示例#1
0
        for goterm in gene1:
            sim1 = sim1 + self.__get_go_score(goterm, gene2)
        sim2 = 0
        for goterm in gene2:
            sim2 = sim2 + self.__get_go_score(goterm, gene1)
        score = (sim1 + sim2) / (len(gene1) + len(gene2))
        return score


if __name__ == '__main__':
    from oboio import OboIO
    from src import download_go_graph

    OBIO = OboIO()
    ONTO = download_go_graph()
    TERMS = OBIO.get_graph(ONTO)

    # G-Sesame GO example
    GSGO = GsesameGO(TERMS)
    print 'GO:0043229 semantic value:', GSGO.semantic_value('GO:0043229')
    print 'GO:0043231 semantic value:', GSGO.semantic_value('GO:0043231')
    print 'Score for: GO:0043229 - GO:0043231:', \
        GSGO.scores('GO:0043229', 'GO:0043231')

    # G-Sesame Gene example
    GSGENE = GsesameGene(TERMS)
    GENE1 = [
        'GO:0004022', 'GO:0004024', 'GO:0004174', 'GO:0046872', 'GO:0008270',
        'GO:0004023'
    ]
    GENE2 = [
示例#2
0
        sim1 = 0
        for goterm in gene1:
            sim1 = sim1 + self.__get_go_score(goterm, gene2)
        sim2 = 0
        for goterm in gene2:
            sim2 = sim2 + self.__get_go_score(goterm, gene1)
        score = (sim1 + sim2) / (len(gene1) + len(gene2))
        return score

if __name__ == '__main__':
    from oboio import OboIO
    from src import download_go_graph

    OBIO = OboIO()
    ONTO = download_go_graph()
    TERMS = OBIO.get_graph(ONTO)

    # G-Sesame GO example
    GSGO = GsesameGO(TERMS)
    print 'GO:0043229 semantic value:', GSGO.semantic_value('GO:0043229')
    print 'GO:0043231 semantic value:', GSGO.semantic_value('GO:0043231')
    print 'Score for: GO:0043229 - GO:0043231:', \
        GSGO.scores('GO:0043229', 'GO:0043231')

    # G-Sesame Gene example
    GSGENE = GsesameGene(TERMS)
    GENE1 = ['GO:0004022', 'GO:0004024', 'GO:0004174', 'GO:0046872',
             'GO:0008270', 'GO:0004023']
    GENE2 = ['GO:0009055', 'GO:0005515', 'GO:0046872', 'GO:0008270',
             'GO:0020037']
    print 'Semantic similarities between the two genes:', \
示例#3
0
        path2 = golib.get_path(goterm2, pred=goterm2['id'], paths=[])
        # We use goterm['id'] instead of the id provided to take into
        # account alt_id which are in the list of goterms but not in the
        # paths. Via goterm['id'] we get the 'normal' GO term identifier.
        scores = self.__score_parents(goterm1['id'], goterm2['id'], path1,
                                      path2)
        if scores:
            score = min(scores)
            self.log.debug("%s and %s are parents" % (id1, id2))
            return (score, score)
        else:
            score = self.__score_cousins(goterm1['id'], goterm2['id'], path1,
                                         path2)
            return score


if __name__ == '__main__':
    from oboio import OboIO
    GDC = GoDistanceCounter()
    GOFILE = '../tests/test.obo'

    OBIO = OboIO()
    TERMS = OBIO.get_graph(GOFILE)
    GDC = GoDistanceCounter(TERMS)
    #gdc.get_biological_process()
    #print "%s terms found in the biological process branch" % \
    #len(self.biological_process.keys())
    #outputfile =  'geneontology_biological_process-%s.obo' % \
    #datetime.datetime.now().strftime('%Y%m%d')
    #write_down_ontology(self.biological_process, outputfile)