Backbone Score Environment¶
BackboneScoreEnv class¶
- class promod3.scoring.BackboneScoreEnv(seqres)¶
The backbone score environment contains and handles all model-specific data used by the scorers. It is linked to a (list of) seqres (one per chain) at construction. The idea is to initialize it at the beginning of the modelling process with all known data (positions extracted from template, psipred prediction, etc). All scorers attached to that environment will see that data and can calculate scores accordingly. Scoring with this setup is a two step process:
Set the positions you want to score in the environment to make it available to all attached scorers
Call the scorers to get the desired scores
One problem that might occur is that you mess around with the environment and at some point you want to restore the original state. The
BackboneScoreEnv
provides a Stash / Pop mechanism to perform this task.- Parameters:
seqres (
str
/ost.seq.SequenceHandle
/list
ofstr
/ost.seq.SequenceList
) – Internal SEQRES to be set (single chain or list with one per chain). Whenever setting structural data, consistency with this SEQRES is enforced.
To access parts of the environment there are two key arguments to consider:
chain_idx: Index of chain as it occurs in seqres (0 for single sequence)
start_resnum: Residue number defining the position in the SEQRES of chain with index chain_idx. The numbering starts for every chain with the value 1.
- Copy()¶
- Returns:
A copy of the current
BackboneScoreEnv
without any scorers attached- Return type:
- SetInitialEnvironment(env_structure)¶
Sets structural environment with which loops to be scored interact. If structural data was already set, all the existing data gets cleared first.
- Parameters:
env_structure (
ost.mol.EntityHandle
) – Structral data to be set as environment. The chains in env_structure are expected to be in the same order as the SEQRES items provided in constructor.- Raises:
RuntimeError
if env is inconsistent with SEQRES set in constructor. This can be because of corrupt residue numbers or sequence mismatches.
- SetEnvironment(bb_list, start_resnum, chain_idx=0)¶
Add/update structural information in environment. If structural data for specific residues is already set, the data gets resetted for these positions.
- Parameters:
bb_list (
BackboneList
) – Structural data to be set as environment.start_resnum (
int
/ost.mol.ResNum
) – Res. number defining the position in the SEQRES.chain_idx (
int
) – Index of chain the structural data belongs to.
- Raises:
RuntimeError
if sequence of bb_list is inconsistent with previously SEQRES set in constructor or when either start_resnum or chain_idx point to invalid positions in the SEQRES.
- ClearEnvironment(start_resnum, num_residues, chain_idx=0)¶
Clears a stretch of length num_residues in the environment in chain with idx chain_idx starting from residue number start_resnum
- SetPsipredPrediction(pred)¶
Set the psipred prediction, which is necessary to calculate some scores.
- Parameters:
pred (
PsipredPrediction
/list
ofPsipredPrediction
) – Psipred prediction to set (one per chain).- Raises:
RuntimeError
if the number of predictions is inconsistent with the number of internal chains or when one of the predictions’ sizes is inconsistent with the internal SEQRES size.
- AddPairwiseFunction(function, function_type)¶
Adds a pairwise function that can be used in
ApplyPairwiseFunction()
.- Parameters:
function (
PairwiseFunction
) – Pairwise function to be added.function_type (
PairwiseFunctionType
) – What distances should be looked at for this function.
- Returns:
Function index to be used in
ApplyPairwiseFunction()
.- Return type:
- ApplyPairwiseFunction(chain_idx_one, resnum_one, chain_idx_two, resnum_two, f_idx)¶
Define two residues to be evaluated with a given pairwise function. This data can then be used by scorers. Note that the pairs are symmetric and so there is no need to add them twice with switched residues.
- Parameters:
- Raises:
RuntimeError
if any of the chain indices or res. numbers is invalid, the interaction partners are the same residue or when f_idx is an invalid index.
- Stash(start_rnum, num_residues, chain_idx)¶
FILO style stashing. You can perform up to 100 stash operations to save the current state of certain stretches in the environment. This state can be restored by calling
Pop()
. In one stash operation you can either stash one stretch by providing integers as input or several stretches by providing lists of integers.
- Pop()¶
Remove and apply the the last stash operation.
- GetSeqres()¶
- Returns:
SEQRES that was set in constructor (one sequence per chain).
- Return type:
Pairwise function classes¶
- class promod3.scoring.PairwiseFunctionType¶
Enumerates the pairwise function types. Possible values:
CA_PAIRWISE_FUNCTION - Evaluate CA atoms distances.
CB_PAIRWISE_FUNCTION - Evaluate CB atoms distances.
- class promod3.scoring.PairwiseFunction¶
Base class for any pairwise function.
- class promod3.scoring.ConstraintFunction(min_dist, max_dist, values)¶
Inherits all functionality of
PairwiseFunction
. Defines a constraint function. The score for a distance between min_dist and max_dist is determined by linear interpolation assuming the first and last value exactly lying on min_dist and max_dist. For distances outside the range defined by min_dist and max_dist, the returned score is 0.0.- Parameters:
- Raises:
RuntimeError
if min_dist >= max_dist or when min_dist or max_dist are negative or when values contains no elements
- class promod3.scoring.ContactFunction(max_dist, score)¶
Inherits all functionality of
PairwiseFunction
. Defines a simple contact function. The score value is score if distance < max_dist and 0.0 otherwise.
Convenient construction of pairwise functions¶
- class promod3.scoring.DiscoContainer(seqres[, function_type = CA_PAIRWISE_FUNCTION])¶
A container collecting structural information until it can be added in form of
ConstraintFunction
to aBackboneScoreEnv
. The constraint functions are built after the principle of QMEANDisCo.- Parameters:
seqres (
ost.seq.SequenceHandle
) – The sequence with which all added structures must matchfunction_type (
PairwiseFunctionType
) – Whether you want to assess pairwise distances between CA or CB atoms
- AddStructuralInfo(aln)¶
- Parameters:
aln (
ost.seq.AlignmentHandle
) – Alignment, where first sequence represent the initial SEQRES and the second sequence the actual structural info. The second sequence must have a view attached.- Raises:
RuntimeError
if number of sequences in aln is not two, the SEQRES does not match or when the second sequence in aln has no view attached.
- AttachConstraints(env, chain_indices[, cluster_thresh = 0.5, gamma = 70.0])¶
Generates distance constraints and adds it to env. It first clusters the added sequences with a pairwise normalised sequence similarity based on BLOSUM62. It’s a hierarchical clustering with with an average distance metric and cluster_thresh as threshold to merge two clusters. Constraint functions are built for every cluster and finally merged. The influence of the per cluster constraint functions to the overall function depends on the clusters average sequence similarity to the target SEQRES. How fast this influence vanishes gets controlled by gamma. The higher it is, the faster vanishes the influence of structural info from distant clusters. The final pairwise cluster functions get then directly added to the scoring env.
- Parameters:
env (
BackboneScoreEnv
) – The scoring env to which the constraint should be addedchain_indices (
list
ofint
) – Indices of chains for which the constraints should be addedcluster_thresh (
float
) – Controls the clustering behaviour at the initial stage of constraint constructiongamma (
float
) – Controls how fast the influence of constraint functions of distant clusters vanishes
- Raises:
RuntimeError
if one of the chain_indices is invalid or the SEQRES set in env for specified chain is inconsistent with SEQRES you initialized the DiscoContainer with