Beispiel #1
0
 def scores(self, id1, id2):
     """Returns the score between two given GO terms.
     :arg id1, identifier of a GO term (ie: GO:0043231, or whatever
         identifier is in your ontology).
     :arg id2, identifier of a GO term (ie: GO:0043229, or whatever
         identifier is in your ontology).
     """
     golib = PyGoLib(self.goterms)
     goterm1 = self.goterms[id1]
     path1 = golib.get_path(goterm1, pred=goterm1['id'], paths=[])
     goterm2 = self.goterms[id2]
     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