def test_lin_zero(self): self.simscore.register('lin', d.Lin) terms = make_terms() terms[0].information_content.omim = 0 terms[1].information_content.omim = 0 res = self.simscore(terms[0], terms[1], method='lin') assert res == 0.0, res
def test_jc2(self): self.simscore.register('jc2', d.JC2) terms = make_terms() terms[0].information_content.omim = 0.5 terms[1].information_content.omim = 0.7 # 1 - (0.5 + 0.7 - 1.8) res = self.simscore(terms[0], terms[1], method='jc2') assert res == 1.6, res
def test_lin(self): self.simscore.register('lin', d.Lin) terms = make_terms() terms[0].information_content.omim = 0.5 terms[1].information_content.omim = 0.7 # 1.8 / (0.5+0.7) = 1.5 res = self.simscore(terms[0], terms[1], method='lin') assert res == 1.5, res
def test_jc(self): self.simscore.register('jc', d.JC) terms = make_terms() terms[0].information_content.omim = 0.5 terms[1].information_content.omim = 0.7 # -1 / ((1 + 1.8) - 0.5 - 0.7) res = self.simscore(terms[0], terms[1], method='jc') assert res == -0.625, res
def test_resnik(self): self.simscore.register('resnik', d.Resnik) terms = make_terms() t1 = MagicMock() t1.common_ancestors = MagicMock(return_value=terms[0:3]) terms[0].information_content.omim = 0.5 terms[1].information_content.omim = 0.7 terms[2].information_content.omim = 0.6 res = self.simscore(t1, {}, method='resnik') assert res == 0.7
def setUp(self): items = make_terms() self.root = items[0] self.child_1_1 = items[1] self.child_1_2 = items[2] self.child_2_1 = items[3] self.child_3 = items[4] self.terms = Ontology(from_obo_file=False) self.terms._append(self.root) self.terms._append(self.child_1_1) self.terms._append(self.child_1_2) self.terms._append(self.child_2_1) self.terms._append(self.child_3) self.terms._connect_all()
def test_graphic(self): self.simscore.register('graphic', d.GraphIC) terms = make_terms() t1 = MagicMock() t1.common_ancestors = MagicMock(return_value=terms[2:4]) t1.all_parents = set(terms[0:4]) t2 = MagicMock() t2.all_parents = set(terms[3:5]) terms[0].information_content.omim = 0.5 terms[1].information_content.omim = 0.7 terms[2].information_content.omim = 0.6 terms[3].information_content.omim = 0.2 terms[4].information_content.omim = 0.1 # common: 0.6 + 0.2 => 0.8 # union: (0.5 + 0.7 + 0.6 + 0.2) + 0.1 => 2.1 res = self.simscore(t1, t2, method='graphic') assert int(res * 10_000) == 3809, res
def setUp(self): self.terms = mo.make_terms()