Skip to content
Snippets Groups Projects
Commit 9060e0fc authored by Niklaus Johner's avatar Niklaus Johner
Browse files

Added support for non-orthogonal cells for the WrapEntityInPeriodicCell function.

parent 211af9d1
Branches
Tags
No related merge requests found
...@@ -31,5 +31,5 @@ void export_StructureAnalysis() ...@@ -31,5 +31,5 @@ void export_StructureAnalysis()
def("CalculateAverageAgreementWithDensityMap",&CalculateAverageAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); def("CalculateAverageAgreementWithDensityMap",&CalculateAverageAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map"))); def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
#endif #endif
def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("basis_vec"),arg("group_res")=true)); def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("ucell_size"),arg("ucell_angles")=geom::Vec3(),arg("group_res")=true));
} }
...@@ -61,8 +61,12 @@ Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapH ...@@ -61,8 +61,12 @@ Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapH
} }
#endif #endif
void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec, bool group_residues){ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 ucell_size, \
const geom::Vec3 ucell_angles, bool group_residues){
mol::XCSEditor edi=eh.EditXCS(mol::BUFFERED_EDIT); mol::XCSEditor edi=eh.EditXCS(mol::BUFFERED_EDIT);
bool orthogonal;
if (ucell_angles==geom::Vec3()){ orthogonal=true; }
else { orthogonal=false; }
if (group_residues) { if (group_residues) {
geom::Vec3 cm,wrapped_cm,shift; geom::Vec3 cm,wrapped_cm,shift;
ResidueHandleList residues=eh.GetResidueList(); ResidueHandleList residues=eh.GetResidueList();
...@@ -71,14 +75,20 @@ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom: ...@@ -71,14 +75,20 @@ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom:
ResidueHandle r=residues[i]; ResidueHandle r=residues[i];
AtomHandleList atoms=r.GetAtomList(); AtomHandleList atoms=r.GetAtomList();
geom::Vec3 ref_pos=atoms[0].GetPos(); geom::Vec3 ref_pos=atoms[0].GetPos();
for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) { if (orthogonal) {
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),ref_pos,basis_vec)); for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) {
} edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),ref_pos,ucell_size));
}}
else {
for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) {
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),ref_pos,ucell_size,ucell_angles));
}}
} }
for (unsigned int i=0; i<n_residues; ++i) { for (unsigned int i=0; i<n_residues; ++i) {
ResidueHandle r=residues[i]; ResidueHandle r=residues[i];
cm=r.GetCenterOfMass(); cm=r.GetCenterOfMass();
wrapped_cm=geom::WrapVec3(cm,cell_center,basis_vec); if (orthogonal) {wrapped_cm=geom::WrapVec3(cm,cell_center,ucell_size);}
else {wrapped_cm=geom::WrapVec3(cm,cell_center,ucell_size,ucell_angles);}
if (wrapped_cm==cm) continue; if (wrapped_cm==cm) continue;
AtomHandleList atoms=r.GetAtomList(); AtomHandleList atoms=r.GetAtomList();
unsigned int n_atoms=r.GetAtomCount(); unsigned int n_atoms=r.GetAtomCount();
...@@ -90,9 +100,14 @@ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom: ...@@ -90,9 +100,14 @@ void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom:
} }
else { else {
AtomHandleList atoms=eh.GetAtomList(); AtomHandleList atoms=eh.GetAtomList();
for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) { if (orthogonal){
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),cell_center,basis_vec)); for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) {
} edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),cell_center,ucell_size));
}}
else {
for (AtomHandleList::iterator a=atoms.begin(), e=atoms.end(); a!=e; ++a) {
edi.SetAtomPos((*a),geom::WrapVec3((*a).GetPos(),cell_center,ucell_size,ucell_angles));
}}
} }
} }
......
...@@ -37,6 +37,6 @@ namespace ost { namespace mol { namespace alg { ...@@ -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); 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); Real DLLEXPORT_OST_MOL_ALG CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map);
#endif #endif
void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 basis_vec, bool group_res=true); void DLLEXPORT_OST_MOL_ALG WrapEntityInPeriodicCell(EntityHandle eh, const geom::Vec3 cell_center, const geom::Vec3 ucell_size, const geom::Vec3 ucell_angles=geom::Vec3(), bool group_res=true);
}}}//ns }}}//ns
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment