Representing Loops¶
The most simple representation of structural information in ProMod3 is the
BackboneList
. It provides a way to store the backbone positions of
residues. They provide structural manipulations, they can be manipulated and
converted from, to, or inserted to a ost.mol.EntityHandle
.
from ost import io
from ost import conop
from promod3 import loop
sequence = "AAAAAAAA"
# the backbone gets initially constructed with backbone dihedrals
# typical for helices
bb_list = loop.BackboneList(sequence)
# let's have a look at the set dihedral angles
for i in range(len(bb_list)):
print("Looking at position %d" % i)
if i > 0:
print("phi: %.4f" % bb_list.GetPhiTorsion(i))
if i < len(bb_list)-1:
print("psi: %.4f" % bb_list.GetPsiTorsion(i))
# we now use a TorsionSampler to set random dihedral angles
torsion_sampler = loop.LoadTorsionSampler()
idx = torsion_sampler.GetHistogramIndex(conop.ALA,
conop.ALA,
conop.ALA)
for i in range(len(bb_list)):
dihedrals = torsion_sampler.Draw(idx)
if i > 0:
bb_list.SetPhiTorsion(i, dihedrals[0])
if i < len(bb_list)-1:
bb_list.SetPsiTorsion(i, dihedrals[1])
# let's save down the randomized fragment
io.SavePDB(bb_list.ToEntity(), "randomized_fragment.pdb")
The BackboneList class¶
- class promod3.loop.BackboneList¶
Container for the positions of the backbone atoms (nitrogen (N), alpha carbon (CA), beta carbon (CB), carbon (C), oxygen (O)), the one letter codes and amino acid types of a segment. This object allows to get, set or modify the atom positions, etc through a set of functions (indexing to access each residue starts at 0). To simplify algorithms, which use this structure, each residue has a CB position defined (i.e. even if it’s a glycine) and we only allow amino acid types belonging to the 20 default amino acids. Note that the omega torsion angle defined here for residue i is the dihedral between CA-C of residue i and N-CA of residue i+1 (this is shifted by 1 residue compared to OST’s
GetOmegaTorsion()
).- BackboneList()¶
Creates empty BackboneList
- BackboneList(sequence)¶
Creates a helical BackboneList from given sequence
- Parameters:
sequence (
str
) – Sequence of created BackboneList- Raises:
RuntimeError
if sequence contains a one letter code which is not one of the 20 default amino acids.
- BackboneList(sequence, dihedral_angles)¶
Creates a BackboneList from given sequence and dihedral_angles
- Parameters:
sequence (
str
) – Sequence of created BackboneListdihedral_angles (
list
) – List oftuple
objects defining the backbone dihedral angles of created BackboneList. Everytuple
must either have two or three elements. Two elements are considered to define the phi and psi angles, leading to an idealized omega angle of 180 degrees. In case of three elements, all angles are defined.
- Raises:
RuntimeError
if sequence contains a one letter code which is not one of the 20 default amino acids or if sequence and dihedral_angles are inconsistent in size.
- BackboneList(residues)¶
Creates a BackboneList with positions and sequence extracted from residues.
- Parameters:
residues (
list
) – List ofost.mol.ResidueHandle
objects from which the backbone positions and one letter codes are extracted.- Raises:
RuntimeError
if a residue in residues contains a one letter code which is not one of the 20 default amino acids or when there is a residue not providing all required positions.
- BackboneList(sequence, residues)¶
Creates a BackboneList from given sequence and positions extracted from residues.
- Parameters:
sequence (
str
) – Sequence of created BackboneListresidues (
list
) – List ofost.mol.ResidueHandle
objects from which the backbone positions are extracted.
- Raises:
RuntimeError
if sequence contains a one letter code which is not one of the 20 default amino acids or if sequence and residues are inconsistent in size or when there is a residue not providing all necessary positions.
- ToDensity(padding=10.0, sampling=Vec3(1.0, 1.0, 1.0), resolution=3.0, high_resolution=false)¶
- Returns:
The whole backbone list converted to a density map.
- Return type:
- ToEntity()¶
- Returns:
The whole backbone list converted to an OST entity.
- Return type:
- InsertInto(chain, start_resnum)¶
Inserts the backbone list into the chain. If the residues corresponding to the
BackboneList
are already present in the entity, they will be replaced, otherwise they will be added to the entity.- Parameters:
chain (
ost.mol.ChainHandle
) – The chainstart_resnum (
int
/ost.mol.ResNum
) – Residue number defining the start location of insertion
- InsertInto(map, resolution=3.0, high_resolution=false)¶
- Parameters:
map (
ost.img.ImageHandle
) –resolution (
float
) –high_resolution (
bool
) –
- SetSequence(sequence)¶
- Parameters:
sequence (
str
) – Set amino acid sequence to this.- Raises:
RuntimeError
if sequence contains a one letter code which is not one of the 20 default amino acids or size of sequence does not match.
- Extract(from, to)¶
- Returns:
Items with indices from, …, to-1 of this list.
- Return type:
- ReplaceFragment(sub_fragment, index, superpose_stems)¶
Replaces a fragment of the
BackboneList
starting at position index by the sub_fragment.- Parameters:
sub_fragment (
BackboneList
) – The fragment to be insertedindex (
int
) – The position at which the fragment replacement will beginsuperpose_stems (
bool
) – If set to false, the function will simply replace the accordingBackbone
objects. If set to True, the n-terminal and c-terminal tails are superposed onto the sub_fragment stems using the positions at index and index + len( sub_fragment )-1.
- Raises:
RuntimeError
if sub_fragment does not fully fit into actual fragment at specified index
- GetOLC(index)¶
- Returns:
One letter code of the residue at given index.
- Return type:
char
- Parameters:
index (
int
) – Residue index.
- SetOLC(index, olc)¶
- Parameters:
index (
int
) – Residue index.olc (
char
) – Set one letter code of the residue to this.
- GetAA(index)¶
- Returns:
Amino acid type of the residue at given index.
- Return type:
- Parameters:
index (
int
) – Residue index.
- SetAA(index, aa)¶
- Parameters:
index (
int
) – Residue index.aa (
ost.conop.AminoAcid
) – Set amino acid type of the residue to this.
- Raises:
RuntimeError
if aa == ost.conop.XXX.
- Set(index, n_pos, ca_pos, cb_pos, c_pos, o_pos, olc)¶
- Set(index, n_pos, ca_pos, c_pos, o_pos, olc)
- Set(index, res, olc)
Set all backbone informations. This will reconstruct CB positions if needed and set the amino acid type according to the given one letter code.
- Parameters:
index (
int
) – Residue index.res (
ResidueHandle
) – Residue from which to extract backbone atom positionsn_pos (
Vec3
) – Set position of nitrogen atom to this.ca_pos (
Vec3
) – Set position of alpha carbon atom to this.cb_pos (
Vec3
) – Set position of beta carbon atom to this.c_pos (
Vec3
) – Set position of carbon atom to this.o_pos (
Vec3
) – Set position of oxygen atom to this.olc (
char
) – Set one letter code of the residue to this.
- resize(new_size)¶
- Parameters:
new_size (
int
) – Resize backbone list to contain this number of residues. If new residues are added, their properties will not be initialized. Existing residues are untouched unless the list is shrinked (in that case extra residues are deleted).
- append(n_pos, ca_pos, cb_pos, c_pos, o_pos, olc)¶
- append(n_pos, ca_pos, c_pos, o_pos, olc)
- append(res, olc)
Appends a new residue at the end of the
BackboneList
. This will reconstruct CB positions if needed and set the amino acid type according to the given one letter code.- Parameters:
res (
ResidueHandle
) – Residue from which to extract backbone atom positionsn_pos (
Vec3
) – Set position of nitrogen atom to this.ca_pos (
Vec3
) – Set position of alpha carbon atom to this.cb_pos (
Vec3
) – Set position of beta carbon atom to this.c_pos (
Vec3
) – Set position of carbon atom to this.o_pos (
Vec3
) – Set position of oxygen atom to this.olc (
char
) – Set one letter code of the residue to this.
- clear()¶
Remove all residues from this list.
- Copy()¶
Creates and returns a deep copy of this
BackboneList
. This can be useful, since Python uses reference assignments.- Return type:
- ReconstructCBetaPositions()¶
Does a simple reconstruction of all CB positions based on the current N, CA and C positions.
- ReconstructOxygenPositions(last_psi=-0.78540)¶
Does a simple reconstruction of all oxygen positions based on the actual N, CA and C positions. The position of the last oxygen depends on the next residue, an additional parameter is therefore required.
- Parameters:
last_psi (
float
) – Psi angle of the last BackboneList residue, the default value corresponds to a typical alpha-helix.
- ReconstructCStemOxygen(after_c_stem)¶
Reconstructs the last oxygen of this backbone list. The oxygen position depends on the residue following the C stem. The position is only reconstructed if the residue handle is valid.
- Parameters:
after_c_stem (
ost.mol.ResidueHandle
) – Residue following the C stem (C stem residue is last element of this backbone list)
- ApplyTransform(index, transform)¶
Applies a transformation to the positions of a single residue.
- Parameters:
index (
int
) – Residue index.transform (
ost.geom.Mat4
) – The transformation
- ApplyTransform(from, to, transform)¶
Applies a transformation to the positions of the residues with indices from, …, to-1 of this list.
- Parameters:
from (
int
) – Start index.to (
int
) – End index (one past last residue to transform).transform (
ost.geom.Mat4
) – The transformation
- ApplyTransform(transform)¶
Applies a transformation to all positions of this list.
- Parameters:
transform (
ost.geom.Transform
/ost.geom.Mat4
) – The transformation
- GetTransform(index, res)¶
- GetTransform(index, other, other_index)
- Returns:
Minimum RMSD transformation of residue index onto res or residue other_index of other backbone list considering the positions of the N, CA and C atoms.
- Return type:
- Parameters:
index (
int
) – Residue index.res (
ost.mol.ResidueHandle
) – The other residue.other (
BackboneList
) – The other backbone list.other_index (
int
) – Residue index in other backbone list.
- GetTransform(other)¶
- Returns:
Get minimum RMSD transformation of CA positions of this backbone list onto CA positions of other backbone list.
- Return type:
- Parameters:
other (
BackboneList
) – The other backbone list.
- SuperposeOnto(other)¶
Superposes this backbone list onto another one using CA positions.
- Parameters:
other (
BackboneList
) – The other backbone list.
- RotateAroundPhiTorsion(index, phi, sequential=False)¶
- RotateAroundPsiTorsion(index, psi, sequential=False)¶
- RotateAroundOmegaTorsion(index, omega, sequential=False)¶
- RotateAroundPhiPsiTorsion(index, phi, psi, sequential=False)¶
- SetAroundPhiTorsion(index, phi, sequential=False)¶
- SetAroundPsiTorsion(index, psi, sequential=False)¶
- SetAroundOmegaTorsion(index, omega, sequential=False)¶
- SetAroundPhiPsiTorsion(index, phi, psi, sequential=False)¶
Rotates/sets the phi/psi/omega torsion angle of the backbone at position index in the backbone list by/to the given angle(s).
- Parameters:
index (
int
) – Residue index.phi (
float
) – Angle by which to rotate phi torsion.psi (
float
) – Angle by which to rotate psi torsion.omega (
float
) – Angle by which to rotate omega torsion.sequential (
bool
) – If True, the rotation will be propagated to all residues after the one with index. Otherwise, it will be propagated in the direction where it will affect the least number of residues.
- TransOmegaTorsions(thresh=20 / 180 * pi, allow_prepro_cis=True)¶
Checks whether this backbone list only contains trans omega torsion angles. Usually, you would want this to be the case, but it can fail if you have any unfavorable omega torsion angle in your backbone.
- Parameters:
- Returns:
whether bb_list only contains trans-omega torsions.
- Return type:
- Raises:
RuntimeError
if size of this backbone list is smaller than 3.
- SetBackrub(index, primary_rot_angle, flanking_rot_angle_one, flanking_rot_angle_two)¶
Applies a backrub motion [davis2006] at residue defined by index. The first rotation axis is defined by the CA positions from residues at index -1 and index +1. All atoms in between get rotated around this axis by primary_rot_angle. To restore the the hydrogen bond network of the two transformed oxygens, the backrub motion gets completed by two compensatory rotations. The first rotation is around the axis defined by the CA position from residue index-1 and the transformed central CA position with an angle of flanking_rot_angle_one. The second rotation is around the axis from the transformed central CA position to the CA position from residue at position index +1 with an angle of flanking_rot_angle_two.
- Parameters:
index (
int
) – Position of central residue of the backrub motionprimary_rot_angle (
float
) – Angle of the first rotation in radiansflanking_rot_angle_one (
float
) – Angle of the first compensatory rotation in radiansflanking_rot_angle_two (
float
) – Angle of the second compensatory rotation in radians
- Raises:
RuntimeError
if index is smaller 1 or larger size of BackboneList - 2
- SetBackrub(index, primary_rot_angle[, scaling=1.0])¶
Applies the backrub motion described above but calculates the ideal angles for the compensatory rotations in a way, that the new oxygen positions are as close as possible to the original ones. The ideal angles can be scaled down by scaling to make them less extreme.
- Parameters:
- Raises:
RuntimeError
if index is smaller 1 or larger size of BackboneList - 2
- MinCADistance(other)¶
- Returns:
Minimal pairwise CA-distance between this and the other backbone list.
- Return type:
- Parameters:
other (
BackboneList
) – The other backbone list.
- RMSD(other, superposed_rmsd=False)¶
- CARMSD(other, superposed_rmsd=False)¶
- Returns:
RMSD / C-alpha RMSD between this and the other backbone list.
- Return type:
- Parameters:
other (
BackboneList
) – The other backbone list.superposed_rmsd (
bool
) – Whether to superpose before calculating the RMSD.