GFANetwork: NetworkX compatibility for GFA graphs#

class gfagraphs.nx.GFANetwork#

Abstract class for visualization and modelization of GFA in a NetworkX object

Returns

Methods are static and should be used passing arguments.

Return type

None

static compute_backbone(graph: Graph) DiGraph#

Computes a networkx representation of the graph, for computing purposes. This backbone contains the exact information of paths, nodes, edges… that is described in the loaded structure. Allows to use every method of networkx library on the graph to perform traversal, neighborhood…

Parameters

graph (Graph) – a gfa graph loaded in memory using this library

Returns

a networkx object, in the form of a directed graph.

Return type

DiGraph

static compute_networkx(graph: Graph, enforce_format: gfagraphs.abstractions.GFAFormat | None = None, node_prefix: str | None = None, node_size_classes: tuple[list] = ([0, 1], [2, 10], [11, 50], [51, 200], [201, 500], [501, 1000], [1001, 10000], [10001, inf]), start_stop_ref: tuple | bool = False) MultiDiGraph#

Computes the networkx representation of the GFA. This function is intended to be used for graphical representation purposes, and not for computing metrics on the graph.

Parameters
  • graph (Graph) – a gfa graph loaded in memory using this library

  • node_prefix (str | None, optional) – a name to put before every node, by default None

  • node_size_classes (tuple[list], optional) – classes of size for coloring nodes, by default ( [0, 1], [2, 10], [11, 50], [51, 200], [201, 500], [ 501, 1000], [1001, 10000], [10001, float(‘inf’)] )

  • start_stop_ref (tuple | bool, optional) – defines starting and ending offset on the reference, by default False

Returns

a networkx object, in the form of a bidirected graph.

Return type

MultiDiGraph

get_most_external_nodes() list[str]#

Get nodes that are on the edges of the graph (starting and ending nodes) Those are characterized by their in/out degree : one of those has to be 0.

Returns

nodes matching the criterion.

Return type

list[str]

gfagraphs.nx.get_palette(number_of_colors: int, cmap_name: str = 'viridis', as_hex: bool = False) list#

Returns a number_of_colors-sized palette, as a list, that one can access with colors[i].

Args:

number_of_colors (int): number of colors needed cmap_name (str, optionnal) : name of the matplotlib colormap. Defaults to viridis. hex (bool) : specifies if colors shall be returned by rgb values (False, default) or hex (True)

Returns:

list: palette of colors