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
|
//------------------------------------------------------------------------------
// This file is part of the OpenStructure project <www.openstructure.org>
//
// Copyright (C) 2008-2020 by the OpenStructure authors
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3.0 of the License, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this library; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//------------------------------------------------------------------------------
#include <boost/python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <ost/mol/mm/interaction.hh>
#include <vector>
using namespace boost::python;
namespace{
template<typename T>
boost::python::list VecToList(std::vector<T>& vec){
boost::python::list l;
for(typename std::vector<T>::iterator it=vec.begin();it!=vec.end();++it){
l.append(*it);
}
return l;
}
template<typename T>
std::vector<T> ListToVec(boost::python::list& l){
std::vector<T> vec;
for (int i = 0; i < boost::python::len(l); ++i){
vec.push_back(boost::python::extract<T>(l[i]));
}
return vec;
}
boost::python::list WrapGetNames(ost::mol::mm::InteractionPtr p){
std::vector<String> names = p->GetNames();
return VecToList<String>(names);
}
boost::python::list WrapGetTypes(ost::mol::mm::InteractionPtr p){
std::vector<String> types = p->GetTypes();
return VecToList<String>(types);
}
boost::python::list WrapGetParam(ost::mol::mm::InteractionPtr p){
std::vector<Real> param = p->GetParam();
return VecToList<Real>(param);
}
void WrapSetNames(ost::mol::mm::InteractionPtr p, boost::python::list l){
std::vector<String> names = ListToVec<String>(l);
p->SetNames(names);
}
void WrapSetTypes(ost::mol::mm::InteractionPtr p, boost::python::list l){
std::vector<String> types = ListToVec<String>(l);
p->SetTypes(types);
}
void WrapSetParam(ost::mol::mm::InteractionPtr p, boost::python::list l){
std::vector<Real> param = ListToVec<Real>(l);
p->SetParam(param);
}
}
void export_Interaction()
{
enum_<ost::mol::mm::FuncType>("FuncType")
.value("Invalid", ost::mol::mm::Invalid)
.value("HarmonicBond", ost::mol::mm::HarmonicBond)
.value("HarmonicAngle", ost::mol::mm::HarmonicAngle)
.value("UreyBradleyAngle", ost::mol::mm::UreyBradleyAngle)
.value("PeriodicDihedral", ost::mol::mm::PeriodicDihedral)
.value("PeriodicImproper", ost::mol::mm::PeriodicImproper)
.value("HarmonicImproper", ost::mol::mm::HarmonicImproper)
.value("CMap", ost::mol::mm::CMap)
.value("LJ", ost::mol::mm::LJ)
.value("LJPair", ost::mol::mm::LJPair)
.value("GBSA", ost::mol::mm::GBSA)
.value("DistanceConstraint", ost::mol::mm::DistanceConstraint)
.value("Exclusion", ost::mol::mm::Exclusion)
.value("HarmonicPositionRestraint", ost::mol::mm::HarmonicPositionRestraint)
.value("HarmonicDistanceRestraint", ost::mol::mm::HarmonicDistanceRestraint)
;
class_<ost::mol::mm::Interaction>("Interaction",init<ost::mol::mm::FuncType>())
.def("SetTypes",&WrapSetTypes,(arg("types")))
.def("SetNames",&WrapSetNames,(arg("names")))
.def("SetParam",&WrapSetParam,(arg("parameters")))
.def("GetTypes",&WrapGetTypes)
.def("GetNames",&WrapGetNames)
.def("GetParam",&WrapGetParam)
.def("GetAtoms",&ost::mol::mm::Interaction::GetAtoms,(arg("residue")))
.def("GetFuncType",&ost::mol::mm::Interaction::GetFuncType)
.def("ReplaceAtom",&ost::mol::mm::Interaction::ReplaceAtom,(arg("name"),arg("new_name"),arg("new_type")))
.def("MatchTypes",&ost::mol::mm::Interaction::MatchTypes,(arg("types")))
.def("MatchNames",&ost::mol::mm::Interaction::MatchNames,(arg("names")))
.def("HasName",&ost::mol::mm::Interaction::HasName,(arg("name")))
.def("HasType",&ost::mol::mm::Interaction::HasType,(arg("type")))
.def("IsParametrized",&ost::mol::mm::Interaction::IsParametrized)
.def("HasTypeWildcard",&ost::mol::mm::Interaction::HasTypeWildcard)
.def("HasNameWildcard",&ost::mol::mm::Interaction::HasNameWildcard)
;
boost::python::register_ptr_to_python<ost::mol::mm::InteractionPtr>();
class_<std::vector<ost::mol::mm::InteractionPtr> >("InteractionList", init<>())
.def(vector_indexing_suite<std::vector<ost::mol::mm::InteractionPtr>, true>())
;
}
|