Cytoscape networks (indra.assemblers.cx.assembler)

class indra.assemblers.cx.assembler.CxAssembler(stmts=None, network_name=None)[source]

This class assembles a CX network from a set of INDRA Statements.

The CX format is an aspect oriented data mode for networks. The format is defined at http://www.home.ndexbio.org/data-model/. The CX format is the standard for NDEx and is compatible with CytoScape via the CyNDEx plugin.

Parameters:
  • stmts (Optional[list[indra.statements.Statement]]) – A list of INDRA Statements to be assembled.
  • network_name (Optional[str]) – The name of the network to be assembled. Default: indra_assembled
statements

A list of INDRA Statements to be assembled.

Type:list[indra.statements.Statement]
network_name

The name of the network to be assembled.

Type:str
cx

The structure of the CX network that is assembled.

Type:dict
add_statements(stmts)[source]

Add INDRA Statements to the assembler’s list of statements.

Parameters:stmts (list[indra.statements.Statement]) – A list of indra.statements.Statement to be added to the statement list of the assembler.
make_model(add_indra_json=True)[source]

Assemble the CX network from the collected INDRA Statements.

This method assembles a CX network from the set of INDRA Statements. The assembled network is set as the assembler’s cx argument.

Parameters:add_indra_json (Optional[bool]) – If True, the INDRA Statement JSON annotation is added to each edge in the network. Default: True
Returns:cx_str – The json serialized CX model.
Return type:str
print_cx(pretty=True)[source]

Return the assembled CX network as a json string.

Parameters:pretty (bool) – If True, the CX string is formatted with indentation (for human viewing) otherwise no indentation is used.
Returns:json_str – A json formatted string representation of the CX network.
Return type:str
save_model(file_name='model.cx')[source]

Save the assembled CX network in a file.

Parameters:file_name (Optional[str]) – The name of the file to save the CX network to. Default: model.cx
set_context(cell_type)[source]

Set protein expression data and mutational status as node attribute

This method uses indra.databases.context_client to get protein expression levels and mutational status for a given cell type and set a node attribute for proteins accordingly.

Parameters:cell_type (str) – Cell type name for which expression levels are queried. The cell type name follows the CCLE database conventions. Example: LOXIMVI_SKIN, BT20_BREAST
upload_model(ndex_cred=None, private=True, style='default')[source]

Creates a new NDEx network of the assembled CX model.

To upload the assembled CX model to NDEx, you need to have a registered account on NDEx (http://ndexbio.org/) and have the ndex python package installed. The uploaded network is private by default.

Parameters:
  • ndex_cred (Optional[dict]) – A dictionary with the following entries: ‘user’: NDEx user name ‘password’: NDEx password
  • private (Optional[bool]) – Whether or not the created network will be private on NDEX.
  • style (Optional[str]) – This optional parameter can either be (1) The UUID of an existing NDEx network whose style should be applied to the new network. (2) Unspecified or ‘default’ to use the default INDRA-assembled network style. (3) None to not set a network style.
Returns:

network_id – The UUID of the NDEx network that was created by uploading the assembled CX model.

Return type:

str

class indra.assemblers.cx.assembler.NiceCxAssembler(stmts=None, network_name=None)[source]

Assembles a Nice CX network from a set of INDRA Statements.

Parameters:
  • stmts (Optional[list[indra.statements.Statement]]) – A list of INDRA Statements to be assembled.
  • network_name (Optional[str]) – The name of the network to be assembled. Default: indra_assembled
network

A Nice CX network object that is assembled from Statements.

Type:ndex2.nice_cx_network.NiceCXNetwork
add_edge(a1_id, a2_id, stmt)[source]

Add a Statement to the network as an edge.

add_node(agent)[source]

Add an Agent to the network as a node.

make_model(self_loops=False, network_attributes=None)[source]

Return a Nice CX network object after running assembly.

Parameters:
  • self_loops (Optional[bool]) – If False, self-loops are excluded from the network. Default: False
  • network_attributes (Optional[dict]) – A dictionary containing attributes to be added to the assembled network.
Returns:

The assembled Nice CX network.

Return type:

ndex2.nice_cx_network.NiceCXNetwork

print_model()[source]

Return the CX string of the assembled model.