def test(self): tree = single.tree() result = list( single.matching_statistics( tree, list( "ABC" ) ) ) self.assertEqual( result, [ ( 0, ( tree.root, 0 ) ) ] * 3 ) builder = single.ukkonen( tree = tree ) for c in "TTAGC$": builder.append( c ) self.assertRaises( RuntimeError, single.matching_statistics, tree, list() ); builder.detach() root = tree.root branch_t = root[ "T" ] leaf_0 = branch_t[ "T" ] leaf_1 = branch_t[ "A" ] leaf_2 = root[ "A" ] leaf_3 = root[ "G" ] leaf_4 = root[ "C" ] result = list( single.matching_statistics( tree, [] ) ) self.assertEqual( result, [] ) result = list( single.matching_statistics( tree, list( "QTTATTATTTAGCQWTTAGFK" ) ) ) self.assertEqual( result, [ ( 0, ( root, 0 ) ), ( 3, ( leaf_0, 3 ) ), ( 2, ( leaf_1, 3 ) ), ( 1, ( leaf_2, 3 ) ), ( 3, ( leaf_0, 3 ) ), ( 2, ( leaf_1, 3 ) ), ( 1, ( leaf_2, 3 ) ), ( 2, ( leaf_0, 2 ) ), ( 5, ( leaf_0, 5 ) ), ( 4, ( leaf_1, 5 ) ), ( 3, ( leaf_2, 5 ) ), ( 2, ( leaf_3, 5 ) ), ( 1, ( leaf_4, 5 ) ), ( 0, ( root, 0 ) ), ( 0, ( root, 0 ) ), ( 4, ( leaf_0, 4 ) ), ( 3, ( leaf_1, 4 ) ), ( 2, ( leaf_2, 4 ) ), ( 1, ( leaf_3, 4 ) ), ( 0, ( root, 0 ) ), ( 0, ( root, 0 ) ), ] )
def test(self): tree = single.tree() result = list( single.matching_statistics( tree, list( "ABC" ) ) ) self.assertEqual( result, [ ( 0, ( tree.root, 0 ) ) ] * 3 ) builder = single.ukkonen( tree = tree ) for c in "TTAGC$": builder.append( c ) builder.detach() leaf_indices_below = suffixtree.calculate_leaf_indices( root = tree.root ) root = tree.root branch_t = root[ "T" ] leaf_0 = branch_t[ "T" ] leaf_1 = branch_t[ "A" ] leaf_2 = root[ "A" ] leaf_3 = root[ "G" ] leaf_4 = root[ "C" ] leaf_5 = root[ "$" ] self.assertEqual( leaf_indices_below[ leaf_0 ], [ 0 ] ) self.assertEqual( leaf_indices_below[ leaf_1 ], [ 1 ] ) self.assertEqual( leaf_indices_below[ leaf_2 ], [ 2 ] ) self.assertEqual( leaf_indices_below[ leaf_3 ], [ 3 ] ) self.assertEqual( leaf_indices_below[ leaf_4 ], [ 4 ] ) self.assertEqual( leaf_indices_below[ leaf_5 ], [ 5 ] ) self.assertEqual( sorted( leaf_indices_below[ branch_t ] ), [ 0, 1 ] ) self.assertEqual( sorted( leaf_indices_below[ root ] ), list(range( 6)) )
def test(self): tree = single.tree() result = list( single.matching_statistics( tree, list( "ABC" ) ) ) self.assertEqual( result, [ ( 0, ( tree.root, 0 ) ) ] * 3 ) builder = single.ukkonen( tree = tree ) for c in "TTAGC$": builder.append( c ) builder.detach() leaf_indices_below = suffixtree.calculate_leaf_indices( root = tree.root ) root = tree.root branch_t = root[ "T" ] leaf_0 = branch_t[ "T" ] leaf_1 = branch_t[ "A" ] leaf_2 = root[ "A" ] leaf_3 = root[ "G" ] leaf_4 = root[ "C" ] leaf_5 = root[ "$" ] self.assertEqual( leaf_indices_below[ leaf_0 ], [ 0 ] ) self.assertEqual( leaf_indices_below[ leaf_1 ], [ 1 ] ) self.assertEqual( leaf_indices_below[ leaf_2 ], [ 2 ] ) self.assertEqual( leaf_indices_below[ leaf_3 ], [ 3 ] ) self.assertEqual( leaf_indices_below[ leaf_4 ], [ 4 ] ) self.assertEqual( leaf_indices_below[ leaf_5 ], [ 5 ] ) self.assertEqual( sorted( leaf_indices_below[ branch_t ] ), [ 0, 1 ] ) self.assertEqual( sorted( leaf_indices_below[ root ] ), range( 6 ) )