diff --git a/modules/mol/base/pymod/export_residue.cc b/modules/mol/base/pymod/export_residue.cc index c4c43e5d89ca06505a65a7b39035692d7150681e..1e1b9f74a60d94c224b9aad51153a9e873b2a4a7 100644 --- a/modules/mol/base/pymod/export_residue.cc +++ b/modules/mol/base/pymod/export_residue.cc @@ -43,13 +43,25 @@ namespace { void set_sec_struct1(ResidueBase* b, const SecStructure& s) {b->SetSecStructure(s);} void set_sec_struct2(ResidueBase* b, char c) {b->SetSecStructure(SecStructure(c));} - void set_chemclass1(ResidueBase* b, const ChemClass& cc) {b->SetChemClass(cc);} - void set_chemclass2(ResidueBase* b, char c) {b->SetChemClass(ChemClass(c));} + void set_chemclass(ResidueBase* b, object po) + { + extract<ChemClass> ex1(po); + if(ex1.check()) { + b->SetChemClass(ex1()); + } + extract<char> ex2(po); + if(ex2.check()) { + b->SetChemClass(ChemClass(ex2())); + } + std::string st=extract<std::string>(po); + if(st.empty()) { + throw Error("expected non-empty string as chem class"); + } + b->SetChemClass(ChemClass(st[0])); + } } -//BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_insert_overloads, -// ResidueHandle::InsertAtom, 2, 3) void export_Residue() { @@ -125,6 +137,11 @@ void export_Residue() .def("IsPeptideLinking", &ResidueBase::IsPeptideLinking) .add_property("peptide_linking", &ResidueBase::IsPeptideLinking) + .def("GetCentralAtom", &ResidueBase::GetCentralAtom) + .def("SetCentralAtom", &ResidueBase::SetCentralAtom) + .add_property("central_atom", &ResidueBase::GetCentralAtom, &ResidueBase::SetCentralAtom) + .add_property("central_normal", &ResidueBase::GetCentralNormal) + .def("GetKey", &ResidueBase::GetKey, return_value_policy<copy_const_reference>()) .def("GetName", &ResidueBase::GetName, @@ -132,8 +149,8 @@ void export_Residue() .def("GetNumber", &ResidueBase::GetNumber, return_value_policy<copy_const_reference>()) .def("GetChemClass", &ResidueBase::GetChemClass) - .def("SetChemClass", set_chemclass1) - .def("SetChemClass", set_chemclass2) + .def("SetChemClass", set_chemclass) + .add_property("chem_class",&ResidueBase::GetChemClass,set_chemclass) .add_property("is_ligand", &ResidueBase::IsLigand, &ResidueBase::SetIsLigand) .def("IsLigand", &ResidueBase::IsLigand) .def("SetIsLigand", &ResidueBase::SetIsLigand) @@ -186,7 +203,6 @@ void export_Residue() .def("GetCenterOfMass", &ResidueHandle::GetCenterOfMass) .def("GetCenterOfAtoms", &ResidueHandle::GetCenterOfAtoms) .def("GetGeometricCenter", geom_center<ResidueHandle>) - .def("GetCentralAtom", &ResidueHandle::GetCentralAtom) .add_property("mass", &ResidueHandle::GetMass) .add_property("center_of_mass", &ResidueHandle::GetCenterOfMass) .add_property("center_of_atoms", &ResidueHandle::GetCenterOfAtoms) diff --git a/modules/mol/base/src/impl/residue_impl.cc b/modules/mol/base/src/impl/residue_impl.cc index d8ce7f6d3f97b6c0bfe9e452d0c2760d54bbd01c..28f0cc6f9047616848e8d0a334da946a6fdfea9f 100644 --- a/modules/mol/base/src/impl/residue_impl.cc +++ b/modules/mol/base/src/impl/residue_impl.cc @@ -43,7 +43,8 @@ ResidueImpl::ResidueImpl(const EntityImplPtr& ent, atom_list_(), sec_structure_(SecStructure::COIL), olc_('?'), - protein_(false), ligand_(false) + protein_(false), ligand_(false), + central_atom_() { } @@ -163,6 +164,7 @@ EntityImplPtr ResidueImpl::GetEntity() const AtomImplPtr ResidueImpl::GetCentralAtom() const { + if(central_atom_) return central_atom_; if (chem_class_.IsNucleotideLinking()) { for (AtomImplList::const_iterator it=atom_list_.begin(); it!=atom_list_.end();++it) { @@ -178,6 +180,12 @@ AtomImplPtr ResidueImpl::GetCentralAtom() const return AtomImplPtr(); } +void ResidueImpl::SetCentralAtom(const AtomImplPtr& a) +{ + central_atom_=a; +} + + char ResidueImpl::GetOneLetterCode() const { return olc_; diff --git a/modules/mol/base/src/impl/residue_impl.hh b/modules/mol/base/src/impl/residue_impl.hh index 560571f87d1ac8f9c492704a54d5b3dcfe6bee15..8b01d32d2f3d8873f8098805dbe62028334dc2ec 100644 --- a/modules/mol/base/src/impl/residue_impl.hh +++ b/modules/mol/base/src/impl/residue_impl.hh @@ -72,6 +72,13 @@ public: ChainImplPtr GetChain() const; AtomImplPtr GetCentralAtom() const; + /*! + explicitely set central atom + + if this is set, it will override the heuristic encoded + in GetCentralAtom; pass an invalid ptr to deactivate again + */ + void SetCentralAtom(const AtomImplPtr& a); geom::Vec3 GetCentralNormal() const; @@ -209,6 +216,7 @@ private: void AddAltAtom(const String& group, const AtomImplPtr& atom, const geom::Vec3& position); void RemoveAltPositionsForAtom(const AtomImplPtr& atom); + String curr_group_; AtomEntryGroups alt_groups_; EntityImplW ent_; @@ -221,8 +229,13 @@ private: ChemClass chem_class_; char olc_; // whether the residue is part of the protein. + // TODO: this should be fixed to be a enum'ed type aka + // RESIDUE_TYPE type_; + // where enum is one of protein, ligand, dna, lipid, etc bool protein_; bool ligand_; + AtomImplPtr central_atom_; + }; }}} // ns diff --git a/modules/mol/base/src/residue_base.cc b/modules/mol/base/src/residue_base.cc index a1d321dee00bf9a43b1a92634d88897099831ba7..7d15ad5f6fff00b62a223b8f41417f25d0703d8d 100644 --- a/modules/mol/base/src/residue_base.cc +++ b/modules/mol/base/src/residue_base.cc @@ -44,6 +44,23 @@ const GenericPropContainerImpl* ResidueBase::GpImpl() const return Impl().get(); } +AtomHandle ResidueBase::GetCentralAtom() const +{ + this->CheckValidity(); + return AtomHandle(Impl()->GetCentralAtom()); +} + +void ResidueBase::SetCentralAtom(const AtomHandle& a) +{ + this->CheckValidity(); + impl_->SetCentralAtom(a.Impl()); +} + +geom::Vec3 ResidueBase::GetCentralNormal() const +{ + this->CheckValidity(); + return impl_->GetCentralNormal(); +} const ResNum& ResidueBase::GetNumber() const { this->CheckValidity(); diff --git a/modules/mol/base/src/residue_base.hh b/modules/mol/base/src/residue_base.hh index ea5a5f01081787d3fe6e177894f288cfb8699f99..c994b9a3098b48479300c811d55583cc213ad16c 100644 --- a/modules/mol/base/src/residue_base.hh +++ b/modules/mol/base/src/residue_base.hh @@ -19,6 +19,8 @@ #ifndef OST_RESIDUE_BASE_HH #define OST_RESIDUE_BASE_HH +#include <ost/geom/geom.hh> + #include <ost/mol/module_config.hh> #include <ost/mol/residue_prop.hh> #include <ost/mol/impl/residue_impl_fw.hh> @@ -90,6 +92,20 @@ public: /// residue name and residue number String GetQualifiedName() const; + /// \brief returns main atom, ie CA for amino acids + AtomHandle GetCentralAtom() const; + + /*! + \brief set explicit central atom + + overrides the heuristic of GetCentralAtom to explicitely + use the given one as the central atom; passing in an + invalid handle reverts back to the heurstic determination + */ + void SetCentralAtom(const AtomHandle& a); + + /// \return return specific normal of residue, usually CA-CB dir for AA + geom::Vec3 GetCentralNormal() const; /// \brief whether the residue can form peptide bonds bool IsPeptideLinking() const; diff --git a/modules/mol/base/src/residue_handle.cc b/modules/mol/base/src/residue_handle.cc index 809dbb8c64b9a1d604753e2feaa79174a8f71c96..d2ef00da17cd22fed12270d1dc783e9d8cc5cbe4 100644 --- a/modules/mol/base/src/residue_handle.cc +++ b/modules/mol/base/src/residue_handle.cc @@ -130,18 +130,6 @@ bool ResidueHandle::operator!=(const ResidueHandle& ref) const return Impl()!=ref.Impl(); } -AtomHandle ResidueHandle::GetCentralAtom() const -{ - this->CheckValidity(); - return AtomHandle(Impl()->GetCentralAtom()); -} - -geom::Vec3 ResidueHandle::GetCentralNormal() const -{ - this->CheckValidity(); - return Impl()->GetCentralNormal(); -} - int ResidueHandle::GetIndex() const { this->CheckValidity(); diff --git a/modules/mol/base/src/residue_handle.hh b/modules/mol/base/src/residue_handle.hh index 54b9092a001e34a45aacdfffddf0ac33cc389665..5048a0804c960f535a7213b2a93c2e7324dac241 100644 --- a/modules/mol/base/src/residue_handle.hh +++ b/modules/mol/base/src/residue_handle.hh @@ -61,21 +61,15 @@ public: : ResidueBase(impl) {} EntityHandle GetEntity() const; - /// \brief returns main atom, ie CA for amino acids - AtomHandle GetCentralAtom() const; - - /// \return return specific normal of residue, usually CA-CB dir for AA - geom::Vec3 GetCentralNormal() const; - - /// \brief Get entity's mass + /// \brief Get residue's mass double GetMass() const; - /// \brief Get entity's center of mass (mass weighted) + /// \brief Get residue's center of mass (mass weighted) geom::Vec3 GetCenterOfMass() const; - /// \brief Get entity's center of atoms (not mass weighted) + /// \brief Get residue's center of atoms (not mass weighted) /// - /// Returns the center of all the atoms in an entity. This is + /// Returns the center of all the atoms in this residue. This is /// similar to GetCenterOfMass(), but the atoms are not mass weighted geom::Vec3 GetCenterOfAtoms() const; diff --git a/modules/mol/base/src/residue_view.hh b/modules/mol/base/src/residue_view.hh index 8c95c81c1fe372151a69a17f213ff6c398827072..8efe0c97f8739a5e8c64a1d1f84f3db357e94835 100644 --- a/modules/mol/base/src/residue_view.hh +++ b/modules/mol/base/src/residue_view.hh @@ -155,22 +155,20 @@ public: /// \brief get parent chain view. ChainView GetChain() const; - - /// \brief Get entity's mass + /// \brief Get residue's mass double GetMass() const; - /// \brief Get entity's center of mass (mass weighted) + /// \brief Get residue's center of mass (mass weighted) geom::Vec3 GetCenterOfMass() const; - /// \brief Get entity's center of atoms (not mass weighted) + /// \brief Get residue's center of atoms (not mass weighted) /// - /// Returns the center of all the atoms in an entity. This is + /// Returns the center of all the atoms in this residue. This is /// similar to GetCenterOfMass(), but the atoms are not mass weighted geom::Vec3 GetCenterOfAtoms() const; - /// \brief Get entity's axis-aligned bounding box + /// \brief Get residue's axis-aligned bounding box geom::AlignedCuboid GetBounds() const; - /// \brief return view based on a query object /// \sa Query