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

Added a function to calculate a density entity overlap by

calculating for each atom in the entity the value of the density
in its position
parent dcb5cc68
Branches
Tags
No related merge requests found
...@@ -28,5 +28,6 @@ void export_StructureAnalysis() ...@@ -28,5 +28,6 @@ void export_StructureAnalysis()
{ {
def("GetPosListFromView",&GetPosListFromView, (arg("view"))); def("GetPosListFromView",&GetPosListFromView, (arg("view")));
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("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec"))); def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("nasis_vec")));
} }
\ No newline at end of file
...@@ -38,15 +38,24 @@ geom::Vec3List GetPosListFromView(const EntityView& view){ ...@@ -38,15 +38,24 @@ geom::Vec3List GetPosListFromView(const EntityView& view){
} }
return vl; return vl;
} }
Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){ std::vector<Real> CalculateAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){
Real sum,v;
sum=0;
CheckHandleValidity(density_map); CheckHandleValidity(density_map);
std::vector<Real> v;
v.reserve(vl.size());
for (geom::Vec3List::const_iterator v1=vl.begin(),e=vl.end(); v1!=e; ++v1) { for (geom::Vec3List::const_iterator v1=vl.begin(),e=vl.end(); v1!=e; ++v1) {
img::Point p(density_map.CoordToIndex(*v1)); img::Point p(density_map.CoordToIndex(*v1));
v=density_map.GetReal(p); v.push_back(density_map.GetReal(p));
sum=sum+v; }
return v;
}
Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapHandle& density_map){
CheckHandleValidity(density_map);
std::vector<Real> v=CalculateAgreementWithDensityMap(vl, density_map);
Real sum=0.0;
for (std::vector<Real>::const_iterator i=v.begin(),e=v.end(); i!=e; ++i) {
sum=sum+*i;
} }
return sum/float(vl.size()); return sum/float(vl.size());
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
namespace ost { namespace mol { namespace alg { namespace ost { namespace mol { namespace alg {
geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view); geom::Vec3List DLLEXPORT_OST_MOL_ALG GetPosListFromView(const EntityView& view);
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);
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);
}}}//ns }}}//ns
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment