Exemple #1
0
 def runTest(self):
     self.maxDiff = None
     my_test = {
              'fn':     genomic_manip.association.find_closest_features(),
              'tracks': {'X': track_collections['Validation'][6]['path_sql'],
                         'Y': track_collections['Validation'][5]['path_sql']},
              'input':  {'max_length':0, 'utr_cutoff':0, 'prom_cutoff': 45},
              'expected': [0]
              }
     run_one(self, my_test)
Exemple #2
0
    def runTest(self):
        self.maxDiff = None

        tests = [
                {'fn':     genomic_manip.basic.bounded(),
                 'input':  {'min_bound': 0, 'max_bound': 45},
                 'tracks': {'X': [(-2,10),(20,30),(26,23),(40,50)]},
                 'expected': [(0,10),(20,30),(40,45)]}
                ,
                {'fn':     genomic_manip.basic.concatenate(),
                 'input':  {'list_of_tracks': [track_collections['Validation'][1]['path_sql'],
                                               track_collections['Validation'][4]['path_sql']]},
                 'expected': [
                             ( 0,   10, u'Validation feature 1',  10.0, 0),
                             ( 2,    8, u'Validation feature 2',   0.0, 0),
                             (10,   20, u'Lorem',                  1.0, 1),
                             (20,   30, u'Validation feature 3',  10.0, 0),
                             (25,   30, u'Validation feature 4',   0.0, 0),
                             (30,   40, u'Ipsum',                  2.0, 1),
                             (40,   45, u'Validation feature 5',   0.0, 0),
                             (40,   50, u'Validation feature 6',  10.0, 0),
                             (60,   70, u'Validation feature 7',  10.0, 0),
                             (70,   80, u'Validation feature 8',  10.0, 0),
                             (90,  100, u'Validation feature 9',  10.0, 0),
                             (90,  110, u'Validation feature 10', 10.0, 0),
                             (120, 130, u'Validation feature 11', 10.0, 0),
                             (125, 135, u'Validation feature 12',  5.0, 0)]}
                 ,
                 {'fn':     genomic_manip.basic.concatenate(),
                 'input':  {'list_of_tracks': [[(0,10),(0,10),(5,10)],
                                               [(0,5),(0,12),(5,8)]]},
                 'expected': [(0,5),(0,10),(0,10),(0,12),(5,8),(5,10)]}
                 ,
                 {'fn':     genomic_manip.basic.flatten(),
                 'input':  {'stop_val': 10},
                 'tracks': {'X': [(0,2,10.0),(2,4,20.0),(6,8,10.0)]},
                 'expected': [10.0, 10.0, 20.0, 20.0, 0.0, 0.0, 10.0, 10.0, 0.0, 0.0]}
                 ,
                 {'fn':     genomic_manip.basic.qual_to_quan(),
                 'tracks': {'X': track_collections['Validation'][4]['path_sql']},
                 'fields': {'X': ['start', 'end', 'score']},
                 'expected': [(10, 20, 1.0), (30, 40, 2.0)]}
                 ,
                 {'fn':     genomic_manip.basic.qual_to_quan(),
                 'tracks': {'X': [(0,2),(2,4),(6,8)]},
                 'expected': [(0,2,1.0),(2,4,1.0),(6,8,1.0)]}
                 ]

        for t in tests: run_one(self, t)
Exemple #3
0
    def runTest(self):
        self.maxDiff = None

        tests  = [
                {'fn':     genomic_manip.boolean.bool_not(),
                 'input':  {'stop_val': 200},
                 'tracks': {'X': track_collections['Validation'][1]['path_sql']},
                 'expected': [( 10, 20, '', 0.0, 0),
                              ( 30, 40, '', 0.0, 0),
                              ( 50, 60, '', 0.0, 0),
                              ( 80, 90, '', 0.0, 0),
                              (110, 120,'', 0.0, 0),
                              (135, 200,'', 0.0, 0)]}
                ,
                {'fn':     genomic_manip.boolean.bool_and(),
                 'tracks': {'X': track_collections['Validation'][2]['path_sql'],
                            'Y': track_collections['Validation'][3]['path_sql']},
                 'expected': [( 15,  20, u'NameA + Name1',  0.1,  0),
                              ( 32,  38, u'NameB + Name2',  0.2,  1),
                              ( 95, 100, u'NameD + Name5',  0.0,  1),
                              (110, 115, u'Name6 + NameD',  0.2,  1),
                              (130, 135, u'Name7 + NameE',  0.4,  0),
                              (140, 145, u'NameF + Name7',  0.4,  0),
                              (185, 190, u'NameG + Name8',  0.2,  1),
                              (185, 195, u'NameG + Name9',  0.2,  1),
                              (210, 215, u'Name10 + NameH', 0.45-5e-17, 1),
                              (215, 220, u'NameI + Name10', 0.25, 1),
                              (235, 240, u'NameJ + Name11', 0.1,  1),
                              (250, 254, u'Name12 + NameJ', 0.15+2e-17, 1),
                              (252, 258, u'NameK + Name12', 0.25, 1),
                              (256, 260, u'NameL + Name12', 0.2,  1),
                              (270, 275, u'Name13 + NameL', 0.1,  1)]}
                 ,
                {'fn':     genomic_manip.boolean.bool_or(),
                 'tracks': {'X': track_collections['Validation'][2]['path_sql'],
                            'Y': track_collections['Validation'][3]['path_sql']},

                 'expected': [( 10,  25, u'Name1 + NameA',          0.2, 0),
                              ( 30,  40, u'Name2 + NameB',          0.4, 1),
                              ( 50,  80, u'Name3 + NameC + Name4',  0.4, 1),
                              ( 90, 120, u'Name5 + NameD + Name6',  0.4, 1),
                              (125, 150, u'NameE + Name7 + NameF',  1.2+2e-16, 0),
                              (180, 200, u'Name8 + Name9 + NameG',  0.5, 1),
                              (205, 225, u'NameH + Name10 + NameI', 1.2, 1),
                              (230, 280, u'Name11 + NameJ + Name12 + NameK + NameL + Name13', 0.9-1e-16, 1),
                              (290, 300, u'Name14', 0.7, -1),
                              (310, 330, u'NameM',  0.3, 1)]}
                 ,
                {'fn':     genomic_manip.boolean.bool_xor(),
                 'input':  {'stop_val': 135},
                 'tracks': {'X1': [( 5,10,'GeneA1',0.0,-1),  (20,30,'GeneA2',0.0,0), (40,50,'GeneA3',0.0,1)],
                            'X2': [( 5,10,'GeneA1',0.0,-1),  (20,30,'GeneA2',0.0,0), (40,50,'GeneA3',0.0,1)],
                            'Y1': [(15,20,'GeneB1',0.0,0),   (25,35,'GeneB2',0.0,0), (45,65,'GeneB3',0.0,1)],
                            'Y2': [(15,20,'GeneB1',0.0,0),   (25,35,'GeneB2',0.0,0), (45,65,'GeneB3',0.0,1)]},
                 'expected': [(  5,  10, 'GeneA1',                    0.0, 0),
                              ( 15,  25, 'GeneB1 + GeneA2 + GeneB2',  0.0, 0),
                              ( 30,  35, 'GeneB1 + GeneA2 + GeneB2',           0.0, 0),
                              ( 40,  45, 'GeneA3 + GeneB3',           0.0, 0),
                              ( 50,  65, 'GeneA3 + GeneB3',           0.0, 0)]}
                 ]

        for t in tests: run_one(self, t)
Exemple #4
0
    def runTest(self):
        tests = [{'fn':    genomic_manip.scores.merge_scores(),
                 'input':  {'list_of_tracks': [[],[]]},
                 'expected': []}
                 ,
                {'fn':    genomic_manip.scores.merge_scores(),
                 'input':  {'list_of_tracks': [track_collections['Scores'][1]['path_sql'],
                                               track_collections['Scores'][2]['path_sql'],
                                               track_collections['Scores'][3]['path_sql']]},
                 'expected': [( 0,    5,    2.0 + 0.6666666666666666),
                              ( 5,   10,    4.0),
                              ( 20,  30,   10.0),
                              ( 30,  40,   30.0),
                              ( 40,  50,   26.0 + 0.666666666666666),
                              ( 50,  60,  120.0),
                              ( 60,  68,  100.0),
                              ( 68,  70,  200.0),
                              ( 70,  80,  100.0),
                              ( 90, 110,    3.0),
                              (120, 130,   10.0)]}
                ,
                {'fn':    genomic_manip.scores.merge_scores(),
                 'input':  {'geometric': True,
                            'list_of_tracks': [track_collections['Scores'][1]['path_sql'],
                                               track_collections['Scores'][2]['path_sql'],
                                               track_collections['Scores'][3]['path_sql']]},
                 'expected':  [(0,     5, 2.0),
                              ( 5,    10, 2.2894284851066637),
                              (20,    30, 3.1072325059538586),
                              (30,    40, 4.481404746557164),
                              (40,    50, 4.3088693800637667),
                              (50,    60, 7.1137866089801252),
                              (60,    68, 6.6943295008216941),
                              (68,    70, 8.4343266530174912),
                              (70,    80, 6.6943295008216941),
                              (90,   110, 2.0800838230519041),
                              (120,  130, 3.1072325059538586)]}
                ,
                {'fn':   genomic_manip.scores.mean_score_by_feature(),
                 'tracks': {'X': track_collections['Scores'    ][4]['path_sql'],
                            'Y': track_collections['Validation'][2]['path_sql']},
                 'input':   {},
                 'expected': [(10,   20, u'Name1',  15.0, -1),
                              (30,   40, u'Name2',  50.0, 1),
                              (50,   60, u'Name3',  30.0, 1),
                              (70,   80, u'Name4',  25.0, 1),
                              (90,  100, u'Name5',   8.0, 1),
                              (110, 120, u'Name6',   0.0, 1),
                              (130, 150, u'Name7',   1.0, -1),
                              (180, 190, u'Name8',   5.0, 1),
                              (180, 200, u'Name9',   8.0, 1),
                              (210, 220, u'Name10',  0.0, 1),
                              (230, 240, u'Name11',  0.0, 1),
                              (250, 260, u'Name12',  0.0, 1),
                              (270, 280, u'Name13',  0.0, 1),
                              (290, 300, u'Name14',  0.0, -1)]},
                {'fn':   genomic_manip.scores.threshold(),
                 'tracks': {'X': track_collections['Validation'][1]['path_sql']},
                 'fields': {'X': ['start', 'end', 'score', 'name']},
                 'input':  {'s': 4.0,
                            'in_type' : 'qualitative',
                            'out_type': 'qualitative'},
                 'expected': [( 0,   10,  10.0, u'Validation feature 1'),
                              (20,   30,  10.0, u'Validation feature 3'),
                              (40,   50,  10.0, u'Validation feature 6'),
                              (60,   70,  10.0, u'Validation feature 7'),
                              (70,   80,  10.0, u'Validation feature 8'),
                              (90,  100,  10.0, u'Validation feature 9'),
                              (90,  110,  10.0, u'Validation feature 10'),
                              (120, 130,  10.0, u'Validation feature 11'),
                              (125, 135,   5.0, u'Validation feature 12')]},
                 ]

        for t in tests: run_one(self, t)
Exemple #5
0
    def runTest(self):
        self.maxDiff = None

        tests  = [
                {'fn':     genomic_manip.standard.filter(),
                 'tracks': {'X': track_collections['Validation'][2]['path_sql'],
                            'Y': track_collections['Validation'][3]['path_sql']},
                 'expected': [( 10,  20, u'Name1',  0.1, -1),
                              ( 30,  40, u'Name2',  0.2, 1),
                              ( 90, 100, u'Name5',  0.0, 1),
                              (110, 120, u'Name6',  0.4, 1),
                              (130, 150, u'Name7',  0.4, -1),
                              (180, 190, u'Name8',  0.1, 1),
                              (180, 200, u'Name9',  0.1, 1),
                              (210, 220, u'Name10', 0.2, 1),
                              (230, 240, u'Name11', 0.1, 1),
                              (250, 260, u'Name12', 0.2, 1),
                              (270, 280, u'Name13', 0.0, 1)]}
                ,
                {'fn':     genomic_manip.standard.neighborhood(),
                 'input':  {'stop_val': 135, 'before_start':-2, 'after_end':2, 'in_type': 'qualitative'},
                 'tracks': {'X': track_collections['Validation'][1]['path_sql']},
                 'expected': [( 0,   12,  u'Validation feature 1',  10.0, 0),
                              ( 0,   10,  u'Validation feature 2',   0.0, 0),
                              (18,   32,  u'Validation feature 3',  10.0, 0),
                              (23,   32,  u'Validation feature 4',   0.0, 0),
                              (38,   47,  u'Validation feature 5',   0.0, 0),
                              (38,   52,  u'Validation feature 6',  10.0, 0),
                              (58,   72,  u'Validation feature 7',  10.0, 0),
                              (68,   82,  u'Validation feature 8',  10.0, 0),
                              (88,  102,  u'Validation feature 9',  10.0, 0),
                              (88,  112,  u'Validation feature 10', 10.0, 0),
                              (118, 132,  u'Validation feature 11', 10.0, 0),
                              (123, 135,  u'Validation feature 12',  5.0, 0)]}
                ,
                {'fn':     genomic_manip.standard.merge().quan,
                 'tracks': {'X': track_collections['Scores'][4]['path_sql']},
                 'expected': [( 10,  20,   15.0),
                              ( 25,  35,  100.0),
                              ( 45,  65,   30.0),
                              ( 72,  77,   50.0),
                              ( 85, 105,    8.0),
                              (120, 122, 9000.0),
                              (130, 131,   20.0),
                              (180, 183,   10.0),
                              (188, 193,   10.0),
                              (198, 200,   40.0)]}
                ,
                {'fn':     genomic_manip.standard.merge().quan,
                 'tracks': {'X': [(10, 40, 10.0), (40, 50, 20.0)]},
                 'expected': [(10, 50, 12.5)]}
                ,
                {'fn':     genomic_manip.standard.merge().qual,
                 'tracks': {'X': [( 10,  20, u'Name1',  1.0, 1),
                                  ( 10,  15, u'Name2',  1.0, 1),
                                  ( 17,  23, u'Name3',  1.0, 1),
                                  ( 50,  60, u'Name4',  1.0, -1),
                                  ( 70,  80, u'Name5',  1.0, -1),
                                  ( 72,  78, u'Name6',  1.0, 1)]},
                 'expected':     [( 10,  23, u'Name1 + Name2 + Name3',  3.0, 1),
                                  ( 50,  60, u'Name4',                  1.0, -1),
                                  ( 70,  80, u'Name5 + Name6',          2.0, 0)]}
                 ]

        for t in tests: run_one(self, t)