From 12cf54e7e99a9ea9a4669936c9d4065386747601 Mon Sep 17 00:00:00 2001 From: Valerio Mariani <valerio.mariani@unibas.ch> Date: Mon, 8 Oct 2012 17:50:01 +0200 Subject: [PATCH] Changed name of CheckResidueTypes function and chain comparison logic Changed the name of the function to RsidueNamesMatch and changed the logic to compare chains according to their idex and not to their name --- modules/mol/alg/doc/molalg.rst | 16 ++++++++++++ modules/mol/alg/pymod/wrap_mol_alg.cc | 2 +- modules/mol/alg/src/consistency_checks.cc | 24 ++++++++++++------ modules/mol/alg/src/consistency_checks.hh | 6 +++-- modules/mol/alg/src/lddt.cc | 25 ++++++++++++++++++- .../mol/alg/tests/test_consistency_checks.cc | 9 +++---- 6 files changed, 64 insertions(+), 18 deletions(-) diff --git a/modules/mol/alg/doc/molalg.rst b/modules/mol/alg/doc/molalg.rst index 9455d58de..66b142940 100644 --- a/modules/mol/alg/doc/molalg.rst +++ b/modules/mol/alg/doc/molalg.rst @@ -374,6 +374,22 @@ The following function detects steric clashes in atomic structures. Two atoms ar :returns: :class:`~ost.mol.alg.ClashingDistances` and :class:`~ost.mol.alg.StereoChemicalParams` respectively +.. function:: ResidueNamesMatch(probe,reference) + + The function 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. Chains are comapred by order, not by chain name + (i.e.: the first chain of the reference will be compared with the first chain of the probe + structure, etc.) + + :param probe: the structure to test + :type probe: :class:`~ost.mol.EntityView` + :param reference: the reference structure + :type reference: :class:`~ost.mol.EntityView` + + :returns: true if the residue names are the same, false otherwise + + .. _traj-analysis: Trajectory Analysis diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc index 1455b635b..08ad6631e 100644 --- a/modules/mol/alg/pymod/wrap_mol_alg.cc +++ b/modules/mol/alg/pymod/wrap_mol_alg.cc @@ -162,7 +162,7 @@ BOOST_PYTHON_MODULE(_ost_mol_alg) def("PrintGlobalRDMap",&mol::alg::PrintGlobalRDMap); def("PrintResidueRDMap",&mol::alg::PrintResidueRDMap); - def("CheckResidueTypes",&mol::alg::CheckResidueTypes); + def("ResidueNamesMatch",&mol::alg::ResidueNamesMatch); } diff --git a/modules/mol/alg/src/consistency_checks.cc b/modules/mol/alg/src/consistency_checks.cc index 3807e461e..371f3c37b 100644 --- a/modules/mol/alg/src/consistency_checks.cc +++ b/modules/mol/alg/src/consistency_checks.cc @@ -28,22 +28,30 @@ namespace ost { namespace mol { namespace alg { /// /// 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. +/// same ResNum) are of the same residue type. Chains are paired by index, not by chain name +/// (i.e., the first chain of the reference will be compared with the first chain of the probe, +/// the second with the second, etc.) -bool CheckResidueTypes (const mol::EntityView& probe, const mol::EntityView& reference) + + + + +bool ResidueNamesMatch (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(); + ChainViewList probe_chains = probe.GetChainList(); + for (unsigned int rci = 0; rci < ref_chains.size(); ++rci) { + ChainView ref_chain= ref_chains[rci]; + if (rci<probe_chains.size()) { + ChainView probe_chain = probe_chains[rci]; + ResidueViewList ref_residues = ref_chain.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()); + return_value = false; + LOG_VERBOSE("Name mismatch for residue " << probe_residue.GetNumber() << " in chain " << rci); LOG_VERBOSE("In reference: " << rri->GetName() << ", in compared structure: " << probe_residue.GetName()); } } diff --git a/modules/mol/alg/src/consistency_checks.hh b/modules/mol/alg/src/consistency_checks.hh index 4833df247..77cffda1c 100644 --- a/modules/mol/alg/src/consistency_checks.hh +++ b/modules/mol/alg/src/consistency_checks.hh @@ -28,9 +28,11 @@ namespace ost { namespace mol { namespace alg { /// /// 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. +/// same ResNum) are of the same residue type. Chains are comapred by order, not by chain name +/// (i.e.: the first chain of the reference will be compared with the first chain of the probe +/// structure, etc.) -bool DLLEXPORT_OST_MOL_ALG CheckResidueTypes (const mol::EntityView& probe, const mol::EntityView& reference); +bool DLLEXPORT_OST_MOL_ALG ResidueNamesMatch (const mol::EntityView& probe, const mol::EntityView& reference); }}} diff --git a/modules/mol/alg/src/lddt.cc b/modules/mol/alg/src/lddt.cc index 8e8277dc0..3f7813b98 100644 --- a/modules/mol/alg/src/lddt.cc +++ b/modules/mol/alg/src/lddt.cc @@ -35,6 +35,7 @@ #include <ost/mol/iterator.hh> #include <ost/platform.hh> #include <ost/log.hh> +#include <ost/mol/alg/consistency_checks.hh> #include <ost/conop/rule_based_builder.hh> #include <ost/dyn_cast.hh> @@ -85,6 +86,8 @@ void usage() std::cerr << " -r <value> distance inclusion radius" << std::endl; std::cerr << " -i <value> sequence separation" << std::endl; std::cerr << " -e print version" << std::endl; + std::cerr << " -x ignore residue name consistency checks" << std::endl; + } // computes coverage @@ -123,12 +126,14 @@ int main (int argc, char **argv) // parses options String sel; bool structural_checks=false; + bool consistency_checks=true; po::options_description desc("Options"); desc.add_options() ("calpha,c", "consider only calpha atoms") ("sel,s", po::value<String>(&sel)->default_value(""), "selection performed on reference structure") ("tolerant,t", "fault tolerant mode") ("structural-checks,f", "perform stereo-chemical and clash checks") + ("ignore-consistency-checks,x", "ignore residue name consistency checks") ("version,e", "version") ("parameter-file,p", po::value<String>(), "stereo-chemical parameter file") ("verbosity,v", po::value<int>(), "verbosity level") @@ -169,6 +174,9 @@ int main (int argc, char **argv) if (vm.count("structural-checks")) { structural_checks=true; } + if (vm.count("ignore-consistency-checks")) { + consistency_checks=false; + } if (vm.count("tolerant")) { profile.fault_tolerant=true; } @@ -215,6 +223,8 @@ int main (int argc, char **argv) cutoffs.push_back(1.0); cutoffs.push_back(2.0); cutoffs.push_back(4.0); + + std::vector<EntityView> ref_list; // loads the reference file and creates the list of distances to check in lddt // if the reference file is a comma-separated list of files, switches to multi- @@ -230,10 +240,10 @@ int main (int argc, char **argv) if (!ref) { exit(-1); } + ref_list.push_back(ref.CreateFullView()); glob_dist_list = CreateDistanceList(ref.CreateFullView(),radius); } else { std::cout << "Multi-reference mode: On" << std::endl; - std::vector<EntityView> ref_list; for (std::vector<StringRef>::const_iterator ref_file_split_sr_it = ref_file_split_sr.begin(); ref_file_split_sr_it != ref_file_split_sr.end();++ref_file_split_sr_it) { String ref_filename = ref_file_split_sr_it->str(); @@ -284,6 +294,19 @@ int main (int argc, char **argv) } EntityView v=model.CreateFullView(); + for (std::vector<EntityView>::const_iterator ref_list_it = ref_list.begin(); + ref_list_it != ref_list.end(); ++ref_list_it) { + bool cons_check = ResidueNamesMatch(v,*ref_list_it); + if (cons_check==false) { + if (consistency_checks==true) { + LOG_ERROR("Residue names in model: " << files[i] << " are inconsistent with one or more references"); + exit(-1); + } else { + LOG_WARNING("Residue names in model: " << files[i] << " are inconsistent with one or more references"); + } + } + } + boost::filesystem::path pathstring(files[i]); String filestring=BFPathToString(pathstring); diff --git a/modules/mol/alg/tests/test_consistency_checks.cc b/modules/mol/alg/tests/test_consistency_checks.cc index 10696a5b6..aad198feb 100644 --- a/modules/mol/alg/tests/test_consistency_checks.cc +++ b/modules/mol/alg/tests/test_consistency_checks.cc @@ -55,8 +55,6 @@ BOOST_AUTO_TEST_CASE(consistency_check) 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(); @@ -66,10 +64,9 @@ BOOST_AUTO_TEST_CASE(consistency_check) 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_CHECK(ost::mol::alg::ResidueNamesMatch(a.CreateFullView(),b.CreateFullView())==true); + BOOST_CHECK(ost::mol::alg::ResidueNamesMatch(c.CreateFullView(),b.CreateFullView())==false); } BOOST_AUTO_TEST_SUITE_END(); -- GitLab