diff --git a/modules/mol/alg/pymod/structure_analysis.py b/modules/mol/alg/pymod/structure_analysis.py index 7cbd0dd4b32bb7e6f4093ed23bbbb52a700fc320..1ad301618bc64e8d1673e2c95b1e9d1dd3a208ef 100644 --- a/modules/mol/alg/pymod/structure_analysis.py +++ b/modules/mol/alg/pymod/structure_analysis.py @@ -13,7 +13,7 @@ def GetFrameFromEntity(eh): Input: eh : EntityHandle """ - return ost.mol.CreateCoordFrame(eh.GetAtomPosList()) + return ost.mol.CreateCoordFrame(eh.GetAtomPosList(ordered_by_index=True)) def GetDistanceBetwCenterOfMass(sele1,sele2): """ diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc index bb55d9bd68234616da9d4bf69d646adccf559d71..280024f0a8f513bedd30a83790239446525b9563 100644 --- a/modules/mol/base/pymod/export_entity.cc +++ b/modules/mol/base/pymod/export_entity.cc @@ -155,7 +155,7 @@ void export_Entity() .def("GetMass", &EntityHandle::GetMass) .def("GetCenterOfMass", &EntityHandle::GetCenterOfMass) .def("GetCenterOfAtoms", &EntityHandle::GetCenterOfAtoms) - .def("GetAtomPosList", &EntityHandle::GetAtomPosList) + .def("GetAtomPosList", &EntityHandle::GetAtomPosList, arg("ordered_by_index")=false) .def("GetGeometricCenter", geom_center<EntityHandle>) .add_property("geometric_center", geom_center<EntityHandle>) diff --git a/modules/mol/base/src/entity_handle.cc b/modules/mol/base/src/entity_handle.cc index e34e11d2e233ab4a60da62e20c3e085c4ece1f58..7bf3ed349d82cc621198d17be211f4a3b39b3b1a 100644 --- a/modules/mol/base/src/entity_handle.cc +++ b/modules/mol/base/src/entity_handle.cc @@ -402,16 +402,23 @@ AtomHandleList EntityHandle::GetAtomList() const return atoms; } -geom::Vec3List EntityHandle::GetAtomPosList() const { +bool less_index(const mol::AtomHandle& a1, const mol::AtomHandle& a2) +{ + return a1.GetIndex()<a2.GetIndex(); +} + +geom::Vec3List EntityHandle::GetAtomPosList(bool ordered_by_index) const { this->CheckValidity(); geom::Vec3List atom_pos_list; atom_pos_list.reserve(this->GetAtomCount()); AtomHandleList atom_list=this->GetAtomList(); + if (ordered_by_index){ + std::sort(atom_list.begin(),atom_list.end(),less_index); + } for (AtomHandleList::const_iterator a=atom_list.begin(), e=atom_list.end(); a!=e; ++a) { atom_pos_list.push_back(a->GetPos()); } return atom_pos_list; - //return Impl()->GetAtomPosList(); } EntityHandle EntityHandle::GetHandle() const diff --git a/modules/mol/base/src/entity_handle.hh b/modules/mol/base/src/entity_handle.hh index fe2a439135306d6f2a7c080ed91f1e15604faea0..c2888c9e2efbf790090164c253757dfb24b9553b 100644 --- a/modules/mol/base/src/entity_handle.hh +++ b/modules/mol/base/src/entity_handle.hh @@ -289,7 +289,7 @@ public: AtomHandleList GetAtomList() const; /// \brief get complete list of atom positions - geom::Vec3List GetAtomPosList() const; + geom::Vec3List GetAtomPosList(bool ordered_by_index = false) const; /// \brief Get editor for external coordinate system to manipulate atom /// positions