#NEWLINE# def testFind( self ) : #NEWLINE# #INDENT# src = StringIO . StringIO ( 'chr1|test|gene|1001|1100|0|+|.|gene_id "foo1"; transcript_id "bar1";\nchr1|test|gene|2001|2100|0|+|.|gene_id "foo2"; transcript_id "bar2";\nchr1|test|gene|3001|3100|0|+|.|gene_id "foo3"; transcript_id "bar3";\n' . replace ( '|' , '\t' ) ) #NEWLINE# gtf = GTF ( fileobj = src , quiet = True ) #NEWLINE# genes = list ( gtf . genes ) #NEWLINE# self . assertEqual ( [ 'foo1' , 'foo2' , 'foo3' ] , [ x . gene_id for x in genes ] ) #NEWLINE# found = False #NEWLINE# for gene in gtf . find ( 'chr1' , 1900 , 2200 ) : #NEWLINE# #INDENT# found = True #NEWLINE# self . assertEqual ( gene . gid , 'foo2' ) #NEWLINE# #UNINDENT# self . assertTrue ( found ) #NEWLINE# found = False #NEWLINE# for gene in gtf . find ( 'chr1' , 1900 , 2000 ) : #NEWLINE# #INDENT# found = True #NEWLINE# self . assertEqual ( gene . gid , 'foo2' ) #NEWLINE# #UNINDENT# self . assertTrue ( found ) #NEWLINE# found = False #NEWLINE# for gene in gtf . find ( 'chr1' , 2050 , 2200 ) : #NEWLINE# #INDENT# found = True #NEWLINE# self . assertEqual ( gene . gid , 'foo2' ) #NEWLINE# #UNINDENT# self . assertTrue ( found )