Commits

Kanwei Li committed 37f2fb7

Fix small twobit reading bug & add test

Comments (0)

Files changed (2)

lib/bx/seq/twobit.py

         # Trim start / stop
         if start < 0:
             start = 0
-        if end > seq.size:
-            end = seq.size
+        if end > self.size:
+            end = self.size
         out_size = end - start
         if out_size < 1:
             raise Exception( "end before start (%s,%s)" % ( start,end ) )

lib/bx/seq/twobit_tests.py

         for i in range( 100 ):
             start = random.randint( 0, length-2 )
             end = random.randint( start+1, length )
+            assert t[k].get(start, end) == s[start:end]
             assert t[k][start:end] == s[start:end], \
                 "seq: %s, start: %d, end: %d\nExpected:\n%s\nActual:\n%s\n" % ( k, start, end, s[start:end], t.get( k, start, end ) )