diff --git a/modules/mol/alg/doc/molalg.rst b/modules/mol/alg/doc/molalg.rst index 9455d58dee59c029ea8d37e3d82804f63b625021..66b14294022870a6dfe967ce407994388ef6679d 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 1455b635bceb17e7ebfba141317a811e119351b0..08ad6631efe89ce483e9cc653c2baec321db6927 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 3807e461e712ff7cd76b639b24f592208c860437..371f3c37b6b8fbc921ecd3a82fa647251992b216 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 4833df2474c5d82d6056663f4ee4eca677053487..77cffda1ce3639c37111cc0b7d8fa120015e9958 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 8e8277dc098a239e3ffe734f7c39d2da52163b30..3f7813b98c584c8b5e0bd3fd623ebce0973b6878 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 10696a5b6cf831194c3df4fff2bed28db90d3cb8..aad198febf3decc69d591cb16058cfe9d6e07a24 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();