From 4728655d22c5ef5a47284588921a99687f3d9b1a Mon Sep 17 00:00:00 2001
From: Niklaus Johner <nij2003@med.cornell.edu>
Date: Mon, 9 Jun 2014 17:12:03 -0400
Subject: [PATCH] Added additional argument and flag in the
 RMSD_Matrix_From_Traj function to allow for alignment and RMSD calulation
 from different EntityViews

---
 modules/mol/alg/pymod/trajectory_analysis.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/modules/mol/alg/pymod/trajectory_analysis.py b/modules/mol/alg/pymod/trajectory_analysis.py
index 23c53b5a7..ddd2c4173 100644
--- a/modules/mol/alg/pymod/trajectory_analysis.py
+++ b/modules/mol/alg/pymod/trajectory_analysis.py
@@ -52,7 +52,7 @@ def smooth(vec,n):
 From here on the module needs numpy
 """
 
-def RMSD_Matrix_From_Traj(t,sele,first=0,last=-1):
+def RMSD_Matrix_From_Traj(t,sele,first=0,last=-1,align=True,align_sele=None):
   """
   This function calculates a matrix M such that M[i,j] is the
   RMSD of the EntityView sele between frames i and j of the trajectory t
@@ -64,14 +64,16 @@ def RMSD_Matrix_From_Traj(t,sele,first=0,last=-1):
     last=-1 : the last frame of t to be used
   Returns a numpy NxN matrix, where n is the number of frames.
   """
+  if not align_sele:align_sele=sele
   try:
     import numpy as npy
     if last==-1:last=t.GetFrameCount()
     n_frames=last-first
     rmsd_matrix=npy.identity(n_frames)
     for i in range(n_frames):
-      t=ost.mol.alg.SuperposeFrames(t,sele,begin=first,end=last,ref=i)
-      eh=t.GetEntity()
+      if align:
+        t=ost.mol.alg.SuperposeFrames(t,align_sele,begin=first,end=last,ref=i)
+        eh=t.GetEntity()
       t.CopyFrame(i)
       rmsd_matrix[i,:]=ost.mol.alg.AnalyzeRMSD(t,sele,sele)
       if i==0:
-- 
GitLab