1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212
|
// Copyright (c) 2013-2020, SIB - Swiss Institute of Bioinformatics and
// Biozentrum - University of Basel
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <promod3/modelling/model.hh>
#include <promod3/core/export_helper.hh>
using namespace boost::python;
using namespace promod3::modelling;
namespace {
ModellingHandle WrapMHandleFromAln(const ost::seq::AlignmentList& aln,
const boost::python::list& chain_names,
bool include_ligands,
bool spdbv_style) {
std::vector<String> v_chain_names;
promod3::core::ConvertListToVector(chain_names, v_chain_names);
return MHandleFromAln(aln, v_chain_names, include_ligands, spdbv_style);
}
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) {
throw promod3::Error("The backbone_scorer must be properly initialized "
"before it can be used!");
}
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) {
throw promod3::Error("The backbone_scorer_env must be properly initialized "
"before it can be used!");
}
return mhandle.backbone_scorer_env;
}
void WrapSetBackboneScorerEnv(ModellingHandle& mhandle,
promod3::scoring::BackboneScoreEnvPtr env) {
mhandle.backbone_scorer_env = env;
}
promod3::scoring::AllAtomOverallScorerPtr
WrapGetAllAtomScorer(ModellingHandle& mhandle) {
if (!mhandle.all_atom_scorer) {
throw promod3::Error("The all_atom_scorer must be properly initialized "
"before it can be used!");
}
return mhandle.all_atom_scorer;
}
void WrapSetAllAtomScorer(ModellingHandle& mhandle,
promod3::scoring::AllAtomOverallScorerPtr scorer) {
mhandle.all_atom_scorer = scorer;
}
promod3::loop::AllAtomEnvPtr
WrapGetAllAtomScorerEnv(ModellingHandle& mhandle) {
if (!mhandle.all_atom_scorer_env) {
throw promod3::Error("The all_atom_scorer_env must be properly initialized "
"before it can be used!");
}
return mhandle.all_atom_scorer_env;
}
void WrapSetAllAtomScorerEnv(ModellingHandle& mhandle,
promod3::loop::AllAtomEnvPtr env) {
mhandle.all_atom_scorer_env = env;
}
promod3::loop::AllAtomEnvPtr
WrapGetAllAtomSidechainEnv(ModellingHandle& mhandle) {
if (!mhandle.all_atom_sidechain_env) {
throw promod3::Error("The all_atom_sidechain_env must be properly "
"initialized before it can be used!");
}
return mhandle.all_atom_sidechain_env;
}
void WrapSetAllAtomSidechainEnv(ModellingHandle& mhandle,
promod3::loop::AllAtomEnvPtr env) {
mhandle.all_atom_sidechain_env = env;
}
promod3::modelling::SidechainReconstructorPtr
WrapGetSidechainRec(ModellingHandle& mhandle) {
if (!mhandle.sidechain_reconstructor) {
throw promod3::Error("The sidechain_reconstructor must be properly "
"initialized before it can be used!");
}
return mhandle.sidechain_reconstructor;
}
void WrapSetSidechainRec(ModellingHandle& mhandle,
promod3::modelling::SidechainReconstructorPtr sc_rec) {
mhandle.sidechain_reconstructor = sc_rec;
}
void WrapSetSequenceProfiles(ModellingHandle& mhandle,
const boost::python::list& profiles){
ost::seq::ProfileHandleList v_profiles;
promod3::core::ConvertListToVector(profiles, v_profiles);
SetSequenceProfiles(mhandle, v_profiles);
}
void WrapSetPsipredPredictions(ModellingHandle& mhandle,
const boost::python::list& predictions){
promod3::loop::PsipredPredictionList v_predictions;
promod3::core::ConvertListToVector(predictions, v_predictions);
SetPsipredPredictions(mhandle, v_predictions);
}
boost::python::list WrapPsipredPredictionAccess(ModellingHandle& mhandle){
boost::python::list return_list;
promod3::core::AppendVectorToList(mhandle.psipred_predictions, return_list);
return return_list;
}
boost::python::list WrapProfileAccess(ModellingHandle& mhandle){
boost::python::list return_list;
promod3::core::AppendVectorToList(mhandle.profiles, return_list);
return return_list;
}
} // anon ns
void export_model()
{
class_<ModellingHandle>("ModellingHandle", init<>())
.def("Copy", &ModellingHandle::Copy)
.def_readwrite("model", &ModellingHandle::model)
.def_readwrite("gaps", &ModellingHandle::gaps)
.add_property("seqres", &ModellingHandle::seqres)
.add_property("psipred_predictions", &WrapPsipredPredictionAccess)
.add_property("profiles", &WrapProfileAccess)
.add_property("backbone_scorer", &WrapGetBackboneScorer,
&WrapSetBackboneScorer)
.add_property("backbone_scorer_env", &WrapGetBackboneScorerEnv,
&WrapSetBackboneScorerEnv)
.add_property("all_atom_scorer", &WrapGetAllAtomScorer,
&WrapSetAllAtomScorer)
.add_property("all_atom_scorer_env", &WrapGetAllAtomScorerEnv,
&WrapSetAllAtomScorerEnv)
.add_property("all_atom_sidechain_env", &WrapGetAllAtomSidechainEnv,
&WrapSetAllAtomSidechainEnv)
.add_property("sidechain_reconstructor", &WrapGetSidechainRec,
&WrapSetSidechainRec)
;
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("ReorderGaps", &ReorderGaps, (arg("mhandle")));
def("SetupDefaultBackboneScoring", &SetupDefaultBackboneScoring,
(arg("mhandle")));
def("IsBackboneScoringSetUp", &IsBackboneScoringSetUp, (arg("mhandle")));
def("SetupDefaultAllAtomScoring", &SetupDefaultAllAtomScoring,
(arg("mhandle")));
def("IsAllAtomScoringSetUp", &IsAllAtomScoringSetUp, (arg("mhandle")));
def("SetSequenceProfiles", &WrapSetSequenceProfiles,
(arg("mhandle"), arg("profiles")));
def("SetPsipredPredictions", &WrapSetPsipredPredictions,
(arg("mhandle"), arg("psipred_predictions")));
def("MergeMHandle", &MergeMHandle, (arg("source_mhandle"),
arg("target_mhandle"),
arg("source_chain_idx"),
arg("target_chain_idx"),
arg("start_resnum"),
arg("end_resnum"),
arg("transform")));
def("InsertLoop", InsertLoop,
(arg("mhandle"), arg("bb_list"), arg("start_resnum"), arg("chain_idx")));
def("InsertLoopClearGaps", InsertLoopClearGaps,
(arg("mhandle"), arg("bb_list"), arg("gap")));
def("MHandleFromAln", &WrapMHandleFromAln, (arg("aln"), arg("chain_names"),
arg("include_ligands")=false,
arg("spdbv_style")=false));
}
|