Skip to main content

Table 1 Sample code for the evaluation of protein backbone dihedral angles and fragment quality

From: rstoolbox - a Python library for large-scale analysis of computational protein design data and structural bioinformatics

Action Code Sample
Load import rstoolbox as rs
import matplotlib.pyplot as plt
import seaborn as sns
Read # With Rosetta installed, a single structure is scored. The
# function will return multiple score terms, sequence,
# secondary structure and phi/psi angles.
ref = rs.io.get_sequence_and_structure(‘1kx8_d2.pdb’)
# Loading Rosetta fragments
seqfrags = rs.io.parse_rosetta_fragments(‘seq.200.9mers’)
# With Rosetta, structural similarity of the fragments can be measured
seqfrags = seqfrags. add_quality_measure (None, ‘mota_1kx8_d2.pdb’)
strfrags = rs.io.parse_rosetta_fragments(‘str.200.9mers’)
strfrags = strfrags. add_quality_measure (None, ‘mota_1kx8_d2.pdb’)
# Loading ab initio data
abseq = rs.io.parse_rosetta_file(‘abinitio_seqfrags.minsilent.gz’)
abstr = rs.io.parse_rosetta_file(‘abinitio_strfrags.minsilent.gz’)
Plot fig = plt.figure(figsize = (170 / 25.4, 170 / 25.4))
grid = (3, 6)
# There are 4 flavours of Ramachandran plots available depending on the
# targeted residues: GENERAL, GLY, PRE-PRO and PRO.
ax1 = plt.subplot2grid(grid, (0, 0), colspan = 2)
# Ramachandran is plotted for a single decoy (selected as parameter 1).
# As a decoy can contain multiple chains, the chain identifier is an
# ubiquitous attribute in multiple functions of the library.
rs.plot.plot_ramachandran_single (ref.iloc[0], ‘A’, ax1)
ax1 = plt.subplot2grid(grid, (0, 2), fig = fig, colspan = 2)
rs. plot.plot_ramachandran_single (ref.iloc[0], ‘A’, ax1, ‘PRE-PRO’)
ax1 = plt.subplot2grid(grid, (0, 4), colspan = 2)
rs.plot.plot_ramachandran_single (ref.iloc[0], ‘A’, ax1, ‘PRO’)
# Show RMSD match of fragments to the corresponding sequence for a
# selected region
ax1 = plt.subplot2grid(grid, (1, 0), colspan = 3)
ax2 = plt.subplot2grid(grid, (1, 3), colspan = 3, sharey = ax1)
rs.plot.plot_fragments (seqfrags. slice_region (21, 56),
                                                                     strfrags.slice_region(21, 56), ax1, ax2)
rs.utils.add_top_title (ax1, ‘sequence-based 9mers’)
rs.utils.add_top_title (ax2, ‘structure-based 9mers’)
# DataFrames can directly work with widely spread plotting functions
ax1 = plt.subplot2grid(grid, (2, 0), colspan = 3)
sns.scatterplot(x = “rms”, y = “score”, data = abseq, ax = ax1)
ax2 = plt.subplot2grid(grid, (2, 3), colspan = 3, sharey = ax1, sharex = ax1)
sns.scatterplot(x = “rms”, y = “score”, data = abstr, ax = ax2)
rs.utils.add_top_title (ax1, ‘sequence-based fragments’)
rs.utils.add_top_title (ax2, ‘structure-based fragments’)
plt.tight_layout()
plt.savefig(‘BMC_Fig2.png’, dpi = 300)
  1. The code shows how to combine structural data obtained from a protein structure file with fragment quality evaluated by Rosetta and ab initio simulations. Code comments are presented in italics while functions from the rstoolbox are highlighted in bold. Styling commands are skipped to facilitate reading, but can be found in the repository’s notebook.