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

Added a function to calculate an Average Distance Matrix

from a trajectory for an EntityView, i.e. the matrix of
pairwise average distances.
parent 3a3b9263
Branches
Tags
No related merge requests found
...@@ -196,4 +196,20 @@ def DistRMSDFromTraj(t,sele,ref_sele,radius=7.0,average=False,seq_sep=4,first=0, ...@@ -196,4 +196,20 @@ def DistRMSDFromTraj(t,sele,ref_sele,radius=7.0,average=False,seq_sep=4,first=0,
LogError("Function needs numpy, but I could not import it.") LogError("Function needs numpy, but I could not import it.")
raise raise
def AverageDistanceMatrixFromTraj(t,sele,first=0,last=-1):
try:
import numpy as npy
except ImportError:
LogError("Function needs numpy, but I could not import it.")
raise
n_atoms=sele.GetAtomCount()
M=npy.zeros([n_atoms,n_atoms])
for i,a1 in enumerate(sele.atoms):
for j,a2 in enumerate(sele.atoms):
d=ost.mol.alg.AnalyzeDistanceBetwAtoms(t,a1.GetHandle(),a2.GetHandle())[first:last]
M[i,j]=npy.mean(d)
M[j,i]=npy.mean(d)
return M
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment