Skip to content
Snippets Groups Projects
Commit 86029263 authored by Valerio Mariani's avatar Valerio Mariani
Browse files

Added residue name consistency check

parent c1ab3a03
Branches
Tags
No related merge requests found
......@@ -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);
}
......@@ -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)
......
//------------------------------------------------------------------------------
// 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;
}
}}}
//------------------------------------------------------------------------------
// 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
set(OST_MOL_ALG_UNIT_TESTS
test_superposition.cc
tests.cc
test_consistency_checks.cc
test_convenient_superpose.py
)
......
//------------------------------------------------------------------------------
// 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();
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment