#NEWLINE# def main( ) : #NEWLINE# #INDENT# usage = 'usage: %prog [options]' #NEWLINE# description = 'Script to analyze C. elegans histone marks data matrix.' #NEWLINE# optparser = OptionParser ( version = '%prog 0.1' , description = description , usage = usage , add_help_option = False ) #NEWLINE# optparser . add_option ( '-h' , '--help' , action = 'help' , help = 'Show this help message and exit.' ) #NEWLINE# optparser . add_option ( '-i' , '--ifile' , dest = 'ifile' , type = 'string' , help = 'input file' ) #NEWLINE# optparser . add_option ( '-o' , '--ofile' , dest = 'ofile' , help = 'output file, default: stdout' ) #NEWLINE# ( options , args ) = optparser . parse_args ( ) #NEWLINE# command_list = { #NEWLINE# #INDENT# 'summary' : summary , #NEWLINE# 'organize' : organize , #NEWLINE# 'call1' : call1 , #NEWLINE# 'drawchrom' : drawchrom , #NEWLINE# 'call1draw' : call1draw , #NEWLINE# 'combcall2draw' : combcall2draw , #NEWLINE# #UNINDENT# } #NEWLINE# command_des = { #NEWLINE# #INDENT# 'summary' : 'Show the column names.' , #NEWLINE# 'organize' : 'Re-organize the file for data-mining.' , #NEWLINE# 'call1' : 'Call enriched regions for certain column.' , #NEWLINE# 'drawchrom' : 'Draw ce chromosomes.' , #NEWLINE# 'call1draw' : 'Call enriched regions and then draw chromosome figures.' , #NEWLINE# 'combcall2draw' : 'Call enriched regions where any of the tracks is above threshold and draw them on chromosome figures.' , #NEWLINE# #UNINDENT# } #NEWLINE# if ( ( not options . ifile ) or ( not args ) ) : #NEWLINE# #INDENT# optparser . print_help ( ) #NEWLINE# sys . exit ( ) #NEWLINE# #UNINDENT# if options . ofile : #NEWLINE# #INDENT# write_func = open ( options . ofile , 'w' ) . write #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# write_func = sys . stdout . write #NEWLINE# #UNINDENT# if command_list . has_key ( args [ 0 ] ) : #NEWLINE# #INDENT# com = command_list [ args [ 0 ] ] #NEWLINE# com_args = args [ 1 : ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# optparser . print_help ( ) #NEWLINE# sys . stderr . write ( 'Avialable Commands:\n\n' ) #NEWLINE# for c in command_list . keys ( ) : #NEWLINE# #INDENT# sys . stderr . write ( ( ( ( c + ': ' ) + com [ c ] ) + '\n' ) ) #NEWLINE# #UNINDENT# sys . exit ( ) #NEWLINE# #UNINDENT# cvsfilereader = csv . DictReader ( open ( options . ifile , 'r' ) , delimiter = '\t' ) #NEWLINE# com ( cvsfilereader , write_func , com_args )