Exemplo n.º 1
0
    def __init__(self, obo_file, assoc_file, sql_conn, verbose=True):
        # load gene ontology with fastSemSim
        if verbose:
            print("loading gene ontology")
        self.go = fastSemSim.Ontology.ontologies.load(obo_file)

        # load annotation class with fastSemSim
        if verbose:
            print("creating annotation corpus")
        self.ac = AnnotationCorpus(self.go)

        # set parameters for accessions
        ac_params = {}
        # only keep go term and accession name in memory
        ac_params['simplify'] = True
        if verbose:
            print("parsing association file")
        self.ac.parse(assoc_file, "GOA")

        # check for consistency
        if not self.ac.isConsistent():
            raise Exception

        if verbose:
            print("loading gene associations")
        # TODO: might do this jointly with fastSemSim's associations
        # this load all HGNC gene -> GO term associations into memory
        self.assoc = self.load_go_associations(sql_conn)

        if verbose:
            print("creating BPscore object")
        # load the semantic similarity class for SimRel (Schlicker et al. 2006)
        # using the `max` function as mixer, resulting in an implementation
        # for the BPScore metric from Schlicker et al. 2006
        self.semsim_class = SetSemSim(self.go,
                                      self.ac,
                                      TSS="SimRel",
                                      MSS="max")