def test_strand_tables(self):
        se = 'CCCTTTGGG'
        assert make_strand_table(se) == [list(se)]
        assert strand_table_to_sequence(make_strand_table(se), join=True) == se

        se = 'CCCT+TTGGG'
        assert make_strand_table(se) == [list('CCCT'), list('TTGGG')]
        assert strand_table_to_sequence(make_strand_table(se), join=True) == se

        se = 'CCCT+TTGGG'
        assert make_strand_table(se) == [list('CCCT'), list('TTGGG')]
        assert strand_table_to_sequence(make_strand_table(se), join=True) == se

        se = 'CCCT+AAA+TTGGG'
        assert make_strand_table(se) == [
            list('CCCT'), list('AAA'),
            list('TTGGG')
        ]
        assert strand_table_to_sequence(make_strand_table(se), join=True) == se

        se = list('CCCT+AAA+TTGGG')
        assert make_strand_table(se) == [
            list('CCCT'), list('AAA'),
            list('TTGGG')
        ]
        assert strand_table_to_sequence(make_strand_table(se),
                                        join=False) == se
    def test_split_complex_01(self):
        se = 'CCCT+AAA+TTGGG'
        ss = '(((.+...+..)))'
        ps = make_strand_table(se)
        pt = make_pair_table(ss)
        out = list(split_complex_pt(ps, pt))
        assert len(out) == 2
        outdb = list(split_complex_db(se, ss, join=True))
        assert ('CCCT+TTGGG', '(((.+..)))') in outdb
        assert ('AAA', '...') in outdb

        se = 'CCCT+AAA+TTTT+TTGGG'
        ss = '(((.+...+....+..)))'
        ps = make_strand_table(se)
        pt = make_pair_table(ss)
        out = list(split_complex_pt(ps, pt))
        assert len(out) == 3
        outdb = list(split_complex_db(se, ss, join=True))
        assert ('CCCT+TTGGG', '(((.+..)))') in outdb
        assert ('AAA', '...') in outdb
        assert ('TTTT', '....') in outdb
 def test_split_complex_02(self):
     se = 'CCCT+AAA+GCGC+TTTT+TTGGG'
     ss = '(((.+.(.+)()(+.)..+..)))'
     ps = make_strand_table(se)
     pt = make_pair_table(ss)
     bs, bt = ps[:], pt[:]
     out = list(split_complex_pt(ps, pt))
     assert len(out) == 2
     assert bs == ps
     assert bt == pt
     outdb = list(split_complex_db(se, ss, join=True))
     assert len(outdb) == 2
     assert ('CCCT+TTGGG', '(((.+..)))') in outdb
     assert ('AAA+GCGC+TTTT', '.(.+)()(+.)..') in outdb
    def test_split_complex_00(self):
        se = list('CCCTTTGGG')
        ss = list('(((...)))')
        ps = make_strand_table(se)
        pt = make_pair_table(ss)
        out = list(split_complex_pt(ps, pt))
        assert len(out) == 1
        c1 = ([['C', 'C', 'C', 'T', 'T', 'T', 'G', 'G',
                'G']], [[(0, 8), (0, 7), (0, 6), None, None, None, (0, 2),
                         (0, 1), (0, 0)]])
        assert c1 in out

        outdb = list(split_complex_db(se, ss))
        assert (se, ss) in outdb

        se = list('CCCT+TTGGG')
        ss = list('(((.+..)))')
        ps = make_strand_table(se)
        pt = make_pair_table(ss)
        out = list(split_complex_pt(ps, pt))
        assert len(out) == 1
        outdb = list(split_complex_db(se, ss))
        assert (se, ss) in outdb
    def test_split_complex_03(self):
        se = 'CCCT+TC+GT+TG+C+GG'
        ss = '(((.+.(+).+.)+.+))'
        ps = make_strand_table(se)
        pt = make_pair_table(ss)
        out = list(split_complex_pt(ps, pt))
        assert len(out) == 3
        c1 = ([['T', 'C'], ['G', 'T']], [[None, (1, 0)], [(0, 1), None]])
        c2 = ([['C']], [[None]])
        c3 = ([['C', 'C', 'C', 'T'], ['T', 'G'], ['G', 'G']], [[(2, 1), (2, 0),
                                                                (1, 1), None],
                                                               [None, (0, 2)],
                                                               [(0, 1),
                                                                (0, 0)]])
        assert c1 in out
        assert c2 in out
        assert c3 in out

        outdb = list(split_complex_db(se, ss, join=True))
        assert ('TC+GT', '.(+).') in outdb
        assert ('C', '.') in outdb
        assert ('CCCT+TG+GG', '(((.+.)+))') in outdb