<s> '''<STR_LIT>''' <EOL> import os <EOL> import sys <EOL> import CGAT . Experiment as E <EOL> import CGAT . IOTools as IOTools <EOL> import pysam <EOL> import CGAT . GTF as GTF <EOL> import numpy <EOL> import pandas <EOL> try : <EOL> import pyximport <EOL> pyximport . install ( build_in_temp = False ) <EOL> import _bam2geneprofile <EOL> except ImportError : <EOL> import CGAT . _bam2geneprofile as _bam2geneprofile <EOL> from bx . bbi . bigwig_file import BigWigFile <EOL> def main ( argv = None ) : <EOL> """<STR_LIT>""" <EOL> if not argv : <EOL> argv = sys . argv <EOL> parser = E . OptionParser ( version = "<STR_LIT>" , <EOL> usage = globals ( ) [ "<STR_LIT>" ] ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT>" , <EOL> action = "<STR_LIT>" , <EOL> choices = ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ) , <EOL> help = '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" , <EOL> type = "<STR_LIT:string>" , action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT:-c>" , "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> metavar = "<STR_LIT>" , <EOL> type = "<STR_LIT:string>" , action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:string>" , <EOL> metavar = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT>" , <EOL> choices = ( "<STR_LIT:none>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT>" , action = "<STR_LIT>" , <EOL> choices = ( "<STR_LIT:all>" , "<STR_LIT:none>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT>" , <EOL> choices = ( "<STR_LIT>" , "<STR_LIT>" ) , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> action = "<STR_LIT>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:float>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> action = "<STR_LIT:store_true>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:string>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . add_option ( <EOL> "<STR_LIT>" , <EOL> dest = "<STR_LIT>" , <EOL> type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> parser . set_defaults ( <EOL> remove_rna = False , <EOL> ignore_pairs = False , <EOL> force_output = False , <EOL> bin_size = <NUM_LIT:10> , <EOL> extends = [ ] , <EOL> shifts = [ ] , <EOL> sort = [ ] , <EOL> reporter = "<STR_LIT>" , <EOL> resolution_cds = <NUM_LIT:1000> , <EOL> resolution_introns = <NUM_LIT:1000> , <EOL> resolution_exons_absolute_distance_topolya = <NUM_LIT> , <EOL> resolution_introns_absolute_distance_topolya = <NUM_LIT> , <EOL> extension_exons_absolute_distance_topolya = <NUM_LIT> , <EOL> extension_introns_absolute_distance_topolya = <NUM_LIT> , <EOL> resolution_upstream_utr = <NUM_LIT:1000> , <EOL> resolution_downstream_utr = <NUM_LIT:1000> , <EOL> resolution_upstream = <NUM_LIT:1000> , <EOL> resolution_downstream = <NUM_LIT:1000> , <EOL> resolution_first = <NUM_LIT:1000> , <EOL> resolution_last = <NUM_LIT:1000> , <EOL> extension_upstream = <NUM_LIT> , <EOL> extension_downstream = <NUM_LIT> , <EOL> extension_inward = <NUM_LIT> , <EOL> extension_outward = <NUM_LIT> , <EOL> plot = True , <EOL> methods = [ ] , <EOL> infiles = [ ] , <EOL> controlfiles = [ ] , <EOL> gtffile = None , <EOL> profile_normalizations = [ ] , <EOL> transcript_normalization = None , <EOL> scale_flanks = <NUM_LIT:0> , <EOL> merge_pairs = False , <EOL> min_insert_size = <NUM_LIT:0> , <EOL> max_insert_size = <NUM_LIT:1000> , <EOL> base_accuracy = False , <EOL> matrix_format = "<STR_LIT>" , <EOL> control_factor = None , <EOL> output_all_profiles = False , <EOL> background_region_bins = <NUM_LIT:10> , <EOL> input_filename_counts = None , <EOL> ) <EOL> ( options , args ) = E . Start ( parser , argv = argv , add_output_options = True ) <EOL> if len ( args ) == <NUM_LIT:2> : <EOL> infile , gtf = args <EOL> options . infiles . append ( infile ) <EOL> options . gtffile = gtf <EOL> if not options . gtffile : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> if options . gtffile == "<STR_LIT:->" : <EOL> options . gtffile = options . stdin <EOL> else : <EOL> options . gtffile = IOTools . openFile ( options . gtffile ) <EOL> if len ( options . infiles ) == <NUM_LIT:0> : <EOL> raise ValueError ( "<STR_LIT>" ) <EOL> for methodsRequiresBaseAccuracy in [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> ] : <EOL> if methodsRequiresBaseAccuracy in options . methods : <EOL> options . base_accuracy = True <EOL> if options . reporter == "<STR_LIT>" : <EOL> gtf_iterator = GTF . flat_gene_iterator ( GTF . iterator ( options . gtffile ) ) <EOL> elif options . reporter == "<STR_LIT>" : <EOL> gtf_iterator = GTF . transcript_iterator ( GTF . iterator ( options . gtffile ) ) <EOL> if len ( options . infiles ) > <NUM_LIT:0> : <EOL> if options . infiles [ <NUM_LIT:0> ] . endswith ( "<STR_LIT>" ) : <EOL> bamfiles = [ pysam . Samfile ( x , "<STR_LIT:rb>" ) for x in options . infiles ] <EOL> if options . controlfiles : <EOL> controlfiles = [ pysam . Samfile ( x , "<STR_LIT:rb>" ) <EOL> for x in options . controlfiles ] <EOL> else : <EOL> controlfiles = None <EOL> format = "<STR_LIT>" <EOL> if options . merge_pairs : <EOL> range_counter = _bam2geneprofile . RangeCounterBAM ( <EOL> bamfiles , <EOL> shifts = options . shifts , <EOL> extends = options . extends , <EOL> merge_pairs = options . merge_pairs , <EOL> min_insert_size = options . min_insert_size , <EOL> max_insert_size = options . max_insert_size , <EOL> controfiles = controlfiles , <EOL> control_factor = options . control_factor ) <EOL> elif options . shifts or options . extends : <EOL> range_counter = _bam2geneprofile . RangeCounterBAM ( <EOL> bamfiles , <EOL> shifts = options . shifts , <EOL> extends = options . extends , <EOL> controlfiles = controlfiles , <EOL> control_factor = options . control_factor ) <EOL> elif options . base_accuracy : <EOL> range_counter = _bam2geneprofile . RangeCounterBAMBaseAccuracy ( <EOL> bamfiles , <EOL> controlfiles = controlfiles , <EOL> control_factor = options . control_factor ) <EOL> else : <EOL> range_counter = _bam2geneprofile . RangeCounterBAM ( <EOL> bamfiles , <EOL> controlfiles = controlfiles , <EOL> control_factor = options . control_factor ) <EOL> elif options . infiles [ <NUM_LIT:0> ] . endswith ( "<STR_LIT>" ) : <EOL> bedfiles = [ pysam . Tabixfile ( x ) for x in options . infiles ] <EOL> if options . controlfiles : <EOL> controlfiles = [ pysam . Tabixfile ( x ) <EOL> for x in options . controlfiles ] <EOL> else : <EOL> controlfiles = None <EOL> range_counter = _bam2geneprofile . RangeCounterBed ( <EOL> bedfiles , <EOL> controlfiles = controlfiles , <EOL> control_factor = options . control_factor ) <EOL> elif options . infiles [ <NUM_LIT:0> ] . endswith ( "<STR_LIT>" ) : <EOL> wigfiles = [ BigWigFile ( file = open ( x ) ) for x in options . infiles ] <EOL> range_counter = _bam2geneprofile . RangeCounterBigWig ( wigfiles ) <EOL> else : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" % str ( options . infiles ) ) <EOL> counters = [ ] <EOL> for method in options . methods : <EOL> if method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . UTRCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_upstream_utr , <EOL> options . resolution_cds , <EOL> options . resolution_downstream_utr , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream , <EOL> ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . GeneCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_cds , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream , <EOL> options . scale_flanks ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . GeneCounterWithIntrons ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_cds , <EOL> options . resolution_introns , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream , <EOL> options . scale_flanks ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( <EOL> _bam2geneprofile . GeneCounterAbsoluteDistanceFromThreePrimeEnd ( <EOL> range_counter , options . resolution_upstream , <EOL> options . resolution_downstream , <EOL> options . resolution_exons_absolute_distance_topolya , <EOL> options . resolution_introns_absolute_distance_topolya , <EOL> options . extension_upstream , <EOL> options . extension_downstream , <EOL> options . extension_exons_absolute_distance_topolya , <EOL> options . extension_introns_absolute_distance_topolya , <EOL> options . scale_flanks ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . TSSCounter ( <EOL> range_counter , <EOL> options . extension_outward , <EOL> options . extension_inward ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . RegionCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_cds , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . MidpointCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . SeparateExonCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_first , <EOL> options . resolution_last , <EOL> options . resolution_cds , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream ) ) <EOL> elif method == "<STR_LIT>" : <EOL> counters . append ( _bam2geneprofile . SeparateExonWithIntronCounter ( <EOL> range_counter , <EOL> options . resolution_upstream , <EOL> options . resolution_first , <EOL> options . resolution_last , <EOL> options . resolution_cds , <EOL> options . resolution_introns , <EOL> options . resolution_downstream , <EOL> options . extension_upstream , <EOL> options . extension_downstream ) ) <EOL> for c in counters : <EOL> c . setNormalization ( options . transcript_normalization ) <EOL> if options . output_all_profiles : <EOL> c . setOutputProfiles ( IOTools . openFile ( E . getOutputFile ( c . name ) + <EOL> "<STR_LIT>" , "<STR_LIT:w>" ) ) <EOL> if options . input_filename_counts : <EOL> E . info ( "<STR_LIT>" % options . input_filename_counts ) <EOL> all_counts = pandas . read_csv ( <EOL> IOTools . openFile ( options . input_filename_counts ) , <EOL> sep = '<STR_LIT:\t>' , header = <NUM_LIT:0> , index_col = <NUM_LIT:0> ) <EOL> if len ( counters ) != <NUM_LIT:1> : <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> counter = _bam2geneprofile . UnsegmentedCounter ( counters [ <NUM_LIT:0> ] ) <EOL> counters = [ counter ] <EOL> _bam2geneprofile . countFromCounts ( counters , all_counts ) <EOL> else : <EOL> E . info ( "<STR_LIT>" % len ( counters ) ) <EOL> feature_names = _bam2geneprofile . countFromGTF ( counters , <EOL> gtf_iterator ) <EOL> if not options . profile_normalizations : <EOL> options . profile_normalizations . append ( "<STR_LIT:none>" ) <EOL> elif "<STR_LIT:all>" in options . profile_normalizations : <EOL> options . profile_normalizations = [ "<STR_LIT:none>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ] <EOL> for method , counter in zip ( options . methods , counters ) : <EOL> profiles = [ ] <EOL> for norm in options . profile_normalizations : <EOL> profile = counter . getProfile ( <EOL> normalize = norm , <EOL> background_region_bins = options . background_region_bins ) <EOL> profiles . append ( profile ) <EOL> for x in range ( <NUM_LIT:1> , len ( profiles ) ) : <EOL> assert profiles [ <NUM_LIT:0> ] . shape == profiles [ x ] . shape <EOL> matrix = numpy . concatenate ( profiles ) <EOL> matrix . shape = len ( profiles ) , len ( profiles [ <NUM_LIT:0> ] ) <EOL> matrix = matrix . transpose ( ) <EOL> with IOTools . openFile ( E . getOutputFile ( counter . name ) + <EOL> "<STR_LIT>" , "<STR_LIT:w>" ) as outfile : <EOL> outfile . write ( "<STR_LIT>" % "<STR_LIT:\t>" . join ( <EOL> options . profile_normalizations ) ) <EOL> fields = [ ] <EOL> bins = [ ] <EOL> for field , nbins in zip ( counter . fields , counter . nbins ) : <EOL> fields . extend ( [ field ] * nbins ) <EOL> bins . extend ( list ( range ( nbins ) ) ) <EOL> for row , cols in enumerate ( zip ( fields , bins , matrix ) ) : <EOL> outfile . write ( "<STR_LIT>" % <EOL> ( row , "<STR_LIT:\t>" . join ( [ str ( x ) for x in cols [ : - <NUM_LIT:1> ] ] ) ) ) <EOL> outfile . write ( "<STR_LIT>" % <EOL> ( "<STR_LIT:\t>" . join ( [ str ( x ) for x in cols [ - <NUM_LIT:1> ] ] ) ) ) <EOL> with IOTools . openFile ( E . getOutputFile ( counter . name ) + <EOL> "<STR_LIT>" , "<STR_LIT:w>" ) as outfile : <EOL> counter . writeLengthStats ( outfile ) <EOL> if options . output_all_profiles : <EOL> counter . closeOutputProfiles ( ) <EOL> if options . plot : <EOL> import matplotlib <EOL> matplotlib . use ( "<STR_LIT>" ) <EOL> import matplotlib . pyplot as plt <EOL> for method , counter in zip ( options . methods , counters ) : <EOL> if method in ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) : <EOL> plt . figure ( ) <EOL> plt . subplots_adjust ( wspace = <NUM_LIT> ) <EOL> max_scale = max ( [ max ( x ) for x in counter . aggregate_counts ] ) <EOL> for x , counts in enumerate ( counter . aggregate_counts ) : <EOL> plt . subplot ( <NUM_LIT:6> , <NUM_LIT:1> , x + <NUM_LIT:1> ) <EOL> plt . plot ( range ( len ( counts ) ) , counts ) <EOL> plt . title ( counter . fields [ x ] ) <EOL> plt . ylim ( <NUM_LIT:0> , max_scale ) <EOL> figname = counter . name + "<STR_LIT>" <EOL> fn = E . getOutputFile ( figname ) + "<STR_LIT>" <EOL> plt . savefig ( os . path . expanduser ( fn ) ) <EOL> plt . figure ( ) <EOL> points = [ ] <EOL> cuts = [ ] <EOL> for x , counts in enumerate ( counter . aggregate_counts ) : <EOL> points . extend ( counts ) <EOL> cuts . append ( len ( counts ) ) <EOL> plt . plot ( range ( len ( points ) ) , points ) <EOL> xx , xxx = <NUM_LIT:0> , [ ] <EOL> for x in cuts : <EOL> xxx . append ( xx + x // <NUM_LIT:2> ) <EOL> xx += x <EOL> plt . axvline ( xx , <EOL> color = "<STR_LIT:r>" , <EOL> ls = "<STR_LIT>" ) <EOL> plt . xticks ( xxx , counter . fields ) <EOL> figname = counter . name + "<STR_LIT>" <EOL> fn = E . getOutputFile ( figname ) + "<STR_LIT>" <EOL> plt . savefig ( os . path . expanduser ( fn ) ) <EOL> elif method == "<STR_LIT>" : <EOL> plt . figure ( ) <EOL> plt . subplot ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> plt . plot ( range ( - options . extension_outward , <EOL> options . extension_inward ) , <EOL> counter . aggregate_counts [ <NUM_LIT:0> ] ) <EOL> plt . title ( counter . fields [ <NUM_LIT:0> ] ) <EOL> plt . subplot ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> plt . plot ( range ( - options . extension_inward , <EOL> options . extension_outward ) , <EOL> counter . aggregate_counts [ <NUM_LIT:1> ] ) <EOL> plt . title ( counter . fields [ <NUM_LIT:1> ] ) <EOL> plt . subplot ( <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> plt . title ( "<STR_LIT>" ) <EOL> plt . plot ( range ( - options . extension_outward , <EOL> options . extension_inward ) , <EOL> counter . aggregate_counts [ <NUM_LIT:0> ] ) <EOL> plt . plot ( range ( - options . extension_inward , <EOL> options . extension_outward ) , <EOL> counter . aggregate_counts [ <NUM_LIT:1> ] ) <EOL> plt . legend ( counter . fields [ : <NUM_LIT:2> ] ) <EOL> fn = E . getOutputFile ( counter . name ) + "<STR_LIT>" <EOL> plt . savefig ( os . path . expanduser ( fn ) ) <EOL> elif method == "<STR_LIT>" : <EOL> plt . figure ( ) <EOL> plt . plot ( numpy . arange ( - options . resolution_upstream , <NUM_LIT:0> ) , <EOL> counter . aggregate_counts [ <NUM_LIT:0> ] ) <EOL> plt . plot ( numpy . arange ( <NUM_LIT:0> , options . resolution_downstream ) , <EOL> counter . aggregate_counts [ <NUM_LIT:1> ] ) <EOL> fn = E . getOutputFile ( counter . name ) + "<STR_LIT>" <EOL> plt . savefig ( os . path . expanduser ( fn ) ) <EOL> E . Stop ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( sys . argv ) ) </s>
