Example #1
0
    def test_intervaljoins_faceted_compound():

        left = (('fruit', 'sort', 'begin', 'end'),
                ('apple', 'cox', 1, 2),
                ('apple', 'fuji', 2, 4))
        right = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'),
                 ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        expect = (('fruit', 'sort', 'begin', 'end', 'type', 'variety', 'start',
                   'stop', 'value'),
                  ('apple', 'cox', 1, 2, 'apple', 'cox', 1, 4, 'foo'),
                  ('apple', 'fuji', 2, 4, 'apple', 'fuji', 3, 7, 'bar'))

        actual = intervaljoin(left, right, lstart='begin', lstop='end',
                              rstart='start', rstop='stop',
                              lkey=('fruit', 'sort'),
                              rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)

        actual = intervalleftjoin(left, right, lstart='begin', lstop='end',
                                  rstart='start', rstop='stop',
                                  lkey=('fruit', 'sort'),
                                  rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #2
0
    def test_intervaljoin_prefixes():

        left = (('begin', 'end', 'quux'),
                (1, 2, 'a'),
                (2, 4, 'b'),
                (2, 5, 'c'),
                (9, 14, 'd'),
                (9, 140, 'e'),
                (1, 1, 'f'),
                (2, 2, 'g'),
                (4, 4, 'h'),
                (5, 5, 'i'),
                (1, 8, 'j'))

        right = (('start', 'stop', 'value'),
                 (1, 4, 'foo'),
                 (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervaljoin(left, right,
                              lstart='begin', lstop='end',
                              rstart='start', rstop='stop',
                              lprefix='l_', rprefix='r_')
        expect = (('l_begin', 'l_end', 'l_quux', 'r_start', 'r_stop', 'r_value'),
                  (1, 2, 'a', 1, 4, 'foo'),
                  (2, 4, 'b', 1, 4, 'foo'),
                  (2, 4, 'b', 3, 7, 'bar'),
                  (2, 5, 'c', 1, 4, 'foo'),
                  (2, 5, 'c', 3, 7, 'bar'),
                  (2, 5, 'c', 4, 9, 'baz'),
                  (1, 8, 'j', 1, 4, 'foo'),
                  (1, 8, 'j', 3, 7, 'bar'),
                  (1, 8, 'j', 4, 9, 'baz'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #3
0
    def test_intervaljoin_faceted():

        left = (('fruit', 'begin', 'end'),
                ('apple', 1, 2),
                ('apple', 2, 4),
                ('apple', 2, 5),
                ('orange', 2, 5),
                ('orange', 9, 14),
                ('orange', 19, 140),
                ('apple', 1, 1),
                ('apple', 2, 2),
                ('apple', 4, 4),
                ('apple', 5, 5),
                ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'),
                 ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'),
                 ('orange', 4, 9, 'baz'))

        expect = (('fruit', 'begin', 'end', 'type', 'start', 'stop', 'value'),
                  ('apple', 1, 2, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 3, 7, 'bar'),
                  ('apple', 2, 5, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 5, 'apple', 3, 7, 'bar'),
                  ('orange', 2, 5, 'orange', 4, 9, 'baz'))
        actual = intervaljoin(left, right, lstart='begin', lstop='end',
                              rstart='start', rstop='stop', lkey='fruit',
                              rkey='type')

        ieq(expect, actual)
        ieq(expect, actual)
Example #4
0
    def test_intervaljoin():

        left = (('begin', 'end', 'quux'),
                (1, 2, 'a'),
                (2, 4, 'b'),
                (2, 5, 'c'),
                (9, 14, 'd'),
                (9, 140, 'e'),
                (1, 1, 'f'),
                (2, 2, 'g'),
                (4, 4, 'h'),
                (5, 5, 'i'),
                (1, 8, 'j'))

        right = (('start', 'stop', 'value'),
                 (1, 4, 'foo'),
                 (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervaljoin(left, right,
                              lstart='begin', lstop='end',
                              rstart='start', rstop='stop')
        expect = (('begin', 'end', 'quux', 'start', 'stop', 'value'),
                  (1, 2, 'a', 1, 4, 'foo'),
                  (2, 4, 'b', 1, 4, 'foo'),
                  (2, 4, 'b', 3, 7, 'bar'),
                  (2, 5, 'c', 1, 4, 'foo'),
                  (2, 5, 'c', 3, 7, 'bar'),
                  (2, 5, 'c', 4, 9, 'baz'),
                  (1, 8, 'j', 1, 4, 'foo'),
                  (1, 8, 'j', 3, 7, 'bar'),
                  (1, 8, 'j', 4, 9, 'baz'))
        debug(lookall(actual))
        ieq(expect, actual)
        ieq(expect, actual)
Example #5
0
    def test_intervaljoins_faceted_compound():

        left = (('fruit', 'sort', 'begin', 'end'), ('apple', 'cox', 1, 2),
                ('apple', 'fuji', 2, 4))
        right = (('type', 'variety', 'start', 'stop', 'value'),
                 ('apple', 'cox', 1, 4, 'foo'), ('apple', 'fuji', 3, 7, 'bar'),
                 ('orange', 'mandarin', 4, 9, 'baz'))

        expect = (('fruit', 'sort', 'begin', 'end', 'type', 'variety', 'start',
                   'stop', 'value'), ('apple', 'cox', 1, 2, 'apple', 'cox', 1,
                                      4, 'foo'),
                  ('apple', 'fuji', 2, 4, 'apple', 'fuji', 3, 7, 'bar'))

        actual = intervaljoin(left,
                              right,
                              lstart='begin',
                              lstop='end',
                              rstart='start',
                              rstop='stop',
                              lkey=('fruit', 'sort'),
                              rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)

        actual = intervalleftjoin(left,
                                  right,
                                  lstart='begin',
                                  lstop='end',
                                  rstart='start',
                                  rstop='stop',
                                  lkey=('fruit', 'sort'),
                                  rkey=('type', 'variety'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #6
0
    def test_intervaljoin_faceted():

        left = (('fruit', 'begin', 'end'), ('apple', 1, 2), ('apple', 2, 4),
                ('apple', 2, 5), ('orange', 2, 5), ('orange', 9, 14),
                ('orange', 19, 140), ('apple', 1, 1), ('apple', 2, 2),
                ('apple', 4, 4), ('apple', 5, 5), ('orange', 5, 5))

        right = (('type', 'start', 'stop', 'value'), ('apple', 1, 4, 'foo'),
                 ('apple', 3, 7, 'bar'), ('orange', 4, 9, 'baz'))

        expect = (('fruit', 'begin', 'end', 'type', 'start', 'stop',
                   'value'), ('apple', 1, 2, 'apple', 1, 4,
                              'foo'), ('apple', 2, 4, 'apple', 1, 4, 'foo'),
                  ('apple', 2, 4, 'apple', 3, 7,
                   'bar'), ('apple', 2, 5, 'apple', 1, 4,
                            'foo'), ('apple', 2, 5, 'apple', 3, 7, 'bar'),
                  ('orange', 2, 5, 'orange', 4, 9, 'baz'))
        actual = intervaljoin(left,
                              right,
                              lstart='begin',
                              lstop='end',
                              rstart='start',
                              rstop='stop',
                              lkey='fruit',
                              rkey='type')

        ieq(expect, actual)
        ieq(expect, actual)
Example #7
0
    def test_intervaljoin_prefixes():

        left = (('begin', 'end', 'quux'), (1, 2, 'a'), (2, 4, 'b'),
                (2, 5, 'c'), (9, 14, 'd'), (9, 140, 'e'), (1, 1, 'f'),
                (2, 2, 'g'), (4, 4, 'h'), (5, 5, 'i'), (1, 8, 'j'))

        right = (('start', 'stop', 'value'), (1, 4, 'foo'), (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervaljoin(left,
                              right,
                              lstart='begin',
                              lstop='end',
                              rstart='start',
                              rstop='stop',
                              lprefix='l_',
                              rprefix='r_')
        expect = (('l_begin', 'l_end', 'l_quux', 'r_start', 'r_stop',
                   'r_value'), (1, 2, 'a', 1, 4, 'foo'),
                  (2, 4, 'b', 1, 4, 'foo'), (2, 4, 'b', 3, 7, 'bar'),
                  (2, 5, 'c', 1, 4, 'foo'), (2, 5, 'c', 3, 7, 'bar'),
                  (2, 5, 'c', 4, 9, 'baz'), (1, 8, 'j', 1, 4, 'foo'),
                  (1, 8, 'j', 3, 7, 'bar'), (1, 8, 'j', 4, 9, 'baz'))
        ieq(expect, actual)
        ieq(expect, actual)
Example #8
0
    def test_intervaljoin_include_stop():

        left = (('begin', 'end', 'quux'), (1, 2, 'a'), (2, 4, 'b'),
                (2, 5, 'c'), (9, 14, 'd'), (9, 140, 'e'), (1, 1, 'f'),
                (2, 2, 'g'), (4, 4, 'h'), (5, 5, 'i'), (1, 8, 'j'))

        right = (('start', 'stop', 'value'), (1, 4, 'foo'), (3, 7, 'bar'),
                 (4, 9, 'baz'))

        actual = intervaljoin(left,
                              right,
                              lstart='begin',
                              lstop='end',
                              rstart='start',
                              rstop='stop',
                              include_stop=True)
        expect = (('begin', 'end', 'quux', 'start', 'stop', 'value'),
                  (1, 2, 'a', 1, 4, 'foo'), (2, 4, 'b', 1, 4, 'foo'),
                  (2, 4, 'b', 3, 7, 'bar'), (2, 4, 'b', 4, 9, 'baz'),
                  (2, 5, 'c', 1, 4, 'foo'), (2, 5, 'c', 3, 7,
                                             'bar'), (2, 5, 'c', 4, 9, 'baz'),
                  (9, 14, 'd', 4, 9, 'baz'), (9, 140, 'e', 4, 9,
                                              'baz'), (1, 1, 'f', 1, 4, 'foo'),
                  (2, 2, 'g', 1, 4, 'foo'), (4, 4, 'h', 1, 4,
                                             'foo'), (4, 4, 'h', 3, 7, 'bar'),
                  (4, 4, 'h', 4, 9, 'baz'), (5, 5, 'i', 3, 7,
                                             'bar'), (5, 5, 'i', 4, 9, 'baz'),
                  (1, 8, 'j', 1, 4, 'foo'), (1, 8, 'j', 3, 7,
                                             'bar'), (1, 8, 'j', 4, 9, 'baz'))
        ieq(expect, actual)
        ieq(expect, actual)