Lightweight python module to load, validate and visualize CWL (Common Workflow Language) files through networkx graphs.
Project description
CWL2Nx
Lightweight python module to load, validate and visualize CWL (Common Workflow Language) files through networkx graphs. It uses cwl_utils for parsing and validation.
Installation
pip install cwl2nx
Example Usage
You will find an example of workflow in the GitHub repository : workflow_example.cwl.yaml
Straightforward conversion
from cwl2nx import CWLToNetworkxConnector
dir = "workflow_example.cwl.yaml"
dag = CWLToNetworkxConnector(dir).convert_to_networkx() # dag is networkx.DiGraph
print(dag.nodes, dag.edges)
Basic networkx display
Once .cwl is loaded in networkx, you can use any visualization tool to display the dag.
from cwl2nx import CWLToNetworkxConnector
import networkx as nx
import matplotlib.pyplot as plt
dir = "workflow_example.cwl.yaml"
connector = CWLToNetworkxConnector(dir)
dag = connector.convert_to_networkx(datasets_as_nodes=True)
nx.draw_networkx(dag)
plt.show()
Using visualization libraries
You'll need to install
dagvizbefore
Run the cell below in a notebook
from cwl2nx import CWLToNetworkxConnector
import networkx as nx
import dagviz
dir = "workflow_example.cwl.yaml"
connector = CWLToNetworkxConnector(dir)
dag = connector.convert_to_networkx()
dagviz.Dagre(dag)
dagviz.Metro(dag) # github tree dag style
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cwl2nx-0.0.6.tar.gz
(8.7 kB
view details)
File details
Details for the file cwl2nx-0.0.6.tar.gz.
File metadata
- Download URL: cwl2nx-0.0.6.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59094319a6dd76b6e6a9a2c8af2b8b35d63b50708a5559ccb7364aa9a3cd362b
|
|
| MD5 |
83102fbcc8a4db62ca6a9339e80b2d9a
|
|
| BLAKE2b-256 |
5444f4b6a6584e886d606357baa1143c3e06ad4c19ca9b14af70a9d00713c31f
|