<s> '''<STR_LIT>''' <EOL> import sys <EOL> import math <EOL> import CGAT . Experiment as E <EOL> """<STR_LIT>""" <EOL> doEps = True <EOL> largepvalues = True <EOL> annsize = <NUM_LIT> <EOL> colsize = <NUM_LIT:9> <EOL> colsep = <NUM_LIT:2> <EOL> rowheight = <NUM_LIT:7> <EOL> rowwidth = rowheight <EOL> textangle = <NUM_LIT> <EOL> labelsize = <NUM_LIT> <EOL> maincolsep = <NUM_LIT:15> <EOL> greylines = <NUM_LIT:5> <EOL> maxp = <NUM_LIT:1.0> <EOL> vertical = <NUM_LIT:0> <EOL> maxsize = rowheight - <NUM_LIT:1> <EOL> maxheight = <NUM_LIT> - labelsize - <NUM_LIT:50> <EOL> maxwidth = <NUM_LIT> - labelsize / <NUM_LIT:3> - <NUM_LIT:10> <EOL> if largepvalues : <EOL> pval0 = <NUM_LIT> <EOL> pval1 = <NUM_LIT> <EOL> pval2 = <NUM_LIT> <EOL> pval3 = <NUM_LIT> <EOL> pval4 = <NUM_LIT> <EOL> pval5 = <NUM_LIT> <EOL> else : <EOL> pval0 = <NUM_LIT> <EOL> pval1 = <NUM_LIT> <EOL> pval2 = <NUM_LIT> <EOL> pval3 = <NUM_LIT> <EOL> pval4 = <NUM_LIT:0.1> <EOL> pval5 = <NUM_LIT> <EOL> def posx ( x ) : <EOL> return x * ( colsize + colsep ) + annsize <EOL> def posy ( y ) : <EOL> return ( collen - y ) * rowheight <EOL> def makeheader ( input , annlist , numcols , numpages ) : <EOL> if doEps : <EOL> print "<STR_LIT>" <EOL> else : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" , numpages <EOL> print "<STR_LIT>" , <NUM_LIT:10> , posy ( collen + <NUM_LIT:4> ) + <NUM_LIT> , int ( <NUM_LIT:10> + ( numcols - <NUM_LIT:1> ) * maincolsep + labelsize / <NUM_LIT:3> + ( numcols ) * posx ( len ( input ) ) ) , int ( posy ( <NUM_LIT:0> ) + labelsize ) + <NUM_LIT> <EOL> print """<STR_LIT>""" <EOL> def sameannotation ( ann1 , ann2 ) : <EOL> return ann1 . replace ( '<STR_LIT:+>' , '<STR_LIT>' ) . replace ( '<STR_LIT:->' , '<STR_LIT>' ) == ann2 . replace ( '<STR_LIT:+>' , '<STR_LIT>' ) . replace ( '<STR_LIT:->' , '<STR_LIT>' ) <EOL> def makecolheader ( input , annlist , title = "<STR_LIT>" ) : <EOL> print "<STR_LIT>" , colsize , "<STR_LIT>" <EOL> for i in range ( len ( input ) ) : <EOL> print posx ( i ) , posy ( - <NUM_LIT:1> ) , "<STR_LIT>" , textangle , "<STR_LIT>" <EOL> print "<STR_LIT:(>" , input [ i ] , "<STR_LIT>" <EOL> print "<STR_LIT>" , rowwidth , "<STR_LIT>" , rowheight , "<STR_LIT>" <EOL> if title : <EOL> print "<STR_LIT>" , <NUM_LIT:10> , posy ( - <NUM_LIT:8> ) , "<STR_LIT>" % ( title ) <EOL> for i in range ( len ( annlist ) ) : <EOL> print "<STR_LIT>" , posy ( i ) , "<STR_LIT>" <EOL> print "<STR_LIT>" , annsize - <NUM_LIT:5> , <NUM_LIT:0> , "<STR_LIT>" , <EOL> print annsize - <NUM_LIT:5> , <NUM_LIT:5> + rowheight , "<STR_LIT>" , <NUM_LIT:0> , <NUM_LIT:5> + rowheight , "<STR_LIT>" <EOL> print "<STR_LIT>" , annlist [ i ] , "<STR_LIT>" <EOL> if ( greylines > <NUM_LIT:0> and ( i + <NUM_LIT:1> ) % greylines == <NUM_LIT:0> ) or ( greylines == <NUM_LIT:0> and i < len ( annlist ) - <NUM_LIT:1> and not sameannotation ( annlist [ i ] , annlist [ i + <NUM_LIT:1> ] ) ) : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print <NUM_LIT:0> , posy ( i ) , "<STR_LIT>" <EOL> print "<STR_LIT:(>" , annlist [ i ] , "<STR_LIT>" , annsize , "<STR_LIT>" <EOL> print posx ( len ( input ) ) , posy ( i ) , "<STR_LIT>" <EOL> def makecolor ( color ) : <EOL> if color == <NUM_LIT:0.5> : <EOL> print "<STR_LIT>" <EOL> return <EOL> color = <NUM_LIT:1> - color <EOL> if color > <NUM_LIT:0.5> : <EOL> color = min ( <NUM_LIT:1> , <NUM_LIT:2> * color - <NUM_LIT:1> ) <EOL> col0 = [ <NUM_LIT:0.1> , <NUM_LIT:0> , <NUM_LIT:0.5> ] <EOL> col1 = [ <NUM_LIT:1> , <NUM_LIT:0> , <NUM_LIT:0> ] <EOL> else : <EOL> color = min ( <NUM_LIT:1> , <NUM_LIT:1> - <NUM_LIT:2> * color ) <EOL> col0 = [ <NUM_LIT:0.1> , <NUM_LIT> , <NUM_LIT> ] <EOL> col1 = [ <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT> ] <EOL> print col0 [ <NUM_LIT:0> ] + color * ( col1 [ <NUM_LIT:0> ] - col0 [ <NUM_LIT:0> ] ) , col0 [ <NUM_LIT:1> ] + color * ( col1 [ <NUM_LIT:1> ] - col0 [ <NUM_LIT:1> ] ) , col0 [ <NUM_LIT:2> ] + color * ( col1 [ <NUM_LIT:2> ] - col0 [ <NUM_LIT:2> ] ) <EOL> def makeps ( i , j , element ) : <EOL> ( relrep , experp , pexp , ann ) = element <EOL> xpos = posx ( i ) <EOL> if i == - <NUM_LIT:1> : <EOL> xpos = <NUM_LIT:0> <EOL> logrelrep = math . log ( <NUM_LIT> + ( relrep / <NUM_LIT> ) ) <EOL> color = <NUM_LIT:0.5> + ( logrelrep / math . log ( <NUM_LIT> ) ) / <NUM_LIT:2> <EOL> if experp <= pval0 : <EOL> size = maxsize <EOL> elif experp <= pval1 : <EOL> size = <NUM_LIT> * maxsize <EOL> elif experp <= pval2 : <EOL> size = <NUM_LIT> * maxsize <EOL> elif experp <= pval3 : <EOL> size = <NUM_LIT> * maxsize <EOL> elif experp <= pval4 : <EOL> size = <NUM_LIT> * maxsize <EOL> elif experp <= pval5 : <EOL> size = <NUM_LIT> * maxsize <EOL> else : <EOL> size = <NUM_LIT:0> <EOL> if size > <NUM_LIT:0> : <EOL> print xpos , rowheight / <NUM_LIT> + posy ( j ) , size <EOL> makecolor ( color ) <EOL> print "<STR_LIT>" <EOL> else : <EOL> print xpos , rowheight / <NUM_LIT> + posy ( j ) , <NUM_LIT:1> <EOL> makecolor ( <NUM_LIT:0.5> ) <EOL> print "<STR_LIT>" <EOL> if i == vertical : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print posx ( i ) - colsize / <NUM_LIT:2> , posy ( j ) , "<STR_LIT>" <EOL> print posx ( i ) - colsize / <NUM_LIT:2> , posy ( j + <NUM_LIT:1> ) , "<STR_LIT>" <EOL> def makefooter ( lineno , footer = "<STR_LIT>" ) : <EOL> print "<STR_LIT>" , posy ( lineno ) , "<STR_LIT>" , <NUM_LIT:3> + colsize , "<STR_LIT>" <EOL> print "<STR_LIT>" , colsize , "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval0 , "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval1 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval1 , "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval2 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval2 , "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval3 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval3 , "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval4 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval4 , "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval5 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" , pval5 , "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" , - colsize , "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ <NUM_LIT> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ <NUM_LIT:200> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ <NUM_LIT:100> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ <NUM_LIT:50> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print ( "<STR_LIT>" ) <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print ( "<STR_LIT>" ) <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT:50> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> makeps ( - <NUM_LIT:1> , lineno , [ - <NUM_LIT> , pval0 , <NUM_LIT:0> , <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" <EOL> if footer : <EOL> print "<STR_LIT>" , <NUM_LIT:0> , posy ( lineno + <NUM_LIT:3> ) , "<STR_LIT>" % ( footer ) <EOL> def makepageheader ( page ) : <EOL> print "<STR_LIT>" , page , page <EOL> print "<STR_LIT>" <EOL> def makepagetrailer ( page ) : <EOL> print "<STR_LIT>" <EOL> def collect ( infile , with_headers = False ) : <EOL> """<STR_LIT>""" <EOL> data = [ ] <EOL> lines = filter ( lambda x : x [ <NUM_LIT:0> ] != "<STR_LIT:#>" , infile . readlines ( ) ) <EOL> if len ( lines ) == <NUM_LIT:0> : <EOL> return data <EOL> if with_headers : <EOL> del lines [ <NUM_LIT:0> ] <EOL> for line in lines : <EOL> if line [ <NUM_LIT:0> ] == "<STR_LIT:#>" : <EOL> continue <EOL> try : <EOL> ( code , goid , scount , stotal , spercent , bcount , btotal , bpercent , pover , <EOL> punder , goid , category , description ) = line [ : - <NUM_LIT:1> ] . split ( "<STR_LIT:\t>" ) [ : <NUM_LIT> ] <EOL> except ValueError : <EOL> raise "<STR_LIT>" % line [ : - <NUM_LIT:1> ] <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> if code == "<STR_LIT:+>" : <EOL> p = pover <EOL> else : <EOL> p = punder <EOL> data . append ( ( <NUM_LIT> * ( float ( spercent ) / float ( bpercent ) - <NUM_LIT:1.0> ) , <EOL> abs ( float ( p ) ) , float ( bpercent ) , description ) ) <EOL> return data <EOL> def main ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> if argv is None : <EOL> argv = sys . argv <EOL> parser = E . OptionParser ( <EOL> version = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT:title>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT:-c>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( <EOL> sortAlphabetically = True , <EOL> headers = False , <EOL> titles = "<STR_LIT>" , <EOL> pattern_filename = None , <EOL> title = "<STR_LIT>" , <EOL> footer = "<STR_LIT>" , <EOL> ) <EOL> ( options , args ) = E . Start ( parser , add_pipe_options = True ) <EOL> if len ( args ) == <NUM_LIT:0> : <EOL> raise "<STR_LIT>" <EOL> if options . pattern_filename : <EOL> input = [ ] <EOL> titles = args <EOL> for x in titles : <EOL> input . append ( options . pattern_filename % x ) <EOL> else : <EOL> input = args <EOL> if options . titles : <EOL> titles = options . titles . split ( "<STR_LIT:U+002C>" ) <EOL> if len ( titles ) != len ( input ) : <EOL> raise "<STR_LIT>" % ( <EOL> len ( titles ) , len ( input ) ) <EOL> else : <EOL> titles = input <EOL> if options . loglevel >= <NUM_LIT:2> : <EOL> options . stderr . write ( "<STR_LIT>" ) <EOL> for x in range ( len ( input ) ) : <EOL> options . stderr . write ( "<STR_LIT>" % ( titles [ x ] , input [ x ] ) ) <EOL> data = [ ] <EOL> for filename in input : <EOL> try : <EOL> values = collect ( open ( filename , "<STR_LIT:r>" ) , with_headers = options . headers ) <EOL> except IOError : <EOL> values = [ ] <EOL> data . append ( values ) <EOL> annotations = { } <EOL> for i in range ( len ( input ) ) : <EOL> for line in data [ i ] : <EOL> if line [ <NUM_LIT:1> ] < maxp : <EOL> annotations [ line [ <NUM_LIT:3> ] ] = <NUM_LIT:0> <EOL> for ann in annotations : <EOL> annotations [ ann ] = [ <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> , <NUM_LIT:1.0> ] <EOL> annlist = [ ann for ann in annotations ] <EOL> if options . sortAlphabetically : <EOL> annlist . sort ( ) <EOL> columns = <NUM_LIT:1> + int ( len ( annlist ) * rowheight / maxheight ) <EOL> collen = int ( maxheight / rowheight ) <EOL> pagecols = int ( ( maxwidth + maincolsep ) / ( posx ( len ( titles ) ) + maincolsep ) ) <EOL> if doEps : <EOL> pagecols = columns <EOL> numpages = <NUM_LIT:1> + int ( ( columns - <NUM_LIT:1> ) / pagecols ) <EOL> makeheader ( titles , annlist , min ( pagecols , columns ) , numpages ) <EOL> for page in range ( numpages ) : <EOL> if page == numpages - <NUM_LIT:1> : <EOL> colsonpage = columns - page * pagecols <EOL> else : <EOL> colsonpage = pagecols <EOL> makepageheader ( page + <NUM_LIT:1> ) <EOL> for column in range ( colsonpage ) : <EOL> globcolumn = page * pagecols + column <EOL> colannlist = annlist [ globcolumn * collen : <EOL> min ( ( globcolumn + <NUM_LIT:1> ) * collen , len ( annlist ) ) ] <EOL> print "<STR_LIT>" <EOL> print column * ( posx ( len ( titles ) ) + maincolsep ) , "<STR_LIT>" <EOL> makecolheader ( titles , colannlist , <EOL> title = options . title ) <EOL> for i in range ( len ( titles ) ) : <EOL> for j in range ( len ( colannlist ) ) : <EOL> element = <NUM_LIT:0> <EOL> for line in data [ i ] : <EOL> if line [ <NUM_LIT:3> ] == colannlist [ j ] : <EOL> element = line <EOL> if element != <NUM_LIT:0> : <EOL> makeps ( i , j , element ) <EOL> print "<STR_LIT>" <EOL> if colsonpage > <NUM_LIT:1> : <EOL> makefooter ( collen + <NUM_LIT:2> , footer = options . footer ) <EOL> else : <EOL> makefooter ( len ( colannlist ) + <NUM_LIT:2> , footer = options . footer ) <EOL> makepagetrailer ( page + <NUM_LIT:1> ) <EOL> if not doEps : <EOL> print "<STR_LIT>" <EOL> E . Stop ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( sys . argv ) ) </s>
