#NEWLINE# @ files ( PARAMS [ 'ancestral_repeats_filename' ] , 'repeats.gtf.gz' ) #NEWLINE# def buildRepeatTrack( infile , outfile ) : #NEWLINE# #INDENT# 'build a repeat track as negative control.' #NEWLINE# nrepeats = 0 #NEWLINE# for gff in GFF . iterator ( gzip . open ( infile , 'r' ) ) : #NEWLINE# #INDENT# nrepeats += 1 #NEWLINE# #UNINDENT# sample = set ( random . sample ( xrange ( nrepeats ) , PARAMS [ 'ancestral_repeats_samplesize' ] ) ) #NEWLINE# outf = gzip . open ( outfile , 'w' ) #NEWLINE# gtf = GTF . Entry ( ) #NEWLINE# for ( x , gff ) in enumerate ( GFF . iterator ( gzip . open ( infile , 'r' ) ) ) : #NEWLINE# #INDENT# if ( not ( x in sample ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# gtf . fromGFF ( gff , ( '%08i' % x ) , ( '%08i' % x ) ) #NEWLINE# outf . write ( ( '%s\n' % str ( gtf ) ) ) #NEWLINE# #UNINDENT# outf . close ( ) #NEWLINE# E . debug ( ( 'created sample of %i repeats out of %i in %s' % ( len ( sample ) , nrepeats , outfile ) ) )