Exemplo n.º 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)
Exemplo n.º 2
0
    sys.exit()
if args.pub_filter and args.nspace is None:
    sys.stderr.write(
        "--When filtering by publication, must provide GO namespace.\n")
    sys.exit()

id_name = None
if args.idfile is not None:
    id_name = IDMap(args.idfile)

gene_ontology = OBO(args.obo)

logger.info('Populating gene associations')
if args.ass:
    gene_ontology.populate_annotations(args.ass,
                                       gene_col=args.gcol,
                                       term_col=args.term_col)
elif args.gmt:
    gmt = GMT(args.gmt)
    gene_ontology.populate_annotations_from_gmt(gmt)
else:
    sys.stderr.write(
        "--Provide gene annotations from an association file or a GMT file")
    exit()

if args.pub_filter:
    pub_counts = defaultdict(set)
    for (term_id, term) in gene_ontology.go_terms.iteritems():
        if term.namespace != args.nspace:
            continue
        for a in term.annotations:
Exemplo n.º 3
0
args = parser.parse_args()

if args.obo is None:
    sys.stderr.write("--obo file is required.\n")
    sys.exit()
if args.pub_filter and args.nspace is None:
    sys.stderr.write(
        "--When filtering by publication, must provide GO namespace.\n")
    sys.exit()

gene_ontology = OBO(args.obo)

logger.info('Populating gene associations')
if args.ass:
    gene_ontology.populate_annotations(args.ass,
                                       remote_location=args.remote_file,
                                       gene_col=args.gcol,
                                       term_col=args.term_col)
elif args.gmt:
    gmt = GMT(args.gmt)
    gene_ontology.populate_annotations_from_gmt(gmt)
else:
    sys.stderr.write(
        "--Provide gene annotations from an association file or a GMT file")
    exit()

if args.pub_filter:
    pub_counts = defaultdict(set)
    for (term_id, term) in gene_ontology.go_terms.iteritems():
        if term.namespace != args.nspace:
            continue
        for a in term.annotations: