Skip to content

Graph API

Maël Kerbiriou edited this page Mar 29, 2017 · 2 revisions

Graph is the representation of a De Bruijn graph.

This short code snippet illustrates the use of the Graph API:

# we import pyGATB Graph
from gatb import Graph

# We will use a file containing a De Bruijn Graph stored
# in HDF5 format; file created using dbgh5 tool provided
# with GATB-Core. (This file is located next to this snippet)
F_NAME='../thirdparty/gatb-core/gatb-core/test/db/celegans_reads.h5'

# We create the graph
graph = Graph('-in %s' % F_NAME)

# We iterate over some nodes
for i, node in enumerate(graph):
    print('{}: {!r}'.format(i, node))
if i > 3: break

(Code snippet taken from here).

Output of this Pyhon3-pyGATB program is as follows:

Input is h5 or _gatb/ (we assume that kmer counting has already been done), we will complete it into a graph if necessary.
0: <Node k5 AAAAC F>
1: <Node k5 AAAAT F>
2: <Node k5 AAAAG F>
3: <Node k5 AAACA F>
4: <Node k5 AAACC F>

In turn, you can use the Node API to navigate through the graph.

You can review a deep use of Graph and Node APIs here.

You can’t perform that action at this time.