def testAddDOTermAnnotations(self):
        do_obo_file = 'test_files/DO/test_do_obo_file.obo'
        doid_omim_dict = process_do.build_doid_omim_dict(do_obo_file)

        mim2gene_file = 'test_files/DO/test_mim2gene.csv'
        genemap_file = 'test_files/DO/test_genemap.csv'
        mim2entrez_dict = process_do.build_mim2entrez_dict(mim2gene_file)
        mim_diseases = process_do.build_mim_diseases_dict(genemap_file,
                                                          mim2entrez_dict)

        process_do.add_do_term_annotations(
            doid_omim_dict, self.disease_ontology, mim_diseases)

        # We know from testBuildOmimDict above that this is the only
        # one with OMIM xrefs
        doid = 'DOID:9970'
        do_term = self.disease_ontology.get_term(doid)

        annot_dict = {}

        for annotation in do_term.annotations:
            if annotation.gid not in annot_dict:
                annot_dict[annotation.gid] = []
            else:
                annot_dict[annotation.gid].append(annotation.ref)

        desired_annots = {4160: [], 8431: [], 51738: [], 5443: [],
                          5468: [], 6492: []}

        self.assertEqual(annot_dict, desired_annots)
    def testBuildOmimDict(self):
        do_obo_file = 'test_files/DO/test_do_obo_file.obo'

        doid_omim_dict = process_do.build_doid_omim_dict(do_obo_file)

        # Only one of the DO terms in the test DO OBO file has an
        # OMIM xref
        desired_output = {'DOID:9970': set(['601665'])}

        self.assertEqual(doid_omim_dict, desired_output)
    def testCreateDOAbstractTitle(self):
        do_obo_file = 'test_files/DO/test_do_obo_file.obo'
        doid_omim_dict = process_do.build_doid_omim_dict(do_obo_file)

        # We know from testBuildOmimDict above that this is the only
        # one with OMIM xrefs
        doid = 'DOID:9970'
        do_term = self.disease_ontology.get_term(doid)

        abstract = process_do.create_do_term_abstract(do_term, doid_omim_dict)
        desired_abstract = ' Annotations from child terms in the disease ' + \
            'ontology are propagated through transitive closure. ' + \
            'Annotations directly to this term are provided by the OMIM' + \
            ' disease ID 601665. Only annotations with confidence labeled' + \
            ' C or P by OMIM have been added.'
        self.assertEqual(abstract, desired_abstract)