#NEWLINE# def filterGenome( iterator , contigs ) : #NEWLINE# #INDENT# 'remove bed intervals that are outside of contigs.\n\n    contigs is a dictionary of contig sizes.' #NEWLINE# ( ninput , noutput ) = ( 0 , 0 ) #NEWLINE# ( nskipped_contig , nskipped_range , nskipped_endzero ) = ( 0 , 0 , 0 ) #NEWLINE# for bed in iterator : #NEWLINE# #INDENT# ninput += 1 #NEWLINE# if ( bed . contig not in bed ) : #NEWLINE# #INDENT# nskipped_contig += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# if ( ( bed . start < 0 ) or ( bed . end < 0 ) ) : #NEWLINE# #INDENT# nskipped_range += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# if ( bed . end > contigs [ bed . contig ] ) : #NEWLINE# #INDENT# nskipped_range += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# if ( bed . end == 0 ) : #NEWLINE# #INDENT# nskipped_endzero += 1 #NEWLINE# continue #NEWLINE# #UNINDENT# noutput += 1 #NEWLINE# ( yield bed ) #NEWLINE# #UNINDENT# E . info ( ( 'ninput=%i, noutput=%i, nskipped_contig=%i, nskipped_range=%i, nskipped_endzero=%i' % ( ninput , noutput , nskipped_contig , nskipped_range , nskipped_endzero ) ) )