From 3e02346f0290bed9a2c6510955acdb6a4f49f5ef Mon Sep 17 00:00:00 2001 From: Niklaus Johner <nij2003@med.cornell.edu> Date: Thu, 22 Mar 2012 18:26:09 -0400 Subject: [PATCH] Added a function to compute how well an EntityView superposes with a denisty map --- modules/mol/alg/pymod/CMakeLists.txt | 2 + .../alg/pymod/export_structure_analysis.cc | 31 +++++++++++ modules/mol/alg/pymod/wrap_mol_alg.cc | 2 + modules/mol/alg/src/CMakeLists.txt | 2 + modules/mol/alg/src/structure_analysis.cc | 54 +++++++++++++++++++ modules/mol/alg/src/structure_analysis.hh | 36 +++++++++++++ 6 files changed, 127 insertions(+) create mode 100644 modules/mol/alg/pymod/export_structure_analysis.cc create mode 100644 modules/mol/alg/src/structure_analysis.cc create mode 100644 modules/mol/alg/src/structure_analysis.hh diff --git a/modules/mol/alg/pymod/CMakeLists.txt b/modules/mol/alg/pymod/CMakeLists.txt index 0ffb3f651..a89211dce 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 000000000..c4df71e3f --- /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 4f974d940..4e4ccc2f5 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 2e3d94b13..259f7f7dc 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 000000000..a590cf0e4 --- /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 000000000..aa9e72041 --- /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 -- GitLab