Ejemplo n.º 1
0
Archivo: go.py Proyecto: kkaris/pypath
def annotate(graph, organism=9606, aspects=('C', 'F', 'P')):
    """
    Adds Gene Ontology annotations to the nodes of a graph.
    
    :param igraph.Graph graph:
        Any ``igraph.Graph`` object with uniprot IDs
        in its ``name`` vertex attribute.
    """

    aspects = aspects if type(aspects) in {list, tuple} else (aspects, )

    graph.vs['go'] = [{
        'C': set(),
        'F': set(),
        'P': set()
    } for _ in xrange(graph.vcount())]

    terms, annot = dataio.go_annotations_goa(organism=organism)

    prg = progress.Progress(graph.vcount(), 'Loading GO annotations', 9)

    for v in graph.vs:

        prg.step()

        for asp in aspects:

            if v['name'] in annot[asp]:

                v['go'][asp] = annot[asp][v['name']]

    prg.terminate()
Ejemplo n.º 2
0
    def __init__(self, organism=9606, ontology=None):
        """
        For one organism loads Gene Ontology annotations, in addition it
        accepts or creates a ``GeneOntology`` object.
        """

        self.ontology = ontology or GeneOntology()

        annot = dataio.go_annotations_goa(organism=organism)
        self.c = annot['C']
        self.f = annot['F']
        self.p = annot['P']

        self._ancestors_annotate()
        self._merge_annotations()
Ejemplo n.º 3
0
Archivo: go.py Proyecto: kkaris/pypath
    def __init__(
        self,
        organism=9606,
        ontology=None,
        pickle_file=None,
        use_pickle_cache=True,
    ):
        """
        For one organism loads Gene Ontology annotations, in addition it
        accepts or creates a ``GeneOntology`` object.
        """

        session_mod.Logger.__init__(self, name='go')

        self.organism = organism
        self._pickle_file = pickle_file
        self._use_pickle_cache = use_pickle_cache

        if self._pickle_cache_load_hook():

            return

        self.ontology = ontology or GeneOntology()

        self._log('Populating Gene Ontology: '
                  'annotations for organism `%u`.' % organism)

        annot = dataio.go_annotations_goa(organism=organism)
        self.c = annot['C']
        self.f = annot['F']
        self.p = annot['P']

        self._ancestors_annotate()
        self._merge_annotations()

        self._pickle_cache_save_hook()
Ejemplo n.º 4
0
 def test_go_annotations_goa(self):
     
     goa = dataio.go_annotations_goa()
     
     assert 'GO:0043235' in goa['C']['P00533']