diff --git a/modules/mol/alg/pymod/lddt.py b/modules/mol/alg/pymod/lddt.py index 12944128409d41b4cc7f3964d8d33f6c34d71e76..b7147b5f3d5859a820fcf5f4250e3908a1d3c875 100644 --- a/modules/mol/alg/pymod/lddt.py +++ b/modules/mol/alg/pymod/lddt.py @@ -1,6 +1,7 @@ import numpy as np from ost import mol +from ost import conop class SymmetrySettings: @@ -87,15 +88,17 @@ class lDDTScorer: :param target: The target :type target: :class:`ost.mol.EntityHandle`/:class:`ost.mol.EntityView` :param compound_lib: Compound library from which a compound for each residue - is extracted based on its name. Atoms defined in the - compound are searched in the residue and build the - reference for scoring. If the residue has atoms with - names ["A", "B", "C"] but the corresponding compound - only has ["A", "B"], "A" and "B" are considered for - scoring. If the residue has atoms ["A", "B"] but the - compound has ["A", "B", "C"], "C" is considered missing - and does not influence scoring, even if present in the - model. + is extracted based on its name. Uses + :func:`ost.conop.GetDefaultLib` if not given, raises + if this returns no valid compound library. Atoms + defined in the compound are searched in the residue and + build the reference for scoring. If the residue has + atoms with names ["A", "B", "C"] but the corresponding + compound only has ["A", "B"], "A" and "B" are + considered for scoring. If the residue has atoms + ["A", "B"] but the compound has ["A", "B", "C"], "C" is + considered missing and does not influence scoring, even + if present in the model. :type compound_lib: :class:`ost.conop.CompoundLib` :param inclusion_radius: All pairwise distances < *inclusion_radius* are considered for scoring @@ -146,7 +149,7 @@ class lDDTScorer: def __init__( self, target, - compound_lib, + compound_lib=None, inclusion_radius=15, sequence_separation=0, symmetry_settings=None, @@ -157,6 +160,11 @@ class lDDTScorer: self.target = target self.inclusion_radius = inclusion_radius self.sequence_separation = sequence_separation + if compound_lib is None: + compound_lib = conop.GetDefaultLib() + if compound_lib is None: + raise RuntimeError("No compound_lib given and conop.GetDefaultLib " + "returns no valid compound library") self.compound_lib = compound_lib if symmetry_settings is None: self.symmetry_settings = GetDefaultSymmetrySettings() diff --git a/modules/mol/alg/pymod/qsscoring.py b/modules/mol/alg/pymod/qsscoring.py index 38727ea1c650d13099097fa7ead8ef9d7d175967..e5ab8d1d76c2a30ac614f81cbead719276ad875d 100644 --- a/modules/mol/alg/pymod/qsscoring.py +++ b/modules/mol/alg/pymod/qsscoring.py @@ -1244,7 +1244,7 @@ class OligoLDDTScorer(object): raise RuntimeError("OligolDDT computation requires a compound library!") r = self.settings.radius seq_sep = self.settings.sequence_separation - self._lddt_scorer = lddt.lDDTScorer(self.ref, conop.GetDefaultLib(), + self._lddt_scorer = lddt.lDDTScorer(self.ref, inclusion_radius = r, sequence_separation = seq_sep) return self._lddt_scorer diff --git a/modules/mol/alg/tests/test_lddt.py b/modules/mol/alg/tests/test_lddt.py index 84c274ac7ddca5864dc0bc92875c547828103f40..52598fdc83d8a49c6ba1b7a6bf71af19f13dc83b 100644 --- a/modules/mol/alg/tests/test_lddt.py +++ b/modules/mol/alg/tests/test_lddt.py @@ -25,7 +25,7 @@ class TestlDDT(unittest.TestCase): target = _LoadFile("7SGN_C_target.pdb") # do awesome implementation - scorer = lDDTScorer(target, conop.GetDefaultLib()) + scorer = lDDTScorer(target) aws_score, aws_per_res_scores = scorer.lDDT(model) # do reference implementation @@ -51,7 +51,7 @@ class TestlDDT(unittest.TestCase): target = _LoadFile("7W1F_B_target.pdb") # do awesome implementation - scorer = lDDTScorer(target, conop.GetDefaultLib()) + scorer = lDDTScorer(target) aws_score, aws_per_res_scores = scorer.lDDT(model) # do reference implementation @@ -80,7 +80,7 @@ class TestlDDT(unittest.TestCase): target = ent_full.Select('peptide=true and cname=A,B') # we use functionality from QS-scorer to derive a mapping qs_scorer = QSscorer(model, target) - lddt_scorer = lDDTScorer(target, conop.GetDefaultLib()) + lddt_scorer = lDDTScorer(target) score, per_res_scores = lddt_scorer.lDDT(model, chain_mapping=qs_scorer.chain_mapping) @@ -113,7 +113,7 @@ class TestlDDT(unittest.TestCase): # we use functionality from QS-scorer to derive a mapping qs_scorer = QSscorer(model, target) - lddt_scorer = lDDTScorer(target, conop.GetDefaultLib()) + lddt_scorer = lDDTScorer(target) # naively running lDDT will fail, as residue-residue mapping happens # with resnums. Since we shifted that stuff above we'll get an error @@ -143,25 +143,20 @@ class TestlDDT(unittest.TestCase): def test_lDDT_seqsep(self): target = _LoadFile("7SGN_C_target.pdb") with self.assertRaises(NotImplementedError): - scorer = lDDTScorer(target, conop.GetDefaultLib(), - sequence_separation=42) - scorer = lDDTScorer(target, conop.GetDefaultLib(), - sequence_separation=0) + scorer = lDDTScorer(target, sequence_separation=42) + scorer = lDDTScorer(target, sequence_separation=0) def test_calpha(self): model = _LoadFile("7SGN_C_model.pdb") target = _LoadFile("7SGN_C_target.pdb") # do scoring and select aname=CA - scorer = lDDTScorer(target.Select("aname=CA"), - conop.GetDefaultLib()) + scorer = lDDTScorer(target.Select("aname=CA")) score_one, per_res_scores_one = scorer.lDDT(model) score_two, per_res_scores_two = scorer.lDDT(model.Select("aname=CA")) # no selection, just setting calpha flag should give the same - scorer = lDDTScorer(target, - conop.GetDefaultLib(), - calpha=True) + scorer = lDDTScorer(target, calpha=True) score_three, per_res_scores_three = scorer.lDDT(model) # check @@ -181,8 +176,7 @@ class TestlDDT(unittest.TestCase): ed.RenameResidue(model.residues[42], "asdf") # do scoring and select aname=CA - scorer = lDDTScorer(target.Select("aname=CA"), - conop.GetDefaultLib()) + scorer = lDDTScorer(target.Select("aname=CA")) with self.assertRaises(RuntimeError): scorer.lDDT(model)