SciPy

tethne.writers.graph module

Write NetworkX graphs to structured and unstructured network file formats.

Many methods simply invoke equivalent methods in NetworkX.

to_gexf(graph, output_path) Writes graph to GEXF.
to_graphml(graph, path[, encoding, prettyprint]) Writes graph to GraphML.
to_sif(graph, output_path) Generates Simple Interaction Format output file from provided graph.
class tethne.writers.graph.TethneGraphMLWriter(graph=None, encoding='utf-8', prettyprint=True)[source]

Bases: networkx.readwrite.graphml.GraphMLWriter

get_key(name, attr_type, scope, default)[source]

Modified to use attribute name as key, rather than numeric ID.

tethne.writers.graph.to_gexf(graph, output_path)[source]

Writes graph to GEXF.

Uses the NetworkX method write_gexf.

Parameters:

graph : networkx.Graph

The Graph to be exported to GEXF.

output_path : str

Full path, including filename (without suffix). e.g. using ”./graphFolder/graphFile” will result in a GEXF file at ./graphFolder/graphFile.gexf.

tethne.writers.graph.to_graphml(graph, path, encoding='utf-8', prettyprint=True)[source]

Writes graph to GraphML.

Uses the NetworkX method write_graphml.

Parameters:

graph : networkx.Graph

The Graph to be exported to GraphML.

output_path : str

Full path, including filename (without suffix). e.g. using ”./graphFolder/graphFile” will result in a GraphML file at ./graphFolder/graphFile.graphml.

tethne.writers.graph.to_sif(graph, output_path)[source]

Generates Simple Interaction Format output file from provided graph.

The SIF specification is described here.

to_sif() will generate a .sif file describing the network, and a few .eda and .noa files containing edge and node attributes, respectively. These are equivalent to tab-delimited tables, and can be imported as such in Cytoscape 3.0.

Parameters:

graph : networkx.Graph

The Graph to be exported to SIF.

output_path : str

Full path, including filename (without suffix). e.g. using ”./graphFolder/graphFile” will result in a SIF file at ./graphFolder/graphFile.sif, and corresponding .eda and .noa files.

tethne.writers.graph.to_table(graph, path)[source]