diff --git a/modules/mol/alg/pymod/structure_analysis.py b/modules/mol/alg/pymod/structure_analysis.py index 4b575466bbb79138bfdecfb73d63d535d1873a7c..662ed914da1da9c0655631133c19c7fcfe91e50e 100644 --- a/modules/mol/alg/pymod/structure_analysis.py +++ b/modules/mol/alg/pymod/structure_analysis.py @@ -15,3 +15,72 @@ def GetFrameFromEntity(eh): """ return ost.mol.CreateCoordFrame(eh.GetAtomPosList()) +def GetDistanceBetwCenterOfMass(sele1,sele2): + """ + This function calculates the distance between the centers of mass + of sele1 and sele2, two selections from the same Entity. + Input: + sele1 : EntityView + sele2 : EntityView + """ + if not sele1.IsValid() and sele2.IsValid(): + print 'invalid view' + return + eh=sele1.GetHandle() + if not eh==sele2.GetHandle(): + print 'The two views must be from the same entity' + return + f=GetFrameFromEntity(eh) + return f.GetDistanceBetwCenterOfMass(sele1,sele2) + +def GetMinDistanceBetweenViews(sele1,sele2): + """ + This function calculates the minimal distance between + sele1 and sele2, two selections from the same Entity. + Input: + sele1 : EntityView + sele2 : EntityView + """ + if not sele1.IsValid() and sele2.IsValid(): + print 'invalid view' + return + eh=sele1.GetHandle() + if not eh==sele2.GetHandle(): + print 'The two views must be from the same entity' + return + f=GetFrameFromEntity(eh) + return f.GetMinDistance(sele1,sele2) + +def GetMinDistBetwCenterOfMassAndView(sele1,sele2): + """ + This function calculates the minimal distance between sele2 and + the center of mass of sele1, two selections from the same Entity. + Input: + sele1 : EntityView from which the center of mass is taken + sele2 : EntityView + """ + if not sele1.IsValid() and sele2.IsValid(): + print 'invalid view' + return + eh=sele1.GetHandle() + if not eh==sele2.GetHandle(): + print 'The two views must be from the same entity' + return + f=GetFrameFromEntity(eh) + return f.GetMinDistBetwCenterOfMassAndView(sele1,sele2) + + +def GetAlphaHelixContent(sele1): + """ + This function calculates the content of alpha helix in a view. + All residues in the view have to ordered and adjacent (no gaps allowed) + Input: + sele1 : EntityView + """ + if not sele1.IsValid(): + print 'invalid view' + return + eh=sele1.GetHandle() + f=GetFrameFromEntity(eh) + return f.GetAlphaHelixContent(sele1) + diff --git a/modules/mol/base/pymod/export_coord_frame.cc b/modules/mol/base/pymod/export_coord_frame.cc index 3f760c65c78491c75001a6348d7c246c2a4c733d..93f80a7e7fb83594bc3aba2a9d67ba1e2145e2cf 100644 --- a/modules/mol/base/pymod/export_coord_frame.cc +++ b/modules/mol/base/pymod/export_coord_frame.cc @@ -34,6 +34,7 @@ Real (CoordFrame::*get_angle)(const AtomHandle& a1, const AtomHandle& a2, const Real (CoordFrame::*get_dihedral)(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3, const AtomHandle& a4) = &CoordFrame::GetDihedralAngle; geom::Vec3 (CoordFrame::*get_cm)(const mol::EntityView& sele) = &CoordFrame::GetCenterOfMassPos; Real (CoordFrame::*get_dist_cm)(const mol::EntityView& sele1, const mol::EntityView& sele2) = &CoordFrame::GetDistanceBetwCenterOfMass; +Real (CoordFrame::*get_min_dist_cm_v)(const mol::EntityView& sele1, const mol::EntityView& sele2) = &CoordFrame::GetMinDistBetwCenterOfMassAndView; Real (CoordFrame::*get_rmsd)(const mol::EntityView& Reference_View, const mol::EntityView& sele_View) = &CoordFrame::GetRMSD; Real (CoordFrame::*get_min_dist)(const mol::EntityView& view1, const mol::EntityView& view2) = &CoordFrame::GetMinDistance; Real (CoordFrame::*get_alpha)(const mol::EntityView& segment) = &CoordFrame::GetAlphaHelixContent; @@ -49,6 +50,7 @@ void export_CoordFrame() .def("GetDihedralAngle", get_dihedral) .def("GetCenterOfMassPos", get_cm) .def("GetDistanceBetwCenterOfMass", get_dist_cm) + .def("GetMinDistBetwCenterOfMassAndView", get_min_dist_cm_v) .def("GetRMSD",get_rmsd) .def("GetMinDistance",get_min_dist) .def("GetODRLine",&geom::Vec3List::GetODRLine)