diff --git a/modules/mol/alg/pymod/export_structure_analysis.cc b/modules/mol/alg/pymod/export_structure_analysis.cc index c4df71e3f788e6ce659bcd517db0fb38bcee3652..dc60e67b9395e464eec5e32d1a92584c0d6cf229 100644 --- a/modules/mol/alg/pymod/export_structure_analysis.cc +++ b/modules/mol/alg/pymod/export_structure_analysis.cc @@ -28,4 +28,5 @@ void export_StructureAnalysis() { def("GetPosListFromView",&GetPosListFromView, (arg("view"))); def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); -} + def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec"))); +} \ No newline at end of file diff --git a/modules/mol/alg/src/structure_analysis.cc b/modules/mol/alg/src/structure_analysis.cc index a590cf0e4f3af1cdde117353aebe11a112519bb8..bef3588e331fd94757de0eb362262721dba1c7ec 100644 --- a/modules/mol/alg/src/structure_analysis.cc +++ b/modules/mol/alg/src/structure_analysis.cc @@ -50,5 +50,25 @@ Real CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& } return sum; } - + +void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec){ + 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(); + for (unsigned int i=0; i<n_residues; ++i) { + ResidueHandle r=residues[i]; + cm=r.GetCenterOfMass(); + wrapped_cm=geom::WrapVec3(cm,cell_center,basis_vec); + if (wrapped_cm==cm) continue; + AtomHandleList atoms=r.GetAtomList(); + unsigned int n_atoms=r.GetAtomCount(); + shift=wrapped_cm-cm; + for (unsigned int j=0; j<n_atoms; ++j) { + edi.SetAtomPos(atoms[j],atoms[j].GetPos()+shift); + } + } +} + }}} //ns diff --git a/modules/mol/alg/src/structure_analysis.hh b/modules/mol/alg/src/structure_analysis.hh index aa9e720414d2884103499d33bf661939261a8e42..c3f1f8596a515593c7a92bd6b3e2ca48b7a6c9bd 100644 --- a/modules/mol/alg/src/structure_analysis.hh +++ b/modules/mol/alg/src/structure_analysis.hh @@ -26,11 +26,13 @@ #include <ost/mol/alg/module_config.hh> #include <ost/mol/entity_view.hh> +#include <ost/mol/entity_handle.hh> #include <ost/img/map.hh> namespace ost { namespace mol { namespace alg { geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view); Real DLLEXPORT_OST_MOL_ALG CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map); + void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec); }}}//ns #endif