diff --git a/modules/conop/pymod/CMakeLists.txt b/modules/conop/pymod/CMakeLists.txt index 3af9287193cc368b673e3279d939793cba5e3f5d..9c09906222fb97e1c935590ec22e81b536c94891 100644 --- a/modules/conop/pymod/CMakeLists.txt +++ b/modules/conop/pymod/CMakeLists.txt @@ -1,9 +1,8 @@ set(OST_CONOP_PYMOD_SOURCES wrap_conop.cc - export_builder.cc + # export_builder.cc export_compound.cc export_processor.cc - export_rule_based.cc export_heuristic.cc export_amino_acids.cc export_conop.cc diff --git a/modules/conop/pymod/__init__.py b/modules/conop/pymod/__init__.py index a24f5d2ec21b9333c7548cce372739a3c1753e6d..9f4a7b010deb424af0d570ab30356a8e5d21737d 100644 --- a/modules/conop/pymod/__init__.py +++ b/modules/conop/pymod/__init__.py @@ -73,3 +73,17 @@ def SetDefaultBuilder(builder_name): ''' conop_inst=Conopology.Instance() conop_inst.SetDefaultBuilder(builder_name) + +def SetDefaultLib(compound_lib): + ''' + Set the default compound library. The compound library is used by various + functions of the framework that requires knowledge of naming and + connectivity of residues.j + ''' + conop_inst=Conopology.Instance() + conop_inst.SetDefaultLib(compound_lib) + +def GetDefaultLib(): + conop_inst=Conopology.Instance() + return conop_inst.GetDefaultLib() + diff --git a/modules/conop/pymod/cleanup.py b/modules/conop/pymod/cleanup.py index 9ecf9c7ef12b8bb4fce889a5fb8062aab2364eda..1a51673d778e3e51237a3d576db8e67fca75279f 100644 --- a/modules/conop/pymod/cleanup.py +++ b/modules/conop/pymod/cleanup.py @@ -16,10 +16,9 @@ def Cleanup(entity, strip_water=True, canonicalize=True, remove_ligands=True): :return: a cleaned version of the entity """ #setup - builder = conop.GetBuilder() - if not hasattr(builder, "compound_lib") : - raise RuntimeError( "Cannot cleanup structure, since the default builder doesn't use the compound library") - compound_lib = builder.compound_lib + lib = conop.GetDefaultLib() + if not lib: + raise RuntimeError("Cleanup requires a compound library.") clean_entity = entity.Copy() ed = clean_entity.EditXCS() #remove water residues @@ -27,7 +26,7 @@ def Cleanup(entity, strip_water=True, canonicalize=True, remove_ligands=True): _StripWater(clean_entity, ed) #replace modified residues before removing ligands to avoid removing MSE and others if canonicalize: - _CanonicalizeResidues(clean_entity, ed, compound_lib) + _CanonicalizeResidues(clean_entity, ed, lib) #remove all hetatoms that are not water if remove_ligands: _RemoveLigands(clean_entity, ed) diff --git a/modules/conop/pymod/export_conop.cc b/modules/conop/pymod/export_conop.cc index 309ce86b3572987be230a6badeb519a252c073db..f617adaae70babd193888612098d2802f176bb60 100644 --- a/modules/conop/pymod/export_conop.cc +++ b/modules/conop/pymod/export_conop.cc @@ -22,20 +22,20 @@ using namespace boost::python; #include <ost/conop/conop.hh> #include <ost/mol/mol.hh> -#include <ost/conop/builder.hh> using namespace ost::conop; void export_Conop() { class_<Conopology, boost::noncopyable>("Conopology", no_init) .def("Instance", &Conopology::Instance, return_value_policy<reference_existing_object>()).staticmethod("Instance") - .def("ConnectAll", &Conopology::ConnectAll) - .def("GetBuilder", &Conopology::GetBuilder) - .def("ConnectAll", &Conopology::ConnectAll) - .def("RegisterBuilder", &Conopology::RegisterBuilder) - .def("SetDefaultBuilder", &Conopology::SetDefaultBuilder) + //.def("ConnectAll", &Conopology::ConnectAll) + .def("SetDefaultLib", &Conopology::SetDefaultLib) + .def("GetDefaultLib", &Conopology::GetDefaultLib) + //.def("GetBuilder", &Conopology::GetBuilder) + //.def("ConnectAll", &Conopology::ConnectAll) + //.def("RegisterBuilder", &Conopology::RegisterBuilder) + //.def("SetDefaultBuilder", &Conopology::SetDefaultBuilder) ; - register_ptr_to_python<BuilderP>(); } diff --git a/modules/conop/pymod/export_processor.cc b/modules/conop/pymod/export_processor.cc index b69c0d1d8b800c77620a8031516b0a9acac7f8ac..180da8f48363571c1c8465bb4f8f2b01271f900f 100644 --- a/modules/conop/pymod/export_processor.cc +++ b/modules/conop/pymod/export_processor.cc @@ -18,11 +18,11 @@ //------------------------------------------------------------------------------ // #include <boost/python.hpp> -using namespace boost::python; #include <ost/conop/processor.hh> using namespace ost; using namespace ost::conop; +using namespace boost::python; struct PyProcessor : public Processor {}; struct WrappedProcessor : public PyProcessor, public wrapper<WrappedProcessor> { @@ -44,10 +44,19 @@ struct WrappedProcessor : public PyProcessor, public wrapper<WrappedProcessor> { PyObject* self_; }; + void export_processor() { + enum_<Dialect>("Dialect") + .value("PDB_DIALECT", PDB_DIALECT) + .value("CHARMM_DIALECT", CHARMM_DIALECT) + .export_values() + ; class_<Processor, ProcessorPtr, boost::noncopyable>("_Processor", no_init) .def("Copy", &Processor::Copy) + .add_property("check_bond_feasibility", + &Processor::GetCheckBondFeasibility, + &Processor::SetCheckBondFeasibility) .add_property("strict_hydrogens", &Processor::GetStrictHydrogens, &Processor::SetStrictHydrogens) .add_property("connect", &Processor::GetConnect, diff --git a/modules/conop/pymod/wrap_conop.cc b/modules/conop/pymod/wrap_conop.cc index fc19e341c89673dcd72d2eff2b143df3da10fb2e..b76739548e84353e4c8db1c03d38b9714cd77108 100644 --- a/modules/conop/pymod/wrap_conop.cc +++ b/modules/conop/pymod/wrap_conop.cc @@ -19,7 +19,7 @@ #include <boost/python.hpp> using namespace boost::python; -void export_Builder(); +//void export_Builder(); void export_Compound(); void export_Sanitizer(); void export_Conop(); @@ -31,7 +31,7 @@ void export_rule_based(); void export_diag(); BOOST_PYTHON_MODULE(_ost_conop) { - export_Builder(); + // export_Builder(); export_Conop(); export_processor(); export_rule_based(); diff --git a/modules/conop/src/CMakeLists.txt b/modules/conop/src/CMakeLists.txt index dfa77f4490545802c73b5cfa1ebd14a5fa511601..28cf8368ef52c223b4827046e03bf0635ce4b44f 100644 --- a/modules/conop/src/CMakeLists.txt +++ b/modules/conop/src/CMakeLists.txt @@ -1,34 +1,36 @@ set(OST_CONOP_HEADERS -builder.hh -builder_fw.hh +#builder.hh +#builder_fw.hh conop.hh processor.hh -heuristic_builder.hh +#heuristic_builder.hh amino_acids.hh diag.hh model_check.hh +heuristic.hh compound.hh compound_lib.hh module_config.hh rule_based.hh nonstandard.hh -rule_based_builder.hh +#rule_based_builder.hh ring_finder.hh ) set(OST_CONOP_SOURCES -builder.cc +# builder.cc processor.cc amino_acids.cc conop.cc +heuristic.cc diag.cc rule_based.cc model_check.cc -heuristic_builder.cc +#heuristic_builder.cc compound.cc compound_lib.cc nonstandard.cc -rule_based_builder.cc +#rule_based_builder.cc ring_finder.cc ) diff --git a/modules/conop/src/conop.cc b/modules/conop/src/conop.cc index e48b3444e16c4ac7bf1ba5ef70ea28ff8341f93a..ee9cbea237b0e95563208a774858650aef880b77 100644 --- a/modules/conop/src/conop.cc +++ b/modules/conop/src/conop.cc @@ -21,7 +21,6 @@ #include <ost/log.hh> #include "conop.hh" -#include "heuristic_builder.hh" #include <ost/profile.hh> namespace ost { namespace conop { @@ -33,11 +32,10 @@ Conopology& Conopology::Instance() return impl; } -Conopology::Conopology(): - builder_map_() +Conopology::Conopology()//:builder_map_() { - builder_map_["HEURISTIC"]=BuilderP(new HeuristicBuilder()); - builder_map_["DEFAULT"]=builder_map_["HEURISTIC"]; + //builder_map_["HEURISTIC"]=BuilderP(new HeuristicBuilder()); + //builder_map_["DEFAULT"]=builder_map_["HEURISTIC"]; known_elements_.insert("AC"); known_elements_.insert("AG"); @@ -151,7 +149,7 @@ Conopology::Conopology(): known_elements_.insert("ZN"); known_elements_.insert("ZR"); } - +#if 0 void Conopology::RegisterBuilder(const BuilderP& b, const String& name) { if (!GetBuilder(name)) builder_map_[name]=b; @@ -292,6 +290,7 @@ void Conopology::ConnectAll(const BuilderP& b, mol::EntityHandle eh, int flags) eh.Apply(tmaker); } +#endif bool Conopology::IsValidElement(const String& ele) const { String upper_ele=ele; diff --git a/modules/conop/src/conop.hh b/modules/conop/src/conop.hh index 1234a30fd0ae024a69eeeb0d2a4fa9227bdcb73a..4c7d4633c557794e41157af1ede50152134a8cf3 100644 --- a/modules/conop/src/conop.hh +++ b/modules/conop/src/conop.hh @@ -22,8 +22,8 @@ #include <map> #include <ost/conop/module_config.hh> #include <ost/mol/entity_handle.hh> -#include "builder_fw.hh" - +#include "processor.hh" +#include "compound_lib.hh" namespace ost { namespace conop { @@ -33,14 +33,19 @@ typedef enum { class DLLEXPORT_OST_CONOP Conopology { - typedef std::map<String,BuilderP> BuilderMap; + //typedef std::map<String,BuilderP> BuilderMap; + typedef std::map<String,ProcessorPtr> ProcessorMap; public: // singleton static Conopology& Instance(); + // returns the default compound library (if any) + CompoundLibPtr GetDefaultLib() const { return lib_; } + void SetDefaultLib(const CompoundLibPtr& lib) { lib_ = lib; } + // retrieve a builder by name - BuilderP GetBuilder(const String& name="DEFAULT"); + //BuilderP GetBuilder(const String& name="DEFAULT"); /* convenience function, connect all atoms with given coordinates, @@ -48,20 +53,35 @@ public: does this need to live within Conopology ? */ - void ConnectAll(const BuilderP& b, mol::EntityHandle eh, - int flags=0); + //void ConnectAll(const BuilderP& b, mol::EntityHandle eh, + // int flags=0); - void RegisterBuilder(const BuilderP& b, const String& name); - void SetDefaultBuilder(const String& default_name); + //void RegisterBuilder(const BuilderP& b, const String& name); + //void SetDefaultBuilder(const String& default_name); bool IsValidElement(const String& element) const; + + void RegisterProcessor(const String& name, + const ProcessorPtr& processor) { + proc_map_[name] = processor; + } + + ProcessorPtr GetProcessor(const String& name) const { + ProcessorMap::const_iterator i = proc_map_.find(name); + if (i != proc_map_.end() ) { + return i->second; + } + return ProcessorPtr(); + } private: Conopology(); Conopology(const Conopology&) {} Conopology& operator=(const Conopology&) {return *this;} - BuilderMap builder_map_; + //BuilderMap builder_map_; + ProcessorMap proc_map_;; std::set<String> known_elements_; + CompoundLibPtr lib_; }; }} // diff --git a/modules/conop/src/heuristic.cc b/modules/conop/src/heuristic.cc new file mode 100644 index 0000000000000000000000000000000000000000..11070fd7d71402ec78644cf0b2b9510ceecc5260 --- /dev/null +++ b/modules/conop/src/heuristic.cc @@ -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 +//------------------------------------------------------------------------------ +#include <ost/log.hh> +#include <ost/profile.hh> +#include <ost/mol/xcs_editor.hh> +#include <ost/mol/bond_handle.hh> +#include <ost/mol/torsion_handle.hh> +#include <ost/mol/impl/residue_impl.hh> +#include <ost/mol/impl/atom_impl.hh> +#include <ost/mol/residue_handle.hh> +#include "heuristic.hh" + +namespace ost { namespace conop { + + +void HeuristicProcessor::DoProcess(DiagnosticsPtr diags, + mol::EntityHandle ent) const { +} + +}} diff --git a/modules/conop/src/heuristic.hh b/modules/conop/src/heuristic.hh new file mode 100644 index 0000000000000000000000000000000000000000..2e5250d26f4c8fd0f3ea515a1b902ebbd437d734 --- /dev/null +++ b/modules/conop/src/heuristic.hh @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// 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_CONOP_HEURISTIC_HH +#define OST_CONOP_HEURISTIC_HH + +#include <ost/mol/entity_handle.hh> +#include "compound_lib.hh" +#include "diag.hh" +#include "processor.hh" + +namespace ost { namespace conop { + + +class HeuristicProcessor; + +typedef boost::shared_ptr<HeuristicProcessor> HeuristicProcessorPtr; + +class DLLEXPORT_OST_CONOP HeuristicProcessor : public Processor { +public: + HeuristicProcessor() { + } + virtual ProcessorPtr Copy() const { + return ProcessorPtr(new HeuristicProcessor(*this)); + } +protected: + virtual void DoProcess(DiagnosticsPtr diags, + mol::EntityHandle ent) const; +private: +}; + + +}} +#endif + diff --git a/modules/conop/src/nonstandard.cc b/modules/conop/src/nonstandard.cc index eeccdb60d16425dd1107629e41fb075100a7c0c3..eaf06680d087c05080f0e578828c7bad3fd68c66 100644 --- a/modules/conop/src/nonstandard.cc +++ b/modules/conop/src/nonstandard.cc @@ -26,7 +26,6 @@ #include <ost/conop/conop.hh> #include <ost/mol/mol.hh> #include <ost/mol/alg/construct_cbeta.hh> -#include <ost/conop/rule_based_builder.hh> #include <ost/conop/compound_lib.hh> #include "nonstandard.hh" using namespace ost::mol; @@ -39,18 +38,19 @@ namespace ost { namespace conop { bool CopyResidue(ResidueHandle src_res, ResidueHandle dst_res, XCSEditor& edi) { // first let's get our hands on the component library - conop::BuilderP builder=conop::Conopology::Instance().GetBuilder("DEFAULT"); - conop::RuleBasedBuilderPtr rbb=dyn_cast<conop::RuleBasedBuilder>(builder); - conop::CompoundLibPtr comp_lib=rbb->GetCompoundLib(); + conop::CompoundLibPtr comp_lib=conop::Conopology::Instance().GetDefaultLib(); return CopyResidue(src_res, dst_res, edi, comp_lib); } -bool CopyResidue(ResidueHandle src_res, ResidueHandle dst_res, XCSEditor& edi, CompoundLibPtr comp_lib) +bool CopyResidue(ResidueHandle src_res, ResidueHandle dst_res, + XCSEditor& edi, CompoundLibPtr comp_lib) { bool has_cbeta = false; bool ret; - char parent_src = (comp_lib->FindCompound(src_res.GetName(),Compound::PDB))->GetOneLetterCode (); - char parent_dst = (comp_lib->FindCompound(dst_res.GetName(),Compound::PDB))->GetOneLetterCode (); + char parent_src = (comp_lib->FindCompound(src_res.GetName(), + Compound::PDB))->GetOneLetterCode (); + char parent_dst = (comp_lib->FindCompound(dst_res.GetName(), + Compound::PDB))->GetOneLetterCode (); if (parent_src==parent_dst) { ret = CopyConserved(src_res, dst_res, edi, has_cbeta, comp_lib); } else { @@ -69,9 +69,7 @@ bool CopyConserved(ResidueHandle src_res, ResidueHandle dst_res, XCSEditor& edi, bool& has_cbeta) { // first let's get our hands on the component library - conop::BuilderP builder=conop::Conopology::Instance().GetBuilder("DEFAULT"); - conop::RuleBasedBuilderPtr rbb=dyn_cast<conop::RuleBasedBuilder>(builder); - conop::CompoundLibPtr comp_lib=rbb->GetCompoundLib(); + conop::CompoundLibPtr comp_lib=conop::Conopology::Instance().GetDefaultLib(); return CopyConserved(src_res,dst_res,edi,has_cbeta,comp_lib); } diff --git a/modules/conop/src/processor.hh b/modules/conop/src/processor.hh index d8e3e6bf6e371a5325e4fb7b37543cf674fef31b..0fdaee40dba0ce591e445f6882ee10004e7b7005 100644 --- a/modules/conop/src/processor.hh +++ b/modules/conop/src/processor.hh @@ -25,6 +25,11 @@ namespace ost { namespace conop { +typedef enum { + PDB_DIALECT, + CHARMM_DIALECT +} Dialect; + enum ConopAction { CONOP_WARN = 0, CONOP_SILENT, @@ -114,6 +119,8 @@ private: ConopAction zero_occ_treatment_; }; +ConopAction DLLEXPORT_OST_CONOP ConopActionFromString(const String& name); + /// \brief assigns phi/psi/omega to all residues marked peptide-linking of /// the chain diff --git a/modules/conop/tests/CMakeLists.txt b/modules/conop/tests/CMakeLists.txt index ebc0be35c585e31c4698e4a83d05779f1c2f9d58..d65212779729e7e12c306c30ee5084d67923a526 100644 --- a/modules/conop/tests/CMakeLists.txt +++ b/modules/conop/tests/CMakeLists.txt @@ -1,8 +1,8 @@ set(OST_CONOP_UNIT_TESTS - test_heuristic_builder.cc + # test_heuristic_builder.cc tests.cc test_rule_based_conop.cc - test_builder.cc + # test_builder.cc helper.cc test_compound.py test_cleanup.py diff --git a/modules/conop/tests/test_cleanup.py b/modules/conop/tests/test_cleanup.py index 1dc280f4fbaac9867c7f7a1063217bb4527cfbd0..c2b3b2b0e1614ae50f195d433b62e36034f5e971 100644 --- a/modules/conop/tests/test_cleanup.py +++ b/modules/conop/tests/test_cleanup.py @@ -5,7 +5,7 @@ from ost.conop import cleanup class TestCleanUp(unittest.TestCase): def setUp(self): - self.comp_lib=conop.GetBuilder().compound_lib + self.comp_lib=conop.GetDefaultLib() self.ent = io.LoadPDB("sample_test_cleanup.pdb") self.ent_no_wat = io.LoadPDB("sample_nowater.pdb") self.ent_no_lig = io.LoadPDB("sample_noligands.pdb") @@ -155,8 +155,8 @@ class TestCleanUp(unittest.TestCase): self.assertFalse(self.new_ent.residues[6].IsPeptideLinking()) # here assertFalse instead of assertTrue self.assertTrue(self.new_ent.residues[6].atoms[0].is_hetatom) -if not hasattr(conop.GetBuilder(), 'compound_lib'): - print 'Default builder without compound lib. Ignoring test_cleanup.py tests' +if not conop.GetDefaultLib(): + print 'No compound library available. Ignoring test_cleanup.py tests' sys.exit() if __name__== '__main__': diff --git a/modules/conop/tests/test_compound.py b/modules/conop/tests/test_compound.py index a215a78f7a5dd966c2619346aaabf0f084b7bbd7..700f52b286d6e7f842cd004c2dffff6006603436 100644 --- a/modules/conop/tests/test_compound.py +++ b/modules/conop/tests/test_compound.py @@ -5,7 +5,7 @@ from ost import conop class TestCompound(unittest.TestCase): def setUp(self): - self.compound_lib=conop.GetBuilder().compound_lib + self.compound_lib=conop.GetDefaultLib() def testFindCompound(self): compound=self.compound_lib.FindCompound('***') @@ -22,9 +22,8 @@ class TestCompound(unittest.TestCase): if __name__=='__main__': - builder=conop.GetBuilder() - if not hasattr(builder, 'compound_lib'): - print 'default builder does not use compound library. ignoring unit tests' + if not conop.GetDefaultLib(): + print 'No compound library available. ignoring compound unit tests' else: from ost import testutils testutils.RunTests() diff --git a/modules/conop/tests/test_nonstandard.py b/modules/conop/tests/test_nonstandard.py index 170749c6eacd73bc64f4b6826e4df5d80f104512..f10b7d9d0324b5783a8ad6b0e0c162c8b818c828 100644 --- a/modules/conop/tests/test_nonstandard.py +++ b/modules/conop/tests/test_nonstandard.py @@ -117,9 +117,8 @@ class TestNonStandard(unittest.TestCase): if __name__ == "__main__": - builder=conop.GetBuilder() - if not hasattr(builder, 'compound_lib'): - print 'default builder does not use compound library. ignoring unit tests' + if not conop.GetDefaultLib(): + print 'No compound library available. Ignoring unit tests' else: from ost import testutils testutils.RunTests() diff --git a/modules/gui/pymod/dng/init.py b/modules/gui/pymod/dng/init.py index d46af73d8e1a93678a576698e06bdd69b552b84c..5468b7cd9b358f5a5ec7e08ed89b8ed48dd59386 100644 --- a/modules/gui/pymod/dng/init.py +++ b/modules/gui/pymod/dng/init.py @@ -37,8 +37,8 @@ def _InitRuleBasedBuilder(): if os.path.exists(compound_lib_path): conop_inst=conop.Conopology.Instance() compound_lib=conop.CompoundLib.Load(compound_lib_path) - conop_inst.RegisterBuilder(conop.RuleBasedBuilder(compound_lib), 'RBB') - conop_inst.SetDefaultBuilder('RBB') + conop_inst.SetDefaultLib(compound_lib) + io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor(compound_lib) # switch to rule-based builder for high fidelity if compounds.chemlib is # available diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py index 0d6d0e142147cfc499b279610081f5a0fba28610..6df260a86ccd23e4a9b2b77094cef6ae85379c6d 100644 --- a/modules/io/pymod/__init__.py +++ b/modules/io/pymod/__init__.py @@ -148,9 +148,12 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=None, prof.no_hetatms=_override(prof.no_hetatms, no_hetatms) prof.dialect=_override(prof.dialect, dialect) prof.quack_mode=_override(prof.quack_mode, quack_mode) - prof.strict_hydrogens=_override(prof.strict_hydrogens, strict_hydrogens) + if prof.processor: + prof.processor.strict_hydrogens=_override(prof.processor.strict_hydrogens, + strict_hydrogens) + prof.processor.check_bond_feasibilityk=_override(prof.processor.check_bond_feasibility, + bond_feasibility_check) prof.fault_tolerant=_override(prof.fault_tolerant, fault_tolerant) - prof.bond_feasibility_check=_override(prof.bond_feasibility_check, bond_feasibility_check) prof.join_spread_atom_records=_override(prof.join_spread_atom_records, join_spread_atom_records) @@ -162,13 +165,11 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=None, raise IOError('Can not load PDB %s from www.pdb.org'%filename) conop_inst=conop.Conopology.Instance() - builder=conop_inst.GetBuilder("DEFAULT") - if prof.dialect=='PDB': - builder.dialect=conop.PDB_DIALECT - elif prof.dialect=='CHARMM': - builder.dialect=conop.CHARMM_DIALECT - builder.strict_hydrogens=prof.strict_hydrogens - builder.bond_feasibility_check=prof.bond_feasibility_check + if prof.processor: + if prof.dialect=='PDB': + prof.processor.dialect=conop.PDB_DIALECT + elif prof.dialect=='CHARMM': + prof.processor.dialect=conop.CHARMM_DIALECT reader=PDBReader(filename, prof) reader.read_seqres=seqres try: @@ -177,7 +178,8 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=None, while reader.HasNext(): ent=mol.CreateEntity() reader.Import(ent, restrict_chains) - conop_inst.ConnectAll(builder, ent, 0) + if prof.processor: + prof.processor.Process(ent) ent_list.append(ent) if len(ent_list)==0: raise IOError("File '%s' doesn't contain any entities" % filename) @@ -186,7 +188,8 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=None, ent=mol.CreateEntity() if reader.HasNext(): reader.Import(ent, restrict_chains) - conop_inst.ConnectAll(builder, ent, 0) + if prof.processor: + prof.processor.Process(ent) else: raise IOError("File '%s' doesn't contain any entities" % filename) if seqres: @@ -321,7 +324,9 @@ def LoadMMCIF(filename, restrict_chains="", fault_tolerant=None, calpha_only=Non prof = profile.Copy() prof.calpha_only=_override(prof.calpha_only, calpha_only) - prof.strict_hydrogens=_override(prof.strict_hydrogens, strict_hydrogens) + if prof.processor: + proc = prof.processor + proc.strict_hydrogens=_override(proc.strict_hydrogens, strict_hydrogens) prof.fault_tolerant=_override(prof.fault_tolerant, fault_tolerant) if remote: @@ -331,18 +336,14 @@ def LoadMMCIF(filename, restrict_chains="", fault_tolerant=None, calpha_only=Non else: raise IOError('Can not load PDB %s from www.pdb.org'%filename) - conop_inst = conop.Conopology.Instance() - builder = conop_inst.GetBuilder("DEFAULT") - - builder.strict_hydrogens = prof.strict_hydrogens - try: ent = mol.CreateEntity() reader = MMCifReader(filename, ent, prof) reader.read_seqres = seqres #if reader.HasNext(): reader.Parse() - conop_inst.ConnectAll(builder, ent, 0) + if prof.processor: + prof.processor.Process(ent) #else: # raise IOError("File doesn't contain any entities") if seqres and info: @@ -457,7 +458,8 @@ def _PDBize(biounit, asu, seqres=None, min_polymer_size=10): new_res.SetStringProp('type', mol.StringFromChainType(chain.type)) ins_code = chr(ord(ins_code)+1) _CopyAtoms(res, new_res, edi, tr) - conop.ConnectAll(pdb_bu) + # FIXME: get rid of connect all call... + # conop.ConnectAll(pdb_bu) return pdb_bu MMCifInfoBioUnit.PDBize = _PDBize diff --git a/modules/io/pymod/export_pdb_io.cc b/modules/io/pymod/export_pdb_io.cc index c5abad5d434ddbdf1285c854cf4a427a8d0f34b9..55c842c875415c8d81c412ac8431b53105c50ced 100644 --- a/modules/io/pymod/export_pdb_io.cc +++ b/modules/io/pymod/export_pdb_io.cc @@ -36,22 +36,25 @@ void (PDBWriter::*write_b)(const mol::EntityView&)=&PDBWriter::Write; void export_pdb_io() { class_<IOProfile>("IOProfile", - init<String,bool,bool,bool,bool,bool,bool,bool>((arg("dialect")="PDB", - arg("strict_hydrogens")=false, - arg("quack_mode")=false, - arg("fault_tolerant")=false, - arg("join_spread_atom_records")=false, - arg("no_hetatms")=false, - arg("calpha_only")=false, - arg("bond_feasibility_check")=true))) + init<String,bool,bool,bool,bool,bool,bool,bool, + conop::ProcessorPtr>((arg("dialect")="PDB", + arg("strict_hydrogens")=false, + arg("quack_mode")=false, + arg("fault_tolerant")=false, + arg("join_spread_atom_records")=false, + arg("no_hetatms")=false, + arg("calpha_only")=false, + arg("bond_feasibility_check")=true, + arg("processor")=conop::ProcessorPtr()))) .def_readwrite("dialect", &IOProfile::dialect) .def_readwrite("fault_tolerant", &IOProfile::fault_tolerant) .def_readwrite("quack_mode", &IOProfile::quack_mode) - .def_readwrite("strict_hydrogens", &IOProfile::strict_hydrogens) + //.def_readwrite("strict_hydrogens", &IOProfile::strict_hydrogens) .def_readwrite("no_hetatms", &IOProfile::no_hetatms) .def_readwrite("calpha_only", &IOProfile::calpha_only) .def_readwrite("join_spread_atom_records", &IOProfile::join_spread_atom_records) - .def_readwrite("bond_feasibility_check", &IOProfile::bond_feasibility_check) + .def_readwrite("processor", &IOProfile::processor) + //.def_readwrite("bond_feasibility_check", &IOProfile::bond_feasibility_check) .def("Copy", &IOProfile::Copy) .def(self_ns::str(self)) ; diff --git a/modules/io/src/mol/entity_io_crd_handler.cc b/modules/io/src/mol/entity_io_crd_handler.cc index 0f08c72e08ab95460e5552770706bd3c54d3a002..7820aba23f6715da589a4987475e0f5f9601e75c 100644 --- a/modules/io/src/mol/entity_io_crd_handler.cc +++ b/modules/io/src/mol/entity_io_crd_handler.cc @@ -35,6 +35,7 @@ #include <ost/profile.hh> #include <ost/io/io_exception.hh> +#include <ost/io/mol/io_profile.hh> #include <ost/io/swap_util.hh> #include "entity_io_crd_handler.hh" @@ -409,12 +410,14 @@ bool EntityIOCRDHandler::ProvidesExport(const boost::filesystem::path& loc, mol::EntityHandle LoadCRD(const String& file_name) { Profile profile_load("LoadCRD"); - conop::BuilderP builder = conop::Conopology::Instance().GetBuilder(); CRDReader reader(file_name); mol::EntityHandle ent=mol::CreateEntity(); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); reader.Import(ent); - conop::Conopology::Instance().ConnectAll(builder,ent); + IOProfile& prof = IOProfileRegistry::Instance().GetDefault(); + if (prof.processor) { + prof.processor->Process(ent); + } return ent; } diff --git a/modules/io/src/mol/entity_io_mae_handler.cc b/modules/io/src/mol/entity_io_mae_handler.cc index 6a5306b055c44f7d6c6ccc82f5defa8c1acd1d35..b21407458c4422f105834152444f91215f6e2060 100644 --- a/modules/io/src/mol/entity_io_mae_handler.cc +++ b/modules/io/src/mol/entity_io_mae_handler.cc @@ -36,10 +36,9 @@ #include <ost/log.hh> #include <ost/conop/conop.hh> -#include <ost/conop/heuristic_builder.hh> #include <ost/mol/xcs_editor.hh> #include <ost/profile.hh> - +#include <ost/io/mol/io_profile.hh> #include <ost/io/io_exception.hh> #include <ost/io/swap_util.hh> @@ -366,12 +365,14 @@ bool EntityIOMAEHandler::ProvidesExport(const boost::filesystem::path& loc, mol::EntityHandle LoadMAE(const String& file_name) { //conop::BuilderP builder = conop::Conopology::Instance().GetBuilder(); - conop::BuilderP builder(new conop::HeuristicBuilder); MAEReader reader(file_name); mol::EntityHandle ent=mol::CreateEntity(); mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT); reader.Import(ent); - conop::Conopology::Instance().ConnectAll(builder,ent); + IOProfile& prof = IOProfileRegistry::Instance().GetDefault(); + if (prof.processor) { + prof.processor->Process(ent); + } return ent; } diff --git a/modules/io/src/mol/io_profile.hh b/modules/io/src/mol/io_profile.hh index b4802583a838156ef5aac62048c158b50bff65d3..0bec6ba70c81a7935cac2bd226db36a57116603e 100644 --- a/modules/io/src/mol/io_profile.hh +++ b/modules/io/src/mol/io_profile.hh @@ -23,39 +23,50 @@ #include <map> #include <ost/mol/entity_handle.hh> #include <ost/io/module_config.hh> +#include <ost/conop/processor.hh> + namespace ost { namespace io { + struct DLLEXPORT IOProfile { public: - IOProfile(String d, bool sh, bool qm, bool ft, bool js, bool nh, bool co, bool bf): - dialect(d), strict_hydrogens(sh), quack_mode(qm), fault_tolerant(ft), - join_spread_atom_records(js), no_hetatms(nh), calpha_only(co), bond_feasibility_check(bf) - { } - IOProfile(): dialect("PDB"), strict_hydrogens(true), quack_mode(false), - fault_tolerant(false), join_spread_atom_records(false), no_hetatms(false), - calpha_only(false), bond_feasibility_check(true) + IOProfile(String d, bool sh, bool qm, bool ft, bool js, bool nh, + bool co, bool bf, conop::ProcessorPtr proc=conop::ProcessorPtr()): + dialect(d), quack_mode(qm), fault_tolerant(ft), join_spread_atom_records(js), + no_hetatms(nh), calpha_only(co), processor(proc) + { + if (!processor) return; + processor->SetCheckBondFeasibility(bf); + processor->SetStrictHydrogens(sh); + //processor->SetQuackMode(qm); + } + IOProfile(): dialect("PDB"), quack_mode(false), fault_tolerant(false), + join_spread_atom_records(false), no_hetatms(false), + calpha_only(false), processor() { } - virtual ~IOProfile() { } - String dialect; - bool strict_hydrogens; - bool quack_mode; - bool fault_tolerant; - bool join_spread_atom_records; - bool no_hetatms; - bool calpha_only; - bool bond_feasibility_check; + String dialect; + bool quack_mode; + bool fault_tolerant; + bool join_spread_atom_records; + bool no_hetatms; + bool calpha_only; + conop::ProcessorPtr processor; IOProfile Copy() { - return IOProfile(dialect, strict_hydrogens, quack_mode, fault_tolerant, - join_spread_atom_records, no_hetatms, calpha_only, bond_feasibility_check); + return IOProfile(dialect, processor ? processor->GetStrictHydrogens() : false, + quack_mode, fault_tolerant, join_spread_atom_records, + no_hetatms, calpha_only, + processor ? processor->GetCheckBondFeasibility() : false, + processor ? processor->Copy() : conop::ProcessorPtr()); } - virtual void PostImport(mol::EntityHandle ent) { } }; + inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p) { +#if 0 stream << "IOProfile(dialect='" << p.dialect << "', strict_hydrogens=" << (p.strict_hydrogens ? "True" : "False") << ", quack_mode=" << (p.quack_mode ? "True" : "False") << ", join_spread_atom_records=" @@ -64,6 +75,8 @@ inline std::ostream& operator<<(std::ostream& stream, const IOProfile& p) << (p.calpha_only ? "True" : "False") << ", fault_tolerant=" << (p.fault_tolerant ? "True" : "False") << ", bond_feasibility_check=" << (p.bond_feasibility_check ? "True" : "False") << ")"; +#endif +#warning implement me return stream; } diff --git a/modules/io/src/mol/load_entity.cc b/modules/io/src/mol/load_entity.cc index 6fdfa57576b4c655b744955ae02dd30809cd100e..c1322367cc6e188f4a51c4801e0278dc4b37fe95 100644 --- a/modules/io/src/mol/load_entity.cc +++ b/modules/io/src/mol/load_entity.cc @@ -22,6 +22,7 @@ #include "load_entity.hh" #include <ost/mol/xcs_editor.hh> #include <ost/io/io_manager.hh> +#include <ost/io/mol/io_profile.hh> #include <ost/io/mol/entity_io_handler.hh> #include <ost/profile.hh> @@ -38,19 +39,15 @@ void Import(mol::EntityHandle& eh, const String& filename, int flag) // TODO: proper error handling LOG_DEBUG("calling import on entity io handle"); - /* - This should probably allow various parameters to be passed - to adjust the loading behaviour for a particular filter. - Alternatively, these settings could be done outside via - the main IOManager interface, as global settings per import plugin - */ ent_io->Import(eh,filename); LOG_DEBUG("running conopology"); if(ent_io->RequiresBuilder()) { - conop::BuilderP builder = conop::Conopology::Instance().GetBuilder(); - conop::Conopology::Instance().ConnectAll(builder,eh,flag); + IOProfile& prof = IOProfileRegistry::Instance().GetDefault(); + if (prof.processor) { + prof.processor->Process(eh); + } } } diff --git a/modules/io/src/mol/mmcif_reader.cc b/modules/io/src/mol/mmcif_reader.cc index 762939ca817800366ee487ffadef9da493f5103a..a9c0ad6bfc87cf72cf56a66dda0193ddd981db6b 100644 --- a/modules/io/src/mol/mmcif_reader.cc +++ b/modules/io/src/mol/mmcif_reader.cc @@ -25,7 +25,6 @@ #include <ost/mol/xcs_editor.hh> #include <ost/conop/conop.hh> -#include <ost/conop/rule_based_builder.hh> #include <ost/io/mol/mmcif_reader.hh> namespace ost { namespace io { @@ -670,17 +669,17 @@ void MMCifReader::ParseEntityPoly(const std::vector<StringRef>& columns) } } else if (indices_[PDBX_SEQ_ONE_LETTER_CODE] != -1) { seqres=columns[indices_[PDBX_SEQ_ONE_LETTER_CODE]]; - conop::BuilderP builder=conop::Conopology::Instance().GetBuilder("DEFAULT"); - conop::RuleBasedBuilderPtr rbb=dyn_cast<conop::RuleBasedBuilder>(builder); - if (!rbb) { + + conop::CompoundLibPtr comp_lib=conop::Conopology::Instance() + .GetDefaultLib(); + if (!comp_lib) { if (!warned_rule_based_) { - LOG_WARNING("SEQRES import requires the rule-based builder. Ignoring " - "SEQRES records"); + LOG_WARNING("SEQRES import requires a compound library. " + "Ignoring SEQRES records"); } warned_rule_based_=true; return; } - conop::CompoundLibPtr comp_lib=rbb->GetCompoundLib(); edm_it->second.seqres = this->ConvertSEQRES(seqres.str_no_whitespace(), comp_lib); } else { diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc index b4b097c1b8c8bdffcf29a3ccfac8ee9173a4abf0..739bf6bd34e5363447409c26c0822f09b594403a 100644 --- a/modules/io/src/mol/pdb_reader.cc +++ b/modules/io/src/mol/pdb_reader.cc @@ -29,7 +29,6 @@ #include <ost/message.hh> #include <ost/conop/conop.hh> -#include <ost/conop/rule_based_builder.hh> #include <ost/geom/mat3.hh> #include <ost/io/io_exception.hh> #include "pdb_reader.hh" @@ -235,17 +234,17 @@ void PDBReader::ParseCompndEntry (const StringRef& line, int line_num) void PDBReader::ParseSeqRes(const StringRef& line, int line_num) { - conop::BuilderP builder=conop::Conopology::Instance().GetBuilder("DEFAULT"); - conop::RuleBasedBuilderPtr rbb=dyn_cast<conop::RuleBasedBuilder>(builder); - if (!rbb) { + conop::CompoundLibPtr comp_lib; + comp_lib = conop::Conopology::Instance().GetDefaultLib(); + + if (!comp_lib) { if (!warned_rule_based_) { - LOG_WARNING("SEQRES import requires the rule-based builder. Ignoring " + LOG_WARNING("SEQRES import requires a compound library. Ignoring" "SEQRES records"); } warned_rule_based_=true; return; } - conop::CompoundLibPtr comp_lib=rbb->GetCompoundLib(); if (!seqres_.IsValid()) { seqres_=seq::CreateSequenceList(); } diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc index b0e54cdc37dacf167da076cc78b813c2ee7b4fab..561e91576b565d77dc6e9701bbc803f225167f56 100644 --- a/modules/io/tests/test_io_pdb.cc +++ b/modules/io/tests/test_io_pdb.cc @@ -23,7 +23,7 @@ #include <ost/dyn_cast.hh> #include <ost/mol/mol.hh> #include <ost/conop/conop.hh> -#include <ost/conop/rule_based_builder.hh> +#include <ost/conop/heuristic.hh> #include <ost/io/mol/entity_io_pdb_handler.hh> #include <ost/io/pdb_reader.hh> @@ -425,8 +425,8 @@ BOOST_AUTO_TEST_CASE(deuterium_import) mol::EntityHandle ent=mol::CreateEntity(); reader.Import(ent); // we use conopology to mark amino acids as peptide-linking. - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); // this check makes sure that we correctly detect deal with the deuterium // atoms in the residue. BOOST_CHECK(ent.FindResidue("A", 297).IsPeptideLinking()); @@ -439,8 +439,8 @@ BOOST_AUTO_TEST_CASE(bzdng_318) mol::EntityHandle ent=mol::CreateEntity(); reader.Import(ent); // we use conopology to mark amino acids as peptide-linking. - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); { PDBWriter writer(std::string("testfiles/pdb/bzdng-318-out.pdb"), IOProfile()); @@ -613,8 +613,9 @@ BOOST_AUTO_TEST_CASE(write_ter) reader.Import(ent); // we use conopology to mark amino acids as peptide-linking. this is require // for proper TER output - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/ter.pdb", @@ -634,8 +635,8 @@ BOOST_AUTO_TEST_CASE(write_ter2) reader.Import(ent); // we use conopology to mark amino acids as peptide-linking. this is // require for proper TER output - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/ter2.pdb", @@ -655,8 +656,8 @@ BOOST_AUTO_TEST_CASE(write_ter3) reader.Import(ent); // we use conopology to mark amino acids as peptide-linking. this is // require for proper TER output - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/ter3.pdb", @@ -676,8 +677,8 @@ BOOST_AUTO_TEST_CASE(write_ter4) mol::ResidueHandle r2=edi.AppendResidue(ch, "GLY"); mol::AtomHandle a2=edi.InsertAtom(r2, "N", geom::Vec3(35.0, -99.0, -10.5)); mol::ChainHandle ch2=edi.InsertChain("B"); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/ter_emptychain.pdb", @@ -697,8 +698,8 @@ BOOST_AUTO_TEST_CASE(write_ter5) mol::ResidueHandle r2=edi.AppendResidue(ch, "GLY"); mol::AtomHandle a2=edi.InsertAtom(r2, "N", geom::Vec3(35.0, -99.0, -10.5)); mol::ChainHandle ch2=edi.InsertChain("B"); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent.Select("")); } BOOST_CHECK(compare_files("testfiles/pdb/ter_view-emptychain.pdb", @@ -716,8 +717,8 @@ BOOST_AUTO_TEST_CASE(write_ter6) mol::EntityHandle ent=mol::CreateEntity(); reader.Import(ent); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/ter4.pdb", @@ -733,8 +734,8 @@ BOOST_AUTO_TEST_CASE(write_conect) PDBWriter writer(String("testfiles/pdb/conect-out.pdb"), IOProfile()); mol::EntityHandle ent=mol::CreateEntity(); reader.Import(ent); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/conect.pdb", @@ -855,14 +856,11 @@ BOOST_AUTO_TEST_CASE(seqres_import) String lib_path=GetSharedDataPath()+"/compounds.chemlib"; conop::CompoundLibPtr compound_lib=conop::CompoundLib::Load(lib_path); if (!compound_lib) { - std::cout << "WARNING: skipping SEQRES import unit test. " - << "Rule-based builder is required" << std::endl; + std::cout << "WARNING: skipping SEQRES import unit test. Compound lib is " + << "required" << std::endl; return; } - conop::RuleBasedBuilderPtr rbb(new conop::RuleBasedBuilder(compound_lib)); - conop::Conopology::Instance().RegisterBuilder(rbb, "RBB"); - conop::Conopology::Instance().SetDefaultBuilder("RBB"); - + conop::Conopology::Instance().SetDefaultLib(compound_lib); String fname("testfiles/pdb/seqres.pdb"); IOProfile profile; PDBReader reader(fname, profile); @@ -970,8 +968,8 @@ BOOST_AUTO_TEST_CASE(write_charmm_ter) mol::AtomHandle a=edi.InsertAtom(r, "N", geom::Vec3(32.0, -128.0, -2.5)); mol::ResidueHandle r2=edi.AppendResidue(ch, "GLY"); mol::AtomHandle a2=edi.InsertAtom(r2, "N", geom::Vec3(35.0, -99.0, -10.5)); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + conop::HeuristicProcessor heu_proc; + heu_proc.Process(ent); writer.Write(ent); } BOOST_CHECK(compare_files("testfiles/pdb/charmm_ter.pdb", diff --git a/modules/io/tests/test_mmcif_reader.cc b/modules/io/tests/test_mmcif_reader.cc index eb9c852b521990d2195cabc379a82b5d4673dd31..b66b9edde259be5d00a70e27bea0d8e4c982edce 100644 --- a/modules/io/tests/test_mmcif_reader.cc +++ b/modules/io/tests/test_mmcif_reader.cc @@ -22,7 +22,6 @@ #include <ost/io/io_exception.hh> #include <ost/io/mol/mmcif_reader.hh> #include <ost/conop/conop.hh> -#include <ost/conop/rule_based_builder.hh> #define BOOST_AUTO_TEST_DYN_LINK #include <boost/test/unit_test.hpp> @@ -143,13 +142,11 @@ BOOST_AUTO_TEST_CASE(mmcif_convert_seqres) String lib_path=GetSharedDataPath()+"/compounds.chemlib"; conop::CompoundLibPtr compound_lib=conop::CompoundLib::Load(lib_path); if (!compound_lib) { - std::cout << "WARNING: skipping SEQRES import unit test. " - << "Rule-based builder is required" << std::endl; + std::cout << "WARNING: skipping SEQRES import unit test. Compound " + << "library is required" << std::endl; return; } - conop::RuleBasedBuilderPtr rbb(new conop::RuleBasedBuilder(compound_lib)); - conop::Conopology::Instance().RegisterBuilder(rbb, "RBB"); - conop::Conopology::Instance().SetDefaultBuilder("RBB"); + conop::Conopology::Instance().SetDefaultLib(compound_lib); mol::EntityHandle eh=mol::CreateEntity(); TestMMCifReaderProtected tmmcif_p("testfiles/mmcif/atom_site.mmcif", eh); @@ -158,7 +155,6 @@ BOOST_AUTO_TEST_CASE(mmcif_convert_seqres) BOOST_CHECK_EQUAL(tmmcif_p.ConvertSEQRES("A(MSE)Y", compound_lib), "AMY"); BOOST_CHECK_THROW(tmmcif_p.ConvertSEQRES("A(MSEY", compound_lib), IOException); - conop::Conopology::Instance().SetDefaultBuilder("HEURISTIC"); } BOOST_AUTO_TEST_CASE(mmcif_onbeginloop) @@ -403,11 +399,11 @@ BOOST_AUTO_TEST_CASE(mmcif_entity_poly_tests) String lib_path=GetSharedDataPath()+"/compounds.chemlib"; conop::CompoundLibPtr compound_lib=conop::CompoundLib::Load(lib_path); if (!compound_lib) { - std::cout << "WARNING: skipping SEQRES import unit test. " - << "Rule-based builder is required" << std::endl; + std::cout << "WARNING: skipping SEQRES import unit test. Compound " + << "lib is required" << std::endl; return; } - conop::Conopology::Instance().SetDefaultBuilder("RBB"); + conop::Conopology::Instance().SetDefaultLib(compound_lib); BOOST_MESSAGE(" Running mmcif_entity_poly_tests..."); mol::ChainHandle ch; IOProfile profile; @@ -562,7 +558,6 @@ columns.push_back(StringRef("polydeoxyribonucleotide/polyribonucleotide hybrid", BOOST_MESSAGE(" done."); BOOST_MESSAGE(" done."); - conop::Conopology::Instance().SetDefaultBuilder("HEURISTIC"); } BOOST_AUTO_TEST_CASE(mmcif_citation_tests) diff --git a/modules/mol/alg/src/lddt.cc b/modules/mol/alg/src/lddt.cc index fdd70d953c802f7319611071b57ca1e30a2b5c32..75eec8005263a6854319a158d10be07648cee03b 100644 --- a/modules/mol/alg/src/lddt.cc +++ b/modules/mol/alg/src/lddt.cc @@ -34,7 +34,6 @@ #include <ost/platform.hh> #include <ost/log.hh> -#include <ost/conop/rule_based_builder.hh> #include <ost/dyn_cast.hh> using namespace ost; @@ -51,8 +50,10 @@ EntityHandle load(const String& file, const IOProfile& profile) if (reader.HasNext()) { EntityHandle ent=CreateEntity(); reader.Import(ent); - conop::Conopology& conop_inst=conop::Conopology::Instance(); - conop_inst.ConnectAll(conop_inst.GetBuilder(), ent); + if (profile.processor) { + profile.processor->Process(ent); + } + if (ent.GetChainList().size()!=1) { std::cout << "WARNING: File " << file << "has more than one chain" << std::endl; } @@ -116,7 +117,8 @@ int main (int argc, char **argv) // creates the required loading profile IOProfile profile; - profile.bond_feasibility_check=false; +#warning implement me + //profile.bond_feasibility_check=false; // parses options String sel; diff --git a/modules/seq/alg/tests/test_aligntoseqres.py b/modules/seq/alg/tests/test_aligntoseqres.py index 6c390008e69d81d2613337a863503769b6da1872..126c7f0471b43b1898f0b010d73847a00aed7f92 100644 --- a/modules/seq/alg/tests/test_aligntoseqres.py +++ b/modules/seq/alg/tests/test_aligntoseqres.py @@ -68,9 +68,8 @@ class TestAlignToSeqRes(unittest.TestCase): self.assertEqual(seq.alg.ValidateSEQRESAlignment(seqres_aln, chain), False) if __name__ == "__main__": - builder=conop.GetBuilder() - if not hasattr(builder, 'compound_lib'): - print 'default builder does not use compound library. ignoring unit tests' + if not conop.GetDefaultLib(): + print 'No compound library available. Ignoring unit tests' else: from ost import testutils testutils.RunTests() diff --git a/scripts/init_cl.py b/scripts/init_cl.py index d4a14df4cd339872dc62c2de5898b04f07e75c76..88068214d34d73573a89e1ed1808e9602187867b 100644 --- a/scripts/init_cl.py +++ b/scripts/init_cl.py @@ -40,8 +40,8 @@ def _InitRuleBasedBuilder(): compound_lib_path=os.path.join(ost.GetSharedDataPath(), 'compounds.chemlib') if os.path.exists(compound_lib_path): compound_lib=conop.CompoundLib.Load(compound_lib_path) - conop.RegisterBuilder(conop.RuleBasedBuilder(compound_lib), 'RBB') - conop.SetDefaultBuilder('RBB') + conop.SetDefaultLib(compound_lib) + io.profiles['DEFAULT'].processor = conop.RuleBasedProcessor(compound_lib) # switch to rule-based builder for high fidelity if compounds.chemlib is # available