qsscore
– New QS Score Implementation¶
Note
This is a new implementation of QS Score, introduced in OpenStructure 2.4 and tightly integrated with the chain mapping algorithms. The previous qsscoring code that comes with Bertoni et al. is considered deprecated.
- class QSEntity(ent, contact_d=12.0)¶
Helper object for QS-score computation
Holds structural information and getters for interacting chains, i.e. interfaces. Peptide residues are represented by their CB position (CA for GLY) and nucleotides by C3’.
- Parameters:
ent (
ost.mol.EntityView
/ost.mol.EntityHandle
) – Structure for QS score computationcontact_d (
float
) – Pairwise distance of residues to be considered as contacts
- property view¶
Processed structure
View that only contains representative atoms. That’s CB for peptide residues (CA for GLY) and C3’ for nucleotides.
- Type:
- property contact_d¶
Pairwise distance of residues to be considered as contacts
Given at
QSEntity
construction- Type:
float
- GetSequence(chain_name)¶
Get sequence of chain
Returns sequence of specified chain as raw
str
- Parameters:
chain_name (
str
) – Chain inview
- GetPos(chain_name)¶
Get representative positions of chain
That’s CB positions for peptide residues (CA for GLY) and C3’ for nucleotides. Returns positions as a numpy array of shape (n_residues, 3).
- Parameters:
chain_name (
str
) – Chain inview
- PairDist(chain_name_one, chain_name_two)¶
Get pairwise distances between two chains
Returns distances as numpy array of shape (a, b). Where a is the number of residues of the chain that comes BEFORE the other in
chain_names
- GetMinPos(chain_name)¶
Get min x,y,z cooridnates for given chain
Based on positions that are extracted with GetPos
- Parameters:
chain_name (
str
) – Chain inview
- GetMaxPos(chain_name)¶
Get max x,y,z cooridnates for given chain
Based on positions that are extracted with GetPos
- Parameters:
chain_name (
str
) – Chain inview
- PotentialInteraction(chain_name_one, chain_name_two)¶
Returns True if chains potentially interact
Based on crude collision detection. There is no guarantee that they actually interact if True is returned. However, if False is returned, they don’t interact for sure.
- class QSScorer(target, chem_groups, model, alns, contact_d=12.0)¶
Helper object to compute QS-score
Tightly integrated into the mechanisms from the chain_mapping module. The prefered way to derive an object of type
QSScorer
is through the static constructor:FromMappingResult()
. Example score computation including mapping:from ost.mol.alg.qsscore import QSScorer from ost.mol.alg.chain_mapping import ChainMapper ent_1 = io.LoadPDB("path_to_assembly_1.pdb") ent_2 = io.LoadPDB("path_to_assembly_2.pdb") chain_mapper = ChainMapper(ent_1) mapping_result = chain_mapper.GetlDDTMapping(ent_2) qs_scorer = QSScorer.FromMappingResult(mapping_result) score_result = qs_scorer.Score(mapping_result.mapping) print("score:", score_result.QS_global)
QS-score computation in
QSScorer.Score()
implements caching. Repeated computations with alternative chain mappings thus become faster.- Parameters:
target (
ost.mol.EntityView
/ost.mol.EntityHandle
) – Structure designated as “target”. Can be fetched fromost.mol.alg.chain_mapping.MappingResult
chem_groups (
list
oflist
ofstr
) – Groups of chemically equivalent chains in target. Can be fetched fromost.mol.alg.chain_mapping.MappingResult
model (
ost.mol.EntityView
/ost.mol.EntityHandle
) – Structure designated as “model”. Can be fetched fromost.mol.alg.chain_mapping.MappingResult
alns (
dict
with key:tuple
ofstr
, value:ost.seq.AlignmentHandle
) – Each alignment is accessible withalns[(t_chain,m_chain)]
. First sequence is the sequence of the respective chain inqsent1
, second sequence the one fromqsent2
. Can be fetched fromost.mol.alg.chain_mapping.MappingResult
- static FromMappingResult(mapping_result)¶
The preferred way to get a
QSScorer
Static constructor that derives an object of type
QSScorer
using aost.mol.alg.chain_mapping.MappingResult
- Parameters:
mapping_result (
ost.mol.alg.chain_mapping.MappingResult
) – Data source
- property chem_groups¶
Groups of chemically equivalent chains in target
Provided at object construction
- Type:
list
oflist
ofstr
- property alns¶
Alignments between chains in
qsent1
andqsent2
Provided at object construction. Each alignment is accessible with
alns[(t_chain,m_chain)]
. First sequence is the sequence of the respective chain inqsent1
, second sequence the one fromqsent2
.- Type:
dict
with key:tuple
ofstr
, value:ost.seq.AlignmentHandle
- Score(mapping, check=True)¶
Computes QS-score given chain mapping
Again, the preferred way is to get mapping is from an object of type
ost.mol.alg.chain_mapping.MappingResult
.- Parameters:
mapping (
list
oflist
ofstr
) – seeost.mol.alg.chain_mapping.MappingResult.mapping
check (
bool
) – Perform input checks, can be disabled for speed purposes if you know what you’re doing.
- Returns:
Result object of type
QSScorerResult
- ScoreInterface(trg_ch1, trg_ch2, mdl_ch1, mdl_ch2)¶
Computes QS-score only considering one interface
This only works for interfaces that are computed in
Score()
, i.e. interfaces for which the alignments are set up correctly.As all specified chains must be present, the mapping is considered complete which affects
QSScorerResult.QS_global
/QSScorerResult.QS_best
in edge cases of no observed contacts.- Parameters:
trg_ch1 (
str
) – Name of first interface chain in targettrg_ch2 (
str
) – Name of second interface chain in targetmdl_ch1 (
str
) – Name of first interface chain in modelmdl_ch2 (
str
) – Name of second interface chain in model
- Returns:
Result object of type
QSScorerResult
- Raises:
RuntimeError
if no aln for trg_ch1/mdl_ch1 or trg_ch2/mdl_ch2 is available.
- FromFlatMapping(flat_mapping)¶
Same as
Score()
but with flat mapping- Parameters:
flat_mapping (
dict
withstr
as key and value) – Dictionary with target chain names as keys and the mapped model chain names as value- Returns:
Result object of type
QSScorerResult
- class QSScorerResult(weighted_scores, weight_sum, weight_extra_mapped, weight_extra_all, complete_mapping)¶
Holds data relevant for QS-score computation. Formulas for QS scores:
- QS_best = weighted_scores / (weight_sum + weight_extra_mapped) - QS_global = weighted_scores / (weight_sum + weight_extra_all) -> weighted_scores = sum(w(min(d1,d2)) * (1 - abs(d1-d2)/12)) for shared -> weight_sum = sum(w(min(d1,d2))) for shared -> weight_extra_mapped = sum(w(d)) for all mapped but non-shared -> weight_extra_all = sum(w(d)) for all non-shared -> w(d) = 1 if d <= 5, exp(-2 * ((d-5.0)/4.28)^2) else
In the formulas above:
“d”: CA/CB-CA/CB distance of an “inter-chain contact” (“d1”, “d2” for “shared” contacts).
“mapped”: we could map chains of two structures and align residues in
alignments
.“shared”: pairs of residues which are “mapped” and have “inter-chain contact” in both structures.
“inter-chain contact”: CB-CB pairs (CA for GLY) with distance <= 12 A (fallback to CA-CA if
calpha_only
is True).“w(d)”: weighting function (prob. of 2 res. to interact given CB distance) from Xu et al. 2009.
- property weighted_scores¶
weighted_scores attribute as described in formula section above
- Type:
float
- property weight_sum¶
weight_sum attribute as described in formula section above
- Type:
float
- property weight_extra_mapped¶
weight_extra_mapped attribute as described in formula section above
- Type:
float
- property weight_extra_all¶
weight_extra_all attribute as described in formula section above
- Type:
float
- property complete_mapping¶
Whether the underlying mapping of the scored assemblies is complete
In other words: If they have the same stoichiometry. This is relevant for
QS_best
andQS_global
in case of no contacts in any of the scored entities.- Type:
bool
- property QS_best¶
QS_best - the actual score as described in formula section above
If there are no contacts observed in any of the scored entities this score is 1.0 if we’re comparing structures with
complete_mapping
, 0.0 otherwise. In the example of two monomers, no contacts can be observed but they exactly match in terms of quaternary structure. Thus a perfect score. In terms of higher order structure that becomes a bit more abstract but in principle they still have the exact same quaternary structure if they match in stoichiometry but have no single contact.- Type:
float
- property QS_global¶
QS_global - the actual score as described in formula section above
If there are no contacts observed in any of the scored entities this score is 1.0 if we’re comparing structures with
complete_mapping
, 0.0 otherwise. In the example of two monomers, no contacts can be observed but they exactly match in terms of quaternary structure. Thus a perfect score. In terms of higher order structure that becomes a bit more abstract but in principle they still have the exact same quaternary structure if they match in stoichiometry but have no single contact.- Type:
float