diff --git a/modules/mol/alg/pymod/CMakeLists.txt b/modules/mol/alg/pymod/CMakeLists.txt index 0ffb3f65183cb217c5fcfe6b1093a884ea42bca9..a89211dce1155bcd8fb992b333ab4caa19c42cfc 100644 --- a/modules/mol/alg/pymod/CMakeLists.txt +++ b/modules/mol/alg/pymod/CMakeLists.txt @@ -3,12 +3,14 @@ set(OST_MOL_ALG_PYMOD_SOURCES export_svd_superpose.cc export_clash.cc export_trajectory_analysis.cc + export_structure_analysis.cc ) set(OST_MOL_ALG_PYMOD_MODULES "__init__.py" views.py superpose.py + structure_analysis.py ) if (ENABLE_IMG) diff --git a/modules/mol/alg/pymod/export_structure_analysis.cc b/modules/mol/alg/pymod/export_structure_analysis.cc new file mode 100644 index 0000000000000000000000000000000000000000..c4df71e3f788e6ce659bcd517db0fb38bcee3652 --- /dev/null +++ b/modules/mol/alg/pymod/export_structure_analysis.cc @@ -0,0 +1,31 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 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> +using namespace boost::python; + +#include <ost/mol/alg/structure_analysis.hh> + +using namespace ost; +using namespace ost::mol::alg; + +void export_StructureAnalysis() +{ + def("GetPosListFromView",&GetPosListFromView, (arg("view"))); + def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); +} diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc index 4f974d940ee2f090eb4d0a5c3d90f46a06616747..4e4ccc2f56d67b196549fb5648efd39b6b2430a8 100644 --- a/modules/mol/alg/pymod/wrap_mol_alg.cc +++ b/modules/mol/alg/pymod/wrap_mol_alg.cc @@ -27,6 +27,7 @@ using namespace ost; void export_svdSuperPose(); void export_TrajectoryAnalysis(); +void export_StructureAnalysis(); void export_Clash(); #if OST_IMG_ENABLED void export_entity_to_density(); @@ -48,6 +49,7 @@ BOOST_PYTHON_MODULE(_ost_mol_alg) { export_svdSuperPose(); export_TrajectoryAnalysis(); + export_StructureAnalysis(); #if OST_IMG_ENABLED export_entity_to_density(); #endif diff --git a/modules/mol/alg/src/CMakeLists.txt b/modules/mol/alg/src/CMakeLists.txt index 2e3d94b132b02cccb02401641ec9bf0736934b2c..259f7f7dc860c7b8f787527cd44efc9321659a02 100644 --- a/modules/mol/alg/src/CMakeLists.txt +++ b/modules/mol/alg/src/CMakeLists.txt @@ -8,6 +8,7 @@ set(OST_MOL_ALG_HEADERS construct_cbeta.hh clash_score.hh trajectory_analysis.hh + structure_analysis.hh ) set(OST_MOL_ALG_SOURCES @@ -19,6 +20,7 @@ set(OST_MOL_ALG_SOURCES filter_clashes.cc construct_cbeta.cc trajectory_analysis.cc + structure_analysis.cc ) set(MOL_ALG_DEPS ost_mol ost_seq) diff --git a/modules/mol/alg/src/structure_analysis.cc b/modules/mol/alg/src/structure_analysis.cc new file mode 100644 index 0000000000000000000000000000000000000000..a590cf0e4f3af1cdde117353aebe11a112519bb8 --- /dev/null +++ b/modules/mol/alg/src/structure_analysis.cc @@ -0,0 +1,54 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 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 +//------------------------------------------------------------------------------ + +/* + * Author Niklaus Johner + */ + +#include <ost/base.hh> +#include <ost/mol/mol.hh> +#include "structure_analysis.hh" + +namespace ost { namespace mol { namespace alg { + +geom::Vec3List GetPosListFromView(const EntityView& view){ + CheckHandleValidity(view); + geom::Vec3List vl; + AtomViewList atoms=view.GetAtomList(); + vl.reserve(atoms.size()); + for (AtomViewList::const_iterator i=atoms.begin(), + e=atoms.end(); i!=e; ++i) { + vl.push_back(i->GetPos()); + } + return vl; +} + +Real CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){ + Real sum,v; + sum=0; + CheckHandleValidity(density_map); + for (geom::Vec3List::const_iterator v1=vl.begin(),e=vl.end(); v1!=e; ++v1) { + img::Point p(density_map.CoordToIndex(*v1)); + v=density_map.GetReal(p); + sum=sum+v; + } + return sum; +} + +}}} //ns diff --git a/modules/mol/alg/src/structure_analysis.hh b/modules/mol/alg/src/structure_analysis.hh new file mode 100644 index 0000000000000000000000000000000000000000..aa9e720414d2884103499d33bf661939261a8e42 --- /dev/null +++ b/modules/mol/alg/src/structure_analysis.hh @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// This file is part of the OpenStructure project <www.openstructure.org> +// +// Copyright (C) 2008-2011 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 +//------------------------------------------------------------------------------ + +/* + * Niklaus Johner + */ +#ifndef OST_STRUCTURE_ANALYSIS_HH +#define OST_STRUCTURE_ANALYSIS_HH + +#include <ost/mol/alg/module_config.hh> + +#include <ost/mol/entity_view.hh> +#include <ost/img/map.hh> + + +namespace ost { namespace mol { namespace alg { + geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view); + Real DLLEXPORT_OST_MOL_ALG CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map); +}}}//ns +#endif