Beispiel #1
0
    def test_serialization(self):
        a = HPOSet.from_queries([
            'Test child level 1-1', 'Test child level 2-1',
            'Test child level 4'
        ])
        self.assertEqual(a.serialize(), '11+21+41')

        self.assertEqual(HPOSet.from_serialized('11+21+41'), a)
Beispiel #2
0
 def test_omim_enrichment(self):
     hposet = HPOSet.from_queries('HP:0007401,HP:0010885'.split(','))
     res = self.omim_model.enrichment('hypergeom', hposet)
     self.assertIsInstance(res, list)
     self.assertIn('item', res[0])
     self.assertIn('count', res[0])
     self.assertIn('enrichment', res[0])
     self.assertIsInstance(res[0]['item'], an.OmimDisease)
     self.assertIsInstance(res[0]['count'], int)
     self.assertIsInstance(res[0]['enrichment'], float)
Beispiel #3
0
    def test_set(self):
        full_set = HPOSet.from_queries([int(x) for x in self.terms])

        self.assertEqual(len(full_set), len(self.terms))

        phenoterms = full_set.remove_modifier()
        self.assertLess(len(phenoterms), len(full_set))
        self.assertGreater(len(phenoterms), 0)

        self.assertIn(self.terms[5], full_set)

        self.assertNotIn(self.terms[5], phenoterms)
Beispiel #4
0
    def test_remove_modifier(self):
        terms = mo.make_ontology_with_modifiers()

        normal_term_ids = set([1, 11, 12, 21, 31, 41, 13])
        modifier_term_ids = set([5, 12823, 5000001, 5000002, 5100001])

        self.assertEqual(len(terms),
                         (len(normal_term_ids | modifier_term_ids)))

        full_set = HPOSet.from_queries(normal_term_ids | modifier_term_ids)

        self.assertEqual(len(full_set),
                         len(normal_term_ids | modifier_term_ids))

        set_2 = full_set.remove_modifier()
        self.assertEqual(len(set_2), len(normal_term_ids))

        self.assertEqual((normal_term_ids | modifier_term_ids),
                         {int(x)
                          for x in full_set})

        self.assertEqual(normal_term_ids, {int(x) for x in set_2})
Beispiel #5
0
 def test_set_from_queries(self):
     a = HPOSet.from_queries([
         'Test child level 1-1', 'Test child level 2-1',
         'Test child level 4'
     ])
     assert len(a) == 3