Пример #1
0
class TestLabels(unittest.TestCase):

    def setUp(self):
        self.go = OBO('files/test_data/go.obo')
        self.go.populate_annotations(GO_URL, remote_location=True)

        self.dsrepair_term = self.go.get_term(DSREPAIR_ID)

        lines = open('files/go_neg_slim.txt').readlines()
        self.slim_terms = set([l.strip() for l in lines])

    def testOntoLabelsNeg(self):
        ol = OntoLabels(obo=self.go, slim_terms=self.slim_terms)

        (pos, neg) = ol.get_labels(DSREPAIR_ID)
        self.assertTrue(len(pos) > 0)
        self.assertEqual(pos,set(self.dsrepair_term.get_annotated_genes()))

        similar_term = self.go.get_term(DNA_REP_ID).get_annotated_genes()

        slim_overlap = self.go.get_ancestors(DNA_REP_ID) & \
            self.go.get_ancestors(DSREPAIR_ID) & \
            self.slim_terms

        self.assertTrue(DNA_METAB in slim_overlap)
        self.assertTrue(len(neg & set(similar_term)) == 0)

        for dterm in self.go.get_descendents(DNA_METAB):
            dgenes = set(self.go.get_term(dterm).get_annotated_genes())
            self.assertTrue(len(neg & dgenes) == 0)
Пример #2
0
for (tissue, stds) in tissue_std_edges.iteritems():
    c3 = tissue_std_edges[tissue]['0']
    for c3_edge in list(c3):
        # Limit negative edges to positive genes
        if len(c3_edge & tissue_all_pos) < 2:
            c3.remove(c3_edge)

for (tissue, stds) in tissue_std_edges.iteritems():
    c1 = tissue_std_edges[tissue]['1']
    c1_g = reduce(frozenset.union, c1)
    c1_tspc = c1_g - ubiq

    c3 = tissue_std_edges[tissue]['0']
    c3_g = reduce(frozenset.union, c3)
    c3_tspc = c3_g - ubiq

    c2 = within_edges_pos - c1
    c4 = within_edges_neg - c3
    if onto:
        for dtissue in onto.get_descendents(tissue):
            if dtissue in tissue_std_edges:
                c2 -= tissue_std_edges[dtissue]['1']
                c4 -= tissue_std_edges[dtissue]['0']
        for atissue in onto.get_ancestors(tissue):
            if atissue in tissue_std_edges:
                c2 -= tissue_std_edges[atissue]['1']
                c4 -= tissue_std_edges[atissue]['0']

    print tissue, len(c1_tspc), len(c1), len(c2), len(c3), len(c4)