diff --git a/modules/mol/alg/pymod/export_structure_analysis.cc b/modules/mol/alg/pymod/export_structure_analysis.cc
index 707006e3bd69930a098cc10d5918922d2cb33ebd..2a84fe0272a1ce30b5045b579438e2b250b5057b 100644
--- a/modules/mol/alg/pymod/export_structure_analysis.cc
+++ b/modules/mol/alg/pymod/export_structure_analysis.cc
@@ -32,4 +32,5 @@ 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")));
 }
diff --git a/modules/mol/alg/src/structure_analysis.cc b/modules/mol/alg/src/structure_analysis.cc
index 98d43333906192bc63526ca27797b4b359236999..b8c6f10baa4591108502847d617d285ea6648c3f 100644
--- a/modules/mol/alg/src/structure_analysis.cc
+++ b/modules/mol/alg/src/structure_analysis.cc
@@ -59,6 +59,19 @@ 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> > dist_mat;
+  unsigned int n1=view1.GetAtomCount(),n2=view2.GetAtomCount();
+  dist_mat.resize(n1,std::vector<Real>(n2,0));
+  AtomViewList atoms1=view1.GetAtomList(),atoms2=view2.GetAtomList();
+  for (unsigned int i=0; i!=n1; ++i){
+    for (unsigned int j=0; j!=n2; ++j) {
+      dist_mat[i][j]=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, \
diff --git a/modules/mol/alg/src/structure_analysis.hh b/modules/mol/alg/src/structure_analysis.hh
index bafd708879a9a63992ee0f3f687cb76884e0b035..f7cb48540e14e818f3d675604fbe60f3cd88ea59 100644
--- a/modules/mol/alg/src/structure_analysis.hh
+++ b/modules/mol/alg/src/structure_analysis.hh
@@ -38,5 +38,6 @@ 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);
 }}}//ns
 #endif