ecoli.analysis.causality_network.build_network

BuildNetwork

Constructs a network representations of simulation components from sim_data, and generates files for node lists and edge lists.

Adding new nodes to the network:

To add a new type of nodes to the network (either a state or process), you need to write a new function within this file (build_network.py), which goes through all of the instances of the new node type, and for each instance creates a node:

new_node = Node()

adds attributes (**attr), which include “node_class”, “node_type”, “node_id”, “name”, and “synonyms”:

new_node.read_attributes(**attr)

and appends the node to the node list:

self.node_list.append(new_node)

The relevant edges that connect the new node to other nodes also need to be specified:

new_edge = Edge("Edge Type")

The source and destination ids for that edge are added with an attribute:

attr = {
        'src_id': source_id,
        'dst_id': destination_id,
        }

new_edge.read_attributes(**attr)

and the edge is then added to the edge list:

self.edge_list.append(new_edge)

With a complete node and edge list, you are ready to add dynamics data to each node. This is done in read_dynamics.py. You first need to choose appropriate dynamics data to represents that node’s activity, and make sure it is saved in a listener. read_dynamics.py uses saved listener output to load dynamics into each node.

read_dynamics.py might require a new function to the dynamics data if it is of a new node type, specified in the TYPE_TO_READER_FUNCTION dictionary. When the node list is read, nodes of the new type will be passed into the new function, which assigns that node dynamics from listener output:

node.read_dynamics(dynamics, dynamics_units)
class ecoli.analysis.causality_network.build_network.BuildNetwork(sim_data_file, output_dir, check_sanity=False)[source]

Bases: object

Constructs a causality network of simulation components, namely states and processes, of a whole-cell simulation using sim_data. Writes two files (node list and edge list) that are subsequently used by the dynamics reader to extract simulation results, and for the visual representation of the network.

TODO: have check_sanity looks for disconnected nodes, and edges with non-existent nodes.

Parameters:
  • sim_data_file – path to the variant sim_data pickle file used for building the network.

  • output_dir – output directory for the node list and edge list files.

  • check_sanity – if set to True, checks if there are any nodes with duplicate IDs in the network.

_add_complexation_and_complexes()[source]

Add complexation process nodes and complex state nodes to the node list, and edges connected to the complexation nodes to the edge list.

_add_equilibrium()[source]

Add equilibrium nodes to the node list, and add edges connected to the equilibrium nodes to the edge list.

_add_genes()[source]

Add gene state nodes to the node list.

_add_global_nodes()[source]

Add global state nodes to the node list.

_add_metabolism_and_metabolites()[source]

Add metabolism process nodes and metabolite state nodes to the node list, add edges connected to the metabolism nodes to the edge list. Note: forward and reverse reactions are represented as separate nodes.

_add_regulation()[source]

Add regulation nodes with to the node list, and add edges connected to the regulation nodes to the edge list.

_add_rna_maturation_and_mature_transcripts()[source]

Add RNA maturation process nodes and mature transcript state nodes to the node list, and edges connected to these nodes to the edge list.

_add_transcription_and_transcripts()[source]

Add transcription process nodes and transcript state nodes to the node list, and edges connected to the transcription nodes to the edge list.

_add_translation_and_monomers()[source]

Add translation process nodes and protein (monomer) state nodes to the node list, and edges connected to the translation nodes to the edge list.

_append_edge(type_, src, dst, stoichiometry='')[source]

Helper function for appending new nodes to the network.

Parameters:
_build_network()[source]

Add nodes and edges to the node/edge lists, and check for network sanity (optional).

_edge_list()[source]
_find_duplicate_nodes()[source]

Identify nodes that have duplicate IDs.

_node_list()[source]
_remove_hanging_edges()[source]

Remove edges that are not connected to existing nodes.

_write_files()[source]

Write node/edge list as separate .tsv files.

_write_json()[source]

Write node and edge lists as json files.

build_nodes_and_edges()[source]

Build the network and return the node and edge lists.

run()[source]

Build the network and write node/edge list files.

ecoli.analysis.causality_network.build_network.URL_TEMPLATE_COMPOUND = 'https://ecocyc.org/compound?orgid=ECOLI&id={0}'

The following groups of molecules participate in multiple processes and are thus identified here to prevent the addition of duplicate nodes.

Note

Identifying multi-process participatory molecules in this way is not required because –check_sanity checks for duplicate nodes. However, identifying such molecules here can streamline network building by eliminating the need to search through nodes that were added previously.

ecoli.analysis.causality_network.build_network.molecule_compartment(molecule)[source]