Package Biskit :: Module QualSlave
[hide private]
[frames] | no frames]

Source Code for Module Biskit.QualSlave

  1  ## 
  2  ## Biskit, a toolkit for the manipulation of macromolecular structures 
  3  ## Copyright (C) 2004-2005 Raik Gruenberg & Johan Leckner 
  4  ## 
  5  ## This program is free software; you can redistribute it and/or 
  6  ## modify it under the terms of the GNU General Public License as 
  7  ## published by the Free Software Foundation; either version 2 of the 
  8  ## License, or any later version. 
  9  ## 
 10  ## This program is distributed in the hope that it will be useful, 
 11  ## but WITHOUT ANY WARRANTY; without even the implied warranty of 
 12  ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 13  ## General Public License for more details. 
 14  ## 
 15  ## You find a copy of the GNU General Public License in the file 
 16  ## license.txt along with this program; if not, write to the Free 
 17  ## Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 18  ## 
 19  ## 
 20  ## $Revision: 2.3 $ 
 21  ## last $Date: 2006/12/22 14:27:30 $ 
 22  ## last $Author: graik $ 
 23   
 24  """ 
 25  Plot RMSD, Energy of ensemble trajectory. 
 26  """ 
 27       
 28  from os.path import dirname 
 29   
 30  import tools as T 
 31  from Biskit import Trajectory, EHandler 
 32  from Biskit.EnsembleTraj import traj2ensemble, EnsembleTraj 
 33   
 34  from PVM import JobSlave 
 35   
36 -class QualSlave(JobSlave):
37 """ 38 Plot RMSD, Energy of ensemble trajectory. 39 """ 40
41 - def initialize(self, params):
42 """ 43 Copy the parameters that Master is passing in as dict into 44 fields of this class. 45 46 @param params: defined in Master 47 @type params: dict 48 """ 49 pass
50 51
52 - def go( self, dict ):
53 """ 54 Calculate rmsd values for trajectory and plot them. 55 56 @param dict: dictionary with path to trajectories as values 57 @type dict: dict 58 59 @return: dictionary with path to trajectories as values 60 @rtype: dict 61 """ 62 for k, f in dict.items(): 63 64 fout = dirname( f )+'/'+'%s'+ T.stripFilename(f)+'.eps' 65 fshort = dirname( f )[-15:] 66 67 print fshort 68 69 t = self.loadTraj( f ) 70 71 self.calcRmsd( t ) 72 73 p = self.plotRmsdRef(t, fshort ) 74 p.write_eps( fout % 'rms_', width="18cm", height="29cm" ) 75 76 print "Done" 77 78 return dict
79 80
81 - def loadTraj( self, ftraj ):
82 """ 83 Load trajectories from disc. 84 85 @param ftraj: path to trajectory 86 @type ftraj: str 87 88 @return: ensemble trajectory object 89 @rtype: EnsembleTraj 90 """ 91 t = T.Load( T.absfile( ftraj ) ) 92 return traj2ensemble( t )
93 94
95 - def calcRmsd( self, t ):
96 """ 97 Calculate the rmsd to the reference, the CA rmsd to the average 98 member and the CA rmsd to last member frame. Add the results 99 into a profile. 100 101 @param t: ensemble trajectory object 102 @type t: EnsembleTraj 103 """ 104 mCA = t.ref.maskCA() 105 106 t.fit( ref=t.ref, prof='rms_all_ref', comment='all heavy') 107 108 t.fitMembers( mask=mCA, prof='rms_CA_av', comment='CA to member avg') 109 110 t.fitMembers( refIndex=-1, mask=mCA, prof='rms_CA_last', 111 comment='all CA to last member frame')
112 113
114 - def plotRmsdRef( self, t, title ):
115 """ 116 Plot the rmsd profiles calculated in L{ calcRmsd }. 117 118 @param t: ensemble trajectory object 119 @type t: EnsembleTraj 120 @param title: plot title 121 @type title: str 122 123 @return: biggles plot object 124 @rtype: biggles.FramedPlot 125 """ 126 p = t.plotMemberProfiles('rms_all_ref', 'rms_CA_av', 'rms_CA_last') 127 p.title = title 128 p.xlabel= 'frame #' 129 p.ylabel= 'RMSD [A]' 130 return p
131 132 133 if __name__ == '__main__': 134 135 import os, sys 136 137 if len(sys.argv) == 2: 138 139 niceness = int(sys.argv[1]) 140 os.nice(niceness) 141 142 slave = QualSlave() 143 slave.start() 144