diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc index 72a67e4d09299d1e0ce88c0d839e2fe1b599492a..1455b635bceb17e7ebfba141317a811e119351b0 100644 --- a/modules/mol/alg/pymod/wrap_mol_alg.cc +++ b/modules/mol/alg/pymod/wrap_mol_alg.cc @@ -23,6 +23,8 @@ #include <ost/mol/alg/local_dist_diff_test.hh> #include <ost/mol/alg/superpose_frames.hh> #include <ost/mol/alg/filter_clashes.hh> +#include <ost/mol/alg/consistency_checks.hh> + using namespace boost::python; using namespace ost; @@ -159,5 +161,8 @@ BOOST_PYTHON_MODULE(_ost_mol_alg) def("IsStandardResidue",&mol::alg::IsStandardResidue); def("PrintGlobalRDMap",&mol::alg::PrintGlobalRDMap); def("PrintResidueRDMap",&mol::alg::PrintResidueRDMap); - + + def("CheckResidueTypes",&mol::alg::CheckResidueTypes); + + } diff --git a/modules/mol/alg/src/CMakeLists.txt b/modules/mol/alg/src/CMakeLists.txt index b91dd1e42a5f975e29a192666d847e1c56b33115..eca9aa6e892d9a8bd463be00b1e2f01fc3e59125 100644 --- a/modules/mol/alg/src/CMakeLists.txt +++ b/modules/mol/alg/src/CMakeLists.txt @@ -9,6 +9,7 @@ set(OST_MOL_ALG_HEADERS clash_score.hh trajectory_analysis.hh structure_analysis.hh + consistency_checks.hh ) set(OST_MOL_ALG_SOURCES @@ -21,6 +22,7 @@ set(OST_MOL_ALG_SOURCES construct_cbeta.cc trajectory_analysis.cc structure_analysis.cc + consistency_checks.cc ) set(MOL_ALG_DEPS ost_mol ost_seq) diff --git a/modules/mol/alg/src/consistency_checks.cc b/modules/mol/alg/src/consistency_checks.cc new file mode 100644 index 0000000000000000000000000000000000000000..3807e461e712ff7cd76b639b24f592208c860437 --- /dev/null +++ b/modules/mol/alg/src/consistency_checks.cc @@ -0,0 +1,59 @@ +//------------------------------------------------------------------------------ +// 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 <ost/log.hh> +#include <ost/mol/chain_view.hh> +#include <ost/mol/residue_view.hh> +#include <ost/mol/alg/consistency_checks.hh> + +namespace ost { namespace mol { namespace alg { + +/// \brief Checks that residue types with the same ResNum in the two structures match +/// +/// Requires a reference structure and a probe structure. The function checks that all the +/// residues in the reference structure that appear in the probe structure (i.e., that have the +/// same ResNum) are of the same residue type. + +bool CheckResidueTypes (const mol::EntityView& probe, const mol::EntityView& reference) +{ + bool return_value = true; + ChainViewList ref_chains = reference.GetChainList(); + for (ChainViewList::const_iterator rci = ref_chains.begin(), rce=ref_chains.end(); rci!=rce; ++rci) { + ChainView probe_chain = probe.FindChain(rci->GetName()); + if (probe_chain.IsValid()) { + ResidueViewList ref_residues = rci->GetResidueList(); + for (ResidueViewList::iterator rri=ref_residues.begin(), rre=ref_residues.end(); rri!=rre; ++rri) { + ResidueView probe_residue = probe_chain.FindResidue(rri->GetNumber()); + if (probe_residue.IsValid()) { + if (probe_residue.GetName()!=rri->GetName()) { + return_value =false; + LOG_VERBOSE("Type mismatch for residue " << probe_residue.GetNumber()); + LOG_VERBOSE("In reference: " << rri->GetName() << ", in compared structure: " << probe_residue.GetName()); + } + } + } + } + } + return return_value; +} + +}}} + + + diff --git a/modules/mol/alg/src/consistency_checks.hh b/modules/mol/alg/src/consistency_checks.hh new file mode 100644 index 0000000000000000000000000000000000000000..4833df2474c5d82d6056663f4ee4eca677053487 --- /dev/null +++ b/modules/mol/alg/src/consistency_checks.hh @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// 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 +//------------------------------------------------------------------------------ +#ifndef OST_MOL_CONSISTENCY_CHECKS_HH +#define OST_MOL_CONSISTENCY_CHECKS_HH + +#include <ost/mol/entity_view.hh> +#include <ost/mol/alg/module_config.hh> + +namespace ost { namespace mol { namespace alg { + +/// \brief Checks that residue types with the same ResNum in the two structures match +/// +/// Requires a reference structure and a probe structure. The function checks that all the +/// residues in the reference structure that appear in the probe structure (i.e., that have the +/// same ResNum) are of the same residue type. + +bool DLLEXPORT_OST_MOL_ALG CheckResidueTypes (const mol::EntityView& probe, const mol::EntityView& reference); + +}}} + +#endif + + diff --git a/modules/mol/alg/tests/CMakeLists.txt b/modules/mol/alg/tests/CMakeLists.txt index 1008a3578e384b05160bf5ea4a127d1be693b349..758bbbe10df71687391cac11a0425a253b94dc27 100644 --- a/modules/mol/alg/tests/CMakeLists.txt +++ b/modules/mol/alg/tests/CMakeLists.txt @@ -1,6 +1,7 @@ set(OST_MOL_ALG_UNIT_TESTS test_superposition.cc tests.cc + test_consistency_checks.cc test_convenient_superpose.py ) diff --git a/modules/mol/alg/tests/test_consistency_checks.cc b/modules/mol/alg/tests/test_consistency_checks.cc new file mode 100644 index 0000000000000000000000000000000000000000..10696a5b6cf831194c3df4fff2bed28db90d3cb8 --- /dev/null +++ b/modules/mol/alg/tests/test_consistency_checks.cc @@ -0,0 +1,75 @@ +//------------------------------------------------------------------------------ +// 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 Valerio Mariani + */ +#define BOOST_TEST_MODULE ost_mol_alg +#include <boost/test/unit_test.hpp> +#include <boost/test/auto_unit_test.hpp> + +#include <ost/mol/mol.hh> +#include <ost/mol/alg/consistency_checks.hh> + +using namespace ost::mol; +using namespace ost::mol::alg; + + +BOOST_AUTO_TEST_SUITE( mol_alg ); + +BOOST_AUTO_TEST_CASE(consistency_check) +{ + + EntityHandle a=CreateEntity(); + XCSEditor eda=a.EditXCS(); + ChainHandle ca=eda.InsertChain("A"); + ResidueHandle r1a = eda.AppendResidue(ca, "ALA",1); + ResidueHandle r2a = eda.AppendResidue(ca, "TYR",2); + ResidueHandle r3a = eda.AppendResidue(ca, "LEU",3); + ResidueHandle r4a = eda.AppendResidue(ca, "GLY",4); + ChainHandle ca2=eda.InsertChain("C"); + ResidueHandle r1a2 = eda.AppendResidue(ca2, "PRO",1); + + + EntityHandle b=CreateEntity(); + XCSEditor edb=b.EditXCS(); + ChainHandle cb=edb.InsertChain("A"); + ResidueHandle r1b = edb.AppendResidue(cb, "ALA",1); + ResidueHandle r2b = edb.AppendResidue(cb, "TYR",2); + ResidueHandle r3b = edb.AppendResidue(cb, "LEU",3); + ResidueHandle r4b = edb.AppendResidue(cb, "GLY",4); + ResidueHandle r5b = edb.AppendResidue(cb, "PRO",5); + ChainHandle cb2=edb.InsertChain("B"); + ResidueHandle r1b2 = edb.AppendResidue(cb2, "ALA",1); + + + EntityHandle c=CreateEntity(); + XCSEditor edc=c.EditXCS(); + ChainHandle cc=edc.InsertChain("A"); + ResidueHandle r1c = edc.AppendResidue(cc, "ALA",1); + ResidueHandle r2c = edc.AppendResidue(cc, "PRO",2); + ResidueHandle r3c = edc.AppendResidue(cc, "LEU",3); + ResidueHandle r4c = edc.AppendResidue(cc, "GLY",4); + + + BOOST_CHECK(ost::mol::alg::CheckResidueTypes(a.CreateFullView(),b.CreateFullView())==true); + BOOST_CHECK(ost::mol::alg::CheckResidueTypes(c.CreateFullView(),b.CreateFullView())==false); +} + +BOOST_AUTO_TEST_SUITE_END();