booldog.io.interaction_networks

Read standard networks formats/objects (networkx, igraph, graphml, SIF) and convert to Boolean network.

Attributes

_IGRAPH_AVAILABLE

logger

Functions

networkx2interactions(g[, edge_type_key])

Convert a NetworkX Graph into a list of interactions.

igraph2interactions(g[, node_id_key, edge_type_key])

Convert an igraph Graph into a list of interactions.

read_interactions(interactions_input[, node_names])

Create Network from interactions (list)

read_sif(file[, delim, source_col, target_col, ...])

Reads in a SIF file of interactions

read_igraph(g[, node_id_key, edge_type_key, node_name_key])

Create BooleanNetwork from a igraph Graph object.

read_networkx(g[, edge_type_key, node_name_key])

Create BooleanNetwork from a networkx (Di)Graph object.

read_graphml(file[, edge_type_key, node_id_key, ...])

Extract relevant parts for a Boolean network from a graphml file.

Module Contents

booldog.io.interaction_networks._IGRAPH_AVAILABLE = True
booldog.io.interaction_networks.logger
booldog.io.interaction_networks.networkx2interactions(g, edge_type_key='interaction', **_)

Convert a NetworkX Graph into a list of interactions.

Parameters:
  • g (networkx.(Di)Graph) – The input graph object from the Networkx library. (Assumed to be directed.)

  • edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.

  • **_ (dict) – Additional keyword arguments (ignored).

Returns:

A list of (source, target, symbol) tuples, one per edge of g, where symbol is the value of the edge_type_key edge attribute.

Return type:

list of tuple

booldog.io.interaction_networks.igraph2interactions(g, node_id_key='name', edge_type_key='interaction')

Convert an igraph Graph into a list of interactions.

Parameters:
  • g (igraph.Graph) – The input graph object from the igraph library.

  • node_id_key (str, optional) – The vertex attribute key that contains the primary identifier to use for node identifiers. Default is “name”.

  • edge_type_key (str, optional) – The edge attribute key to use for interaction type (e.g., weight, type). Default is “interaction”.

Returns:

A list of (source, target, symbol) tuples, one per edge of g, where source/target are the node_id_key vertex attribute values of the edge’s endpoints, and symbol is the value of the edge_type_key edge attribute.

Return type:

list of tuple

booldog.io.interaction_networks.read_interactions(interactions_input, node_names=None, **kwargs)

Create Network from interactions (list)

Parameters:
  • interactions_input (list or str) – A list of interactions in the network. Each interaction should be a tuple of (source, target, sign), where source and target are node identifiers and sign is either activator_symbol or inhibitor_symbol. Or a path to a JSON file containing such a list of interactions.

  • activator_symbol (int, optional) – The value representing activation in the network. Default is 1.

  • inhibitor_symbol (int, optional) – The value representing inhibition in the network. Default is -1.

  • logic (LogicBuilder, optional) – An optional logic builder (see booldog.io.interaction_logic.LogicBuilder) used to construct each node’s update rule from its regulators. Default is SquadLogic.

  • **kwargs (dict) – Additional keyword arguments, forwarded to booldog.io.interaction_logic.interactions2rules.

Returns:

n – A BoolDogModel object representing the Boolean network.

Return type:

booldog.BoolDogModel

Notes

Uses SQUAD logic to obtain Boolean network.

booldog.io.interaction_networks.read_sif(file, delim='\t', source_col=0, target_col=1, interaction_col=2, header=True, activator_symbol='1', inhibitor_symbol='-1', **kwargs)

Reads in a SIF file of interactions

Parameters:
  • file (str) – Path to the SIF file

  • delim (str, optional) – Delimiter used in the SIF file (default=” “)

  • header (bool, optional) – If the first line of the file is a header (default=True)

  • source_col (int or str, optional) – Column index (if int) or column name (if str) of source node (default=0)

  • target_col (int or str, optional) – Column index (if int) or column name (if str) of target node (default=1)

  • interaction_col (int, optional) – Column index (if int) or column name (if str) of interaction type (symbol) (default=2)

  • activator_symbol (int or str, optional) – Symbol of activation edges in interaction_col, compared against the (string) values read from the file. Default is "1" (a string, matching the fact that values parsed from the file are always strings).

  • inhibitor_symbol (int or str, optional) – Symbol of inhibition edges in interaction_col. Default is "-1" (see activator_symbol).

  • logic (LogicBuilder, optional) – An optional logic builder (see booldog.io.interaction_logic.LogicBuilder) used to construct each node’s update rule from its regulators. Default is SquadLogic.

  • **kwargs (dict) – Additional keyword arguments, forwarded to booldog.io.interaction_logic.interactions2rules.

Returns:

n – A BoolDogModel object representing the Boolean network.

Return type:

booldog.BoolDogModel

Notes

Uses SQUAD logic by default (see logic) to obtain the Boolean network.

booldog.io.interaction_networks.read_igraph(g, node_id_key='name', edge_type_key='interaction', node_name_key='name', **kwargs)

Create BooleanNetwork from a igraph Graph object.

Parameters:
  • g (igraph.Graph) – The input graph object from the igraph library.

  • node_id_key (str, optional) – The vertex attribute key that contains the primary identifier used for each node. Default is “name”.

  • node_name_key (str, optional) – The vertex attribute key that contains the node name (e.g. display label). Default is “name”.

  • edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.

  • activator_symbol (int or str, optional) – Value of activation edges in edge_type_key of g, compared against the raw attribute value. Default is 1 (int, from interactions2rules).

  • inhibitor_symbol (int or str, optional) – Value of inhibition edges in edge_type_key of g. Default is -1 (see activator_symbol).

  • logic (LogicBuilder, optional) – An optional logic builder (see booldog.io.interaction_logic.LogicBuilder) used to construct each node’s update rule from its regulators. Default is SquadLogic.

  • **kwargs (dict) – Additional keyword arguments, forwarded to booldog.io.interaction_logic.interactions2rules.

Returns:

n – A BoolDogModel object representing the Boolean network.

Return type:

booldog.BoolDogModel

Notes

Uses SQUAD logic by default (see logic) to obtain the Boolean network.

booldog.io.interaction_networks.read_networkx(g, edge_type_key='interaction', node_name_key='name', **kwargs)

Create BooleanNetwork from a networkx (Di)Graph object.

Parameters:
  • g (networkx.(Di)Graph) – The input graph object from the networkx library.

  • edge_type_key (str, optional) – The edge attribute key to use for interaction values (e.g., weight, type). Default is “interaction”.

  • activator_symbol (int or str, optional) – Value of activation edges in edge_type_key of g, compared against the raw attribute value. Default is 1 (int, from interactions2rules).

  • inhibitor_symbol (int or str, optional) – Value of inhibition edges in edge_type_key of g. Default is -1 (see activator_symbol).

  • node_name_key (str, optional) – The node attribute key that contains the node name (display label). Default is “name”.

  • logic (LogicBuilder, optional) – An optional logic builder (see booldog.io.interaction_logic.LogicBuilder) used to construct each node’s update rule from its regulators. Default is SquadLogic.

  • **kwargs (dict) – Additional keyword arguments, forwarded to both networkx2interactions (which ignores unrecognized keys) and booldog.io.interaction_logic.interactions2rules.

Returns:

n – A BoolDogModel object representing the Boolean network.

Return type:

booldog.BoolDogModel

Notes

Uses SQUAD logic by default (see logic) to obtain the Boolean network.

booldog.io.interaction_networks.read_graphml(file, edge_type_key='interaction', node_id_key='name', node_name_key='name', yEd_labels=False, yEd_arrow_head=False, use_labels=True, **kwargs)

Extract relevant parts for a Boolean network from a graphml file.

Since graphml is not well defined for Boolean networks (or even standard for interaction networks), this read functionality has limited support.

Parameters:
  • file (str) – Path to the graphml file

  • edge_type_key (str, optional) – The edge attribute key to use for interaction type (e.g., weight, type). Default is “interaction”. Only used if yEd_arrow_head is False (yEd uses the arrow head symbol instead).

  • node_id_key (str, optional) – The vertex attribute key that contains the primary identifier used for each node. Default is “name”. If this attribute is missing from the file, the igraph-assigned “id” attribute is used instead (with a warning logged).

  • node_name_key (str, optional) – The vertex attribute key that contains the node name (e.g. display label). Default is “name”. If this attribute is missing (and differs from node_id_key), node names fall back to node_id_key (with a warning logged).

  • yEd_labels (bool, optional) – If graphml file originates as a yEd export, the node attribute “y:NodeLabel” is used to determine node names (default=False)

  • yEd_arrow_head (bool, optional) – If graphml file originates as a yEd export, the edge attribute “y:Arrows” is used to determine interaction type (default=False)

  • use_labels (bool, optional) – Accepted for future use but currently unused by this function. Default is True.

  • activator_symbol (int or str, optional) – Symbol or value of activation edges. If yEd_arrow_head is True, default is “standard” (the yEd arrow-head symbol for a plain arrow), else default is 1.

  • inhibitor_symbol (int or str, optional) – Symbol or value of inhibition edges. If yEd_arrow_head is True, default is “t_shape” (the yEd arrow-head symbol for a T-bar), else default is -1.

  • **kwargs (dict) – Additional keyword arguments. Only activator_symbol and inhibitor_symbol are read from this dict (see above); any other keys (e.g. a custom logic builder) are ignored, since, unlike the other read_* functions, read_graphml does not forward **kwargs on to interactions2rules.

Returns:

n – A BoolDogModel object representing the Boolean network.

Return type:

booldog.BoolDogModel

Notes

Uses igraph to parse the graphml file, and extracts node and edge attributes to determine interactions. Always uses the default SQUAD logic (booldog.io.interaction_logic.SquadLogic) to build rules.

If yEd_label=True, it also parses the yEd-specific attributes to extract node labels (y:NodeLabel) for node names.

If yEd_arrow_head=True, it parses the yEd-specific edge arrow types (arrow head symbols of y:Arrows) to determine interaction types (activation/inhibition).