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

In the PariwiseDistanceMatrix function, added support for passing

only one EntityView, and computing the lower triangular part of the
pairwise distance matrix in that case.

Added function to extract the matrix of pairwise distances
    between the atoms in two different views
parent b5cbaa22
Branches
Tags
No related merge requests found
......@@ -24,6 +24,9 @@ using namespace boost::python;
using namespace ost;
using namespace ost::mol::alg;
std::vector< std::vector<Real> > (*pair_dist1)(const mol::EntityView&) = PariwiseDistanceMatrix;
std::vector< std::vector<Real> > (*pair_dist2)(const mol::EntityView&,const mol::EntityView&) = PariwiseDistanceMatrix;
void export_StructureAnalysis()
{
def("GetPosListFromView",&GetPosListFromView, (arg("view")));
......@@ -32,5 +35,8 @@ void export_StructureAnalysis()
def("CalculateAgreementWithDensityMap",&CalculateAgreementWithDensityMap,(arg("pos_list"),arg("density_map")));
#endif
def("WrapEntityInPeriodicCell",&WrapEntityInPeriodicCell,(arg("Entity"),arg("cell_center"),arg("ucell_size"),arg("ucell_angles")=geom::Vec3(),arg("group_res")=true));
def("PariwiseDistanceMatrix",&PariwiseDistanceMatrix,(arg("EntityView1"),arg("EntityView2")));
def("PariwiseDistanceMatrix",pair_dist2,(arg("EntityView1"),arg("EntityView2")));
def("PariwiseDistanceMatrix",pair_dist1,(arg("EntityView")));
}
......@@ -60,7 +60,7 @@ Real CalculateAverageAgreementWithDensityMap(const geom::Vec3List& vl, img::MapH
return sum/float(vl.size());
}
std::vector< std::vector<Real> > PariwiseDistanceMatrix(const EntityView view1, const EntityView view2){
std::vector< std::vector<Real> > PariwiseDistanceMatrix(const EntityView& view1, const EntityView& view2){
std::vector< std::vector<Real> > dist_mat;
unsigned int n1=view1.GetAtomCount(),n2=view2.GetAtomCount();
dist_mat.resize(n1,std::vector<Real>(n2,0));
......@@ -73,6 +73,21 @@ std::vector< std::vector<Real> > PariwiseDistanceMatrix(const EntityView view1,
return dist_mat;
}
std::vector< std::vector<Real> > PariwiseDistanceMatrix(const EntityView& view){
std::vector< std::vector<Real> > dist_mat;
unsigned int n=view.GetAtomCount();
//dist_mat.resize(n,std::vector<Real>(n,0));
AtomViewList atoms1=view.GetAtomList(),atoms2=view.GetAtomList();
for (unsigned int i=0; i!=n; ++i){
dist_mat.push_back(std::vector<Real>(n-i-1,0));
for (unsigned int j=i+1; j!=n; ++j) {
dist_mat[i][j-i-1]=geom::Distance(atoms1[i].GetPos(),atoms2[j].GetPos());
}
}
return dist_mat;
}
#endif
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){
......
......@@ -38,6 +38,7 @@ namespace ost { namespace mol { namespace alg {
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 ucell_size, const geom::Vec3 ucell_angles=geom::Vec3(), bool group_res=true);
std::vector< std::vector<Real> > DLLEXPORT_OST_MOL_ALG PariwiseDistanceMatrix(const EntityView view1, const EntityView view2);
std::vector< std::vector<Real> > DLLEXPORT_OST_MOL_ALG PariwiseDistanceMatrix(const EntityView& view1, const EntityView& view2);
std::vector< std::vector<Real> > DLLEXPORT_OST_MOL_ALG PariwiseDistanceMatrix(const EntityView& view);
}}}//ns
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment