예제 #1
0
 def _propagate_go_term_ancestors(self, mapping):
     """Given a mapping object which maps entities to GO terms, this
     method ensures that all the ancestor terms of each GO term
     appear at the respective entities. Returns a copy of the mapping
     which contains these modifications."""
     result = bidict(mapping)
     for entity, terms in result.iteritems_left():
         ancestors = self.tree.ancestors(*terms)
         result.add_left_multi(entity, ancestors)
     return result
예제 #2
0
 def _propagate_go_term_ancestors(self, mapping):
     """Given a mapping object which maps entities to GO terms, this
     method ensures that all the ancestor terms of each GO term
     appear at the respective entities. Returns a copy of the mapping
     which contains these modifications."""
     result = bidict(mapping)
     for entity, terms in result.iteritems_left():
         ancestors = self.tree.ancestors(*terms)
         result.add_left_multi(entity, ancestors)
     return result
예제 #3
0
    def read_goa_file(self, goa_file, ev_codes):
        """Reads the GOA file, return a defaultdict that,
        for each protein id it has a set of strings with the
        associated GO terms
        """
        d = bidict()
        for line in open_anything(goa_file):
            if not line.startswith(("!", "#")):
                # split line, obtain protein_id, go_term, and ev_code
                fields = line.split("\t", 7)
                prot_id, goterm, evcode = fields[1], fields[4], fields[6]

                if evcode in ev_codes:
                    d.add_left(prot_id, self.go_tree.lookup(goterm))
        self.log.info("GOA file read. " + str(d.len_left()) + " proteins loaded")
        return d
예제 #4
0
    def read_goa_file(self, goa_file, ev_codes):
        """Reads the GOA file, return a defaultdict that,
        for each protein id it has a set of strings with the
        associated GO terms
        """
        goa_mapping = bidict()
        for line in open_anything(goa_file):
            if not line.startswith(("!", "#")):
                # split line, obtain protein_id, go_term, and ev_code
                fields = line.split("\t", 7)
                prot_id, goterm, evcode = fields[1], fields[4], fields[6]

                if evcode in ev_codes:
                    goa_mapping.add_left(prot_id, self.go_tree.lookup(goterm))
        self.log.info("GOA file read. %s proteins loaded",
                      str(goa_mapping.len_left()))
        return goa_mapping