Package AutoDockTools :: Package Utilities24 :: Module summarize_time
[hide private]
[frames] | no frames]

Source Code for Module AutoDockTools.Utilities24.summarize_time

 1  #!/usr/bin/env python2.4 
 2  # 
 3  #  
 4  # 
 5  # $Header: /opt/cvs/python/packages/share1.5/AutoDockTools/Utilities24/summarize_time.py,v 1.1 2007/01/09 19:05:20 rhuey Exp $ 
 6  # 
 7  import os, glob, Numeric 
 8  from AutoDockTools.DlgParser import DlgParser 
 9   
10   
11  if __name__ == '__main__': 
12      import sys 
13      import getopt 
14   
15   
16 - def usage():
17 "Print helpful, accurate usage statement to stdout." 18 print "Usage: summarize_time.py -d directory" 19 print 20 print " Description of command..." 21 print " -d directory" 22 print " Optional parameters:" 23 print " [-o] output filename" 24 print " (default is 'summary_of_time')" 25 print " [-v] verbose output"
26 27 28 # process command arguments 29 try: 30 opt_list, args = getopt.getopt(sys.argv[1:], 'd:o:vh') 31 except getopt.GetoptError, msg: 32 print 'summarize_time.py: %s' %msg 33 usage() 34 sys.exit(2) 35 36 # initialize required parameters 37 #-d: directory 38 directory = None 39 40 # optional parameters 41 #-o outputfilename 42 outputfilename = "summary_of_time.txt" 43 #-v: verbose 44 verbose = None 45 #-h: help 46 help = None 47 48 49 #'d:o:vh' 50 for o, a in opt_list: 51 #print "o=", o, " a=", a 52 if o in ('-d', '--d'): 53 directory = a 54 if verbose: print 'set directory to ', a 55 if o in ('-o', '--o'): 56 outputfilename = a 57 if verbose: print 'set outputfilename to ', a 58 if o in ('-v', '--v'): 59 verbose = True 60 if verbose: print 'set verbose to ', True 61 if o in ('-h', '--'): 62 usage() 63 sys.exit() 64 65 if not directory: 66 print 'summarize_time: directory must be specified.' 67 usage() 68 sys.exit() 69 70 p = DlgParser() 71 dlg_list = glob.glob(directory + '/*.dlg') 72 for dlg in dlg_list: 73 p.parse(dlg) 74 stem = dlg_list[0].split('.')[0] 75 ostr = '%s: % 12.4f m \n' %(directory, p.total_time) 76 fptr = open(outputfilename, 'a') 77 fptr.write(ostr) 78 fptr.close() 79 80 # To execute this command type: 81 # summarize_time.py -d directory -o outputfilename -v 82