From 5a553966f474582642caa2ff2ee95da35aad4d46 Mon Sep 17 00:00:00 2001 From: Niklaus Johner <nij2003@med.cornell.edu> Date: Mon, 5 Nov 2012 17:29:01 -0500 Subject: [PATCH] Correct wrapping for the cases when residues are not whole but split by the PBC The residues first get wrapped and then the entity. The wrapping is per residue and each residue gets wrapped according to the position of its center of mass --- modules/mol/alg/pymod/export_structure_analysis.cc | 2 +- modules/mol/alg/src/structure_analysis.cc | 13 +++++++++++-- modules/mol/alg/src/structure_analysis.hh | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/mol/alg/pymod/export_structure_analysis.cc b/modules/mol/alg/pymod/export_structure_analysis.cc index 85fbc230d..f9f58347d 100644 --- a/modules/mol/alg/pymod/export_structure_analysis.cc +++ b/modules/mol/alg/pymod/export_structure_analysis.cc @@ -31,5 +31,5 @@ void export_StructureAnalysis() def("CalculateAverageAgreementWithDensityMap",&CalculateAverageAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); #endif - def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec"))); + def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("basis_vec"),arg("group_res")=true)); } diff --git a/modules/mol/alg/src/structure_analysis.cc b/modules/mol/alg/src/structure_analysis.cc index 50689dfca..de7a176b1 100644 --- a/modules/mol/alg/src/structure_analysis.cc +++ b/modules/mol/alg/src/structure_analysis.cc @@ -61,12 +61,21 @@ Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapH } #endif -void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec){ +void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec, bool group_residues){ mol::XCSEditor edi=eh.EditXCS(mol::BUFFERED_EDIT); geom::Vec3 cm,wrapped_cm,shift; - edi=eh.EditXCS(); ResidueHandleList residues=eh.GetResidueList(); unsigned int n_residues=eh.GetResidueCount(); + if (group_residues) { + for (unsigned int i=0; i<n_residues; ++i) { + ResidueHandle r=residues[i]; + AtomHandleList atoms=r.GetAtomList(); + geom::Vec3 ref_pos=atoms[0].GetPos(); + for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) { + edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),ref_pos,basis_vec)); + } + } + } for (unsigned int i=0; i<n_residues; ++i) { ResidueHandle r=residues[i]; cm=r.GetCenterOfMass(); diff --git a/modules/mol/alg/src/structure_analysis.hh b/modules/mol/alg/src/structure_analysis.hh index 45cb601f8..7ad8ad575 100644 --- a/modules/mol/alg/src/structure_analysis.hh +++ b/modules/mol/alg/src/structure_analysis.hh @@ -37,6 +37,6 @@ namespace ost { namespace mol { namespace alg { std::vector<Real> DLLEXPORT_OST_MOL_ALG CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map); Real DLLEXPORT_OST_MOL_ALG CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map); #endif - void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec); + void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec, bool group_res=true); }}}//ns #endif -- GitLab