linchemin.cgu.translate.translator¶
- linchemin.cgu.translate.translator(input_format: str, original_graph: MonopartiteReacSynGraph | MonopartiteMolSynGraph | BipartiteSynGraph | DiGraph | Dot | list | dict | Iron, output_format: str, out_data_model: str) MonopartiteReacSynGraph | BipartiteSynGraph | MonopartiteMolSynGraph | DiGraph | Dot | Iron | None[source]¶
To translate an input graph from a format/data model to another one
Parameters:¶
- input_format: str
The format of the input graph object
original_graph: Union[MonopartiteReacSynGraph, MonopartiteMolSynGraph, BipartiteSynGraph, nx.classes.digraph.DiGraph, pydot.Dot, list, dict, Iron]
The input graph
- output_format: str
The desired output format
- out_data_model: str
The desired type of output graph (monopartite, bipartite…)
Returns:¶
out_graph: Union[MonopartiteReacSynGraph, BipartiteSynGraph, MonopartiteMolSynGraph, nx.DiGraph, pydot.Dot, Iron, None]
The output graph
Raises:¶
UnavailableTranslation: if the selected translation is not available
Example:¶
>>> graph = json.loads(open('ibm_file.json').read()) >>> nx_graph = translator('ibm_retro', graph[1], 'networkx', out_data_model='monopartite_molecules')