diff --git a/modelling/pymod/_pipeline.py b/modelling/pymod/_pipeline.py index 779ecc7a786754a94823cf48690721da5101dcd8..ea3a03393de733a10f604b55dc237b61775c9501 100644 --- a/modelling/pymod/_pipeline.py +++ b/modelling/pymod/_pipeline.py @@ -4,7 +4,7 @@ as argument. ''' # internal -from promod3 import loop, sidechain, core +from promod3 import loop, sidechain, core, scoring from _modelling import * from _closegaps import * from _ring_punches import * diff --git a/modelling/pymod/export_model.cc b/modelling/pymod/export_model.cc index 22b369edf2955b18f64993150466b21ca06685b5..1de295e835290e1b40506cd6cd89934a579bb608 100644 --- a/modelling/pymod/export_model.cc +++ b/modelling/pymod/export_model.cc @@ -13,12 +13,45 @@ ModellingHandle (*BuildRawModelHandleList)(const ost::seq::AlignmentList&, = &BuildRawModel; namespace { + int WrapCountEnclosedGaps(ModellingHandle& mhandle, const StructuralGap& gap) { return CountEnclosedGaps(mhandle, gap, false); } + int WrapCountEnclosedIns(ModellingHandle& mhandle, const StructuralGap& gap) { return CountEnclosedGaps(mhandle, gap, true); } + +promod3::scoring::BackboneOverallScorerPtr +WrapGetBackboneScorer(ModellingHandle& mhandle){ + if(!mhandle.backbone_scorer){ + String err = "backbone_scorer must first be properly initialized "; + err += "before it can be used!"; + throw promod3::Error(err); + } + return mhandle.backbone_scorer; +} + +void WrapSetBackboneScorer(ModellingHandle& mhandle, + promod3::scoring::BackboneOverallScorerPtr scorer){ + mhandle.backbone_scorer = scorer; +} + +promod3::scoring::BackboneScoreEnvPtr +WrapGetBackboneScorerEnv(ModellingHandle& mhandle){ + if(!mhandle.backbone_scorer_env){ + String err = "backbone_scorer_env must first be properly initialized "; + err += "before it can be used!"; + throw promod3::Error(err); + } + return mhandle.backbone_scorer_env; +} + +void WrapSetBackboneScorerEnv(ModellingHandle& mhandle, + promod3::scoring::BackboneScoreEnvPtr env){ + mhandle.backbone_scorer_env = env; +} + } // anon ns void export_model() @@ -27,12 +60,18 @@ void export_model() .def_readwrite("model", &ModellingHandle::model) .def_readwrite("gaps", &ModellingHandle::gaps) .def_readwrite("seqres", &ModellingHandle::seqres) + .add_property("backbone_scorer", &WrapGetBackboneScorer, + &WrapSetBackboneScorer) + .add_property("backbone_scorer_env", &WrapGetBackboneScorerEnv, + &WrapSetBackboneScorerEnv) ; + def("ClearGaps", ClearGaps, (arg("mhandle"),arg("gap"))); def("CountEnclosedGaps", WrapCountEnclosedGaps, (arg("mhandle"),arg("gap"))); def("CountEnclosedInsertions", WrapCountEnclosedIns, (arg("mhandle"),arg("gap"))); def("MergeGaps", MergeGaps, (arg("mhandle"),arg("index"))); def("RemoveTerminalGaps", RemoveTerminalGaps, (arg("mhandle"))); + def("SetupDefaultBackboneScorer", &SetupDefaultBackboneScorer,(arg("mhandle"))); def("BuildRawModel", BuildRawModelHandle, (arg("aln"), arg("include_ligands")=false, diff --git a/modelling/src/model.cc b/modelling/src/model.cc index 23fb93f3187ae14058097d90bfecbe9b5a544af4..8d7b32f73eac5505089768162c2fe7c3e8b85189 100644 --- a/modelling/src/model.cc +++ b/modelling/src/model.cc @@ -11,12 +11,17 @@ #include <ost/conop/compound_lib.hh> #include <promod3/core/geom_base.hh> #include <promod3/core/runtime_profiling.hh> +#include <promod3/scoring/scoring_object_loader.hh> +#include <promod3/scoring/pairwise_score.hh> +#include <promod3/scoring/density_score.hh> +#include <promod3/scoring/clash_score.hh> #include "model.hh" using namespace ost::mol; using namespace ost; using namespace ost::seq; using namespace ost::conop; +using namespace promod3::scoring; namespace promod3 { namespace modelling { @@ -202,6 +207,37 @@ int RemoveTerminalGaps(ModellingHandle& mhandle) { return removed_gaps; } +template <typename ScorerPtr> +void AttachScorer(BackboneOverallScorerPtr overall_scorer, + ScorerPtr scorer, + BackboneScoreEnvPtr env, + const String& score_name){ + scorer->AttachEnvironment(*env); + (*overall_scorer)[score_name] = scorer; +} + +void SetupDefaultBackboneScorer(ModellingHandle& mhandle){ + + //setup environment + BackboneScoreEnvPtr env(new BackboneScoreEnv(mhandle.seqres)); + env->SetInitialEnvironment(mhandle.model); + + BackboneOverallScorerPtr scorer(new BackboneOverallScorer); + + AttachScorer(scorer, LoadCBPackingScorer(), env, "cb_packing"); + AttachScorer(scorer, LoadCBetaScorer(), env, "cbeta"); + AttachScorer(scorer, LoadReducedScorer(), env, "reduced"); + AttachScorer(scorer, ClashScorerPtr(new ClashScorer), env, "clash"); + AttachScorer(scorer, LoadHBondScorer(), env, "hbond"); + AttachScorer(scorer, LoadSSAgreementScorer(), env, "ss_agreement"); + AttachScorer(scorer, LoadTorsionScorer(), env, "torsion"); + AttachScorer(scorer, PairwiseScorerPtr(new PairwiseScorer), env, "pairwise"); + AttachScorer(scorer, DensityScorerPtr(new DensityScorer), env, "density"); + + mhandle.backbone_scorer_env = env; + mhandle.backbone_scorer = scorer; +} + bool CopyConserved(ResidueView src_res, ResidueHandle dst_res, XCSEditor& edi, bool& has_cbeta) { diff --git a/modelling/src/model.hh b/modelling/src/model.hh index 318427146d8b9b95315e7351d9999972e013a1db..bf2aaa8ca311e99a7a562b1be4b919242ac23bfc 100644 --- a/modelling/src/model.hh +++ b/modelling/src/model.hh @@ -5,6 +5,8 @@ #include <ost/seq/sequence_list.hh> #include <promod3/core/message.hh> +#include <promod3/scoring/backbone_score_base.hh> +#include <promod3/scoring/backbone_overall_scorer.hh> #include "gap.hh" @@ -30,6 +32,8 @@ struct ModellingHandle { ost::mol::EntityHandle model; StructuralGapList gaps; ost::seq::SequenceList seqres; + promod3::scoring::BackboneScoreEnvPtr backbone_scorer_env; + promod3::scoring::BackboneOverallScorerPtr backbone_scorer; }; // see Python doc @@ -45,6 +49,9 @@ void MergeGaps(ModellingHandle& mhandle, uint index); // see Python doc int RemoveTerminalGaps(ModellingHandle& mhandle); +//see Python doc +void SetupDefaultBackboneScorer(ModellingHandle& mhandle); + /// \brief copies all atom of src_res to dst_res /// \param has_cbeta will be set to true if the src_res has a cbeta and the // dst_residue is not a glycine