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

Source Code for Module Biskit.QualMaster

  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  ## 
 21  ## last $Author: leckner $ 
 22  ## last $Date: 2006/12/21 09:33:09 $ 
 23  ## $Revision: 1.5 $ 
 24   
 25  """ 
 26  Parallizes calculation and plotting of ensemble trajectory RMSDs 
 27  """ 
 28   
 29  from Biskit.hosts import cpus_all, nice_dic, nodes_all 
 30  import Biskit.tools as T 
 31  ## from Biskit.PVM.TrackingJobMaster import TrackingJobMaster 
 32  from Biskit.PVM import TrackingJobMaster 
 33   
 34   
35 -class QualMaster(TrackingJobMaster):
36
37 - def __init__(self, trajFiles, n_hosts=20, **kw):
38 """ 39 @param trajFiles: list of trajectory filed 40 @type trajFiles: [ str ] 41 @param n_hosts: number of hosts to use 42 @type n_hosts: int 43 """ 44 dat = {} 45 i = 0 46 for f in trajFiles: 47 dat[i] = T.absfile( f ) 48 i += 1 49 50 niceness = nice_dic 51 hosts = nodes_all[ :n_hosts ] 52 53 slave_script = T.projectRoot() +'/Biskit/QualSlave.py' 54 55 TrackingJobMaster.__init__(self, dat, 1, hosts, niceness, 56 slave_script, **kw)
57 58
59 - def getInitParameters(self, slave_tid):
60 """ 61 hand over parameters to slave once. 62 63 @param slave_tid: slave task id 64 @type slave_tid: int 65 66 @return: dictionary with init parameters 67 @rtype: {param:value} 68 """ 69 return 1
70 71
72 - def done(self):
73 self.exit()
74 75 76 ############# 77 ## TESTING 78 ############# 79
80 -class Test:
81 """ 82 Test class 83 """ 84
85 - def run( self, local=0 ):
86 """ 87 run function test 88 89 @param local: transfer local variables to global and perform 90 other tasks only when run locally 91 @type local: 1|0 92 93 @return: 1 94 @rtype: int 95 """ 96 import os.path 97 98 ## a minimal list of trajectories 99 traj_list = [ T.testRoot() + '/lig_pcr_00/traj.dat' ] 100 101 master = QualMaster( traj_list, 102 show_output=local, 103 verbose=local ) 104 105 ## run and wait for result 106 r = master.calculateResult() 107 #master.start() 108 109 f_plot = '%s/rms_traj.eps'%os.path.dirname(r[0]) 110 111 if local: 112 print 'A RMSD plot is writen to: %s'%f_plot 113 globals().update( locals() ) 114 115 ## cleanup 116 T.tryRemove( f_plot ) 117 118 return 1
119 120
121 - def expected_result( self ):
122 """ 123 Precalculated result to check for consistent performance. 124 125 @return: 1 126 @rtype: int 127 """ 128 return 1
129 130 131 if __name__ == '__main__': 132 133 test = Test() 134 135 assert test.run( local=1 ) == test.expected_result() 136