From 378d6c4f0379358d6ccc9c9519dadb2d045aed99 Mon Sep 17 00:00:00 2001 From: Niklaus Johner <nij2003@med.cornell.edu> Date: Fri, 18 May 2012 17:14:27 -0400 Subject: [PATCH] Added a function to fit a cylinder to a selection on the CoordFrame level --- modules/mol/base/pymod/export_coord_frame.cc | 3 ++- modules/mol/base/src/coord_frame.cc | 12 +++++++++++- modules/mol/base/src/coord_frame.hh | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/mol/base/pymod/export_coord_frame.cc b/modules/mol/base/pymod/export_coord_frame.cc index e4c02c926..1f417064d 100644 --- a/modules/mol/base/pymod/export_coord_frame.cc +++ b/modules/mol/base/pymod/export_coord_frame.cc @@ -41,7 +41,7 @@ Real (CoordFrame::*get_alpha)(const mol::EntityView& segment) = &CoordFrame::Get geom::Line3 (CoordFrame::*get_odr_line)(const mol::EntityView& view1) = &CoordFrame::GetODRLine; geom::Line3 (CoordFrame::*get_odr_line2)() = &geom::Vec3List::GetODRLine; geom::Plane (CoordFrame::*get_odr_plane)(const mol::EntityView& view1) = &CoordFrame::GetODRPlane; - +geom::Line3 (CoordFrame::*fit_cylinder)(const mol::EntityView& view1) = &CoordFrame::FitCylinder; void export_CoordFrame() { @@ -61,6 +61,7 @@ void export_CoordFrame() .def("GetODRLine",get_odr_line) .def("GetODRLine",get_odr_line2) .def("GetAlphaHelixContent",get_alpha) + .def("FitCylinder",fit_cylinder) ; def("CreateCoordFrame",CreateCoordFrame); } diff --git a/modules/mol/base/src/coord_frame.cc b/modules/mol/base/src/coord_frame.cc index 5e2e7812b..71b9ed9a6 100644 --- a/modules/mol/base/src/coord_frame.cc +++ b/modules/mol/base/src/coord_frame.cc @@ -325,7 +325,17 @@ namespace ost { namespace mol { center/=atoms_pos_list.size(); return atoms_pos_list.FitCylinder(initial_axis,center); } - + + geom::Line3 CoordFrame::FitCylinder(const mol::EntityView& view1){ + // Return a lin which is the axis of the best fit cylinder to the CA atoms + // of the EntityView. + // It is assumed that we fit an alpha-helix and that the CA atoms are oredered sequentially + CheckHandleValidity(view1); + std::vector<unsigned long> indices_ca; + GetCaIndices(view1, indices_ca); + return CoordFrame::FitCylinder(indices_ca); + } + Real CoordFrame::GetAlphaHelixContent(const mol::EntityView& segment){ //Returns the percentage of residues in the EntityView (segment) that are in an alpha-helix //Each residue is assigned as being in an alpha-helix or not, based on and backbone torsion angles diff --git a/modules/mol/base/src/coord_frame.hh b/modules/mol/base/src/coord_frame.hh index 5458f4cef..98eb0c25c 100644 --- a/modules/mol/base/src/coord_frame.hh +++ b/modules/mol/base/src/coord_frame.hh @@ -78,6 +78,7 @@ public: geom::Line3 GetODRLine(const mol::EntityView& view1); geom::Plane GetODRPlane(const mol::EntityView& view1); geom::Line3 FitCylinder(std::vector<unsigned long>& indices_ca); + geom::Line3 FitCylinder(const mol::EntityView& view1); Real GetAlphaHelixContent(std::vector<unsigned long>& indices_ca, std::vector<unsigned long>& indices_c, std::vector<unsigned long>& indices_o, std::vector<unsigned long>& indices_n); Real GetAlphaHelixContent(const mol::EntityView& segment); -- GitLab