<s> '''<STR_LIT>''' <EOL> import sys <EOL> import CGAT . Experiment as E <EOL> import CGAT . IndexedFasta as IndexedFasta <EOL> import CGAT . GTF as GTF <EOL> USAGE = """<STR_LIT>""" % sys . argv [ <NUM_LIT:0> ] <EOL> def writeHeader ( outfile ) : <EOL> outfile . write ( "<STR_LIT:\t>" . join ( ( "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) ) + "<STR_LIT:\n>" ) <EOL> def main ( argv = None ) : <EOL> parser = E . OptionParser ( <EOL> version = "<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>" , "<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>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . add_option ( "<STR_LIT>" , "<STR_LIT>" , dest = "<STR_LIT>" , type = "<STR_LIT:int>" , <EOL> help = "<STR_LIT>" ) <EOL> parser . set_defaults ( <EOL> as_gtf = False , <EOL> genome_file = None , <EOL> fragment_size = <NUM_LIT:1000> , <EOL> sample_size = <NUM_LIT> , <EOL> pattern_id = "<STR_LIT>" , <EOL> ) <EOL> ( options , args ) = E . Start ( parser ) <EOL> fasta = IndexedFasta . IndexedFasta ( options . genome_file ) <EOL> contigs = fasta . getContigSizes ( ) <EOL> if options . as_gtf : <EOL> entry = GTF . Entry ( ) <EOL> else : <EOL> entry = GTF . Entry ( ) <EOL> n = <NUM_LIT:0> <EOL> entry . feature = "<STR_LIT>" <EOL> entry . source = "<STR_LIT>" <EOL> for x in range ( options . sample_size ) : <EOL> entry . contig , entry . strand , entry . start , entry . end = fasta . getRandomCoordinates ( <EOL> options . fragment_size ) <EOL> if entry . strand == "<STR_LIT:->" : <EOL> l = contigs [ entry . contig ] <EOL> entry . start , entry . end = l - entry . end , l - entry . start <EOL> if options . as_gtf : <EOL> entry . gene_id = options . pattern_id % n <EOL> entry . transcript_id = entry . gene_id <EOL> options . stdout . write ( str ( entry ) + "<STR_LIT:\n>" ) <EOL> n += <NUM_LIT:1> <EOL> E . Stop ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( main ( ) ) </s>
