napistu 0.3.7__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {napistu-0.3.7 → napistu-0.4.0}/PKG-INFO +2 -2
- {napistu-0.3.7 → napistu-0.4.0}/setup.cfg +2 -2
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/__main__.py +8 -4
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/constants.py +28 -35
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/napistu_edgelist.py +4 -4
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/matching/interactions.py +41 -39
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/gaps.py +2 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/constants.py +61 -45
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/data_handling.py +1 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/neighborhoods.py +3 -3
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/net_create.py +440 -616
- napistu-0.4.0/src/napistu/network/net_create_utils.py +734 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/net_propagation.py +1 -1
- napistu-0.3.7/src/napistu/network/napistu_graph_core.py → napistu-0.4.0/src/napistu/network/ng_core.py +57 -15
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/ng_utils.py +28 -21
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/paths.py +4 -4
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/precompute.py +35 -74
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/sbml_dfs_utils.py +46 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/utils.py +80 -5
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/PKG-INFO +2 -2
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/SOURCES.txt +4 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/requires.txt +1 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/conftest.py +102 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_data_handling.py +5 -2
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_net_create.py +92 -201
- napistu-0.4.0/src/tests/test_network_net_create_utils.py +538 -0
- napistu-0.4.0/src/tests/test_network_ng_core.py +19 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_ng_utils.py +1 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_precompute.py +4 -3
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_rpy2_callr.py +0 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_rpy2_init.py +0 -1
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_sbml_dfs_utils.py +45 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_utils.py +26 -2
- {napistu-0.3.7 → napistu-0.4.0}/LICENSE +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/README.md +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/pyproject.toml +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/setup.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/consensus.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/context/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/context/discretize.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/context/filtering.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/gcs/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/gcs/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/gcs/downloads.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/gcs/utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/identifiers.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/indices.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/bigg.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/gtex.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/hpa.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/identifiers_etl.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/obo.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/psi_mi.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/reactome.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/sbml.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/string.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/trrust.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ingestion/yeast.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/matching/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/matching/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/matching/mount.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/matching/species.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/__main__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/client.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/codebase.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/codebase_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/component_base.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/config.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/documentation.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/documentation_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/execution.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/health.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/profiles.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/server.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/tutorials.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/tutorials_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/mcp/utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/curation.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/pathwayannot.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/modify/uncompartmentalize.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/network/ig_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/dogma.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/genodexito.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/mygene.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/ontologies/renaming.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/rpy2/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/rpy2/callr.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/rpy2/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/rpy2/rids.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/sbml_dfs_core.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/scverse/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/scverse/constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/scverse/loading.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu/source.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/dependency_links.txt +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/entry_points.txt +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/napistu.egg-info/top_level.txt +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_consensus.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_constants.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_context_discretize.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_context_filtering.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_curation.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_data/__init__.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_gaps.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_gcs.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_identifiers.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_indices.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_ingestion_napistu_edgelist.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_ingestion_obo.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_matching_interactions.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_matching_mount.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_matching_species.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_mcp_config.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_mcp_documentation_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_mcp_server.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_ig_utils.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_neighborhoods.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_net_propagation.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_network_paths.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_ontologies_genodexito.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_ontologies_mygene.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_ontologies_renaming.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_pathwayannot.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_sbml.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_sbml_dfs_core.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_sbo.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_scverse_loading.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_set_coverage.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_source.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/test_uncompartmentalize.py +0 -0
- {napistu-0.3.7 → napistu-0.4.0}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: napistu
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.4.0
|
4
4
|
Summary: Connecting high-dimensional data to curated pathways
|
5
5
|
Home-page: https://github.com/napistu/napistu-py
|
6
6
|
Author: Sean Hackett
|
@@ -27,6 +27,7 @@ Requires-Dist: mygene<4.0.0,>=3.0.0
|
|
27
27
|
Requires-Dist: numpy<3.0.0,>=1.24.0
|
28
28
|
Requires-Dist: pandas<3.0.0,>=1.5.0
|
29
29
|
Requires-Dist: pydantic<3.0.0,>=2.0.0
|
30
|
+
Requires-Dist: pyarrow<20.0.0,>=15.0.0
|
30
31
|
Requires-Dist: python-libsbml
|
31
32
|
Requires-Dist: requests>=2.25.0
|
32
33
|
Requires-Dist: scipy<2.0.0,>=1.10.0
|
@@ -51,7 +52,6 @@ Requires-Dist: markdown>=3.4.0; extra == "mcp"
|
|
51
52
|
Requires-Dist: jupyter-client>=7.0.0; extra == "mcp"
|
52
53
|
Requires-Dist: nbformat>=5.0.0; extra == "mcp"
|
53
54
|
Provides-Extra: rpy2
|
54
|
-
Requires-Dist: pyarrow<19.0.0,>=15.0.0; extra == "rpy2"
|
55
55
|
Requires-Dist: rpy2<4.0.0,>=3.5.0; extra == "rpy2"
|
56
56
|
Requires-Dist: rpy2-arrow<1.0.0,>=0.1.0; extra == "rpy2"
|
57
57
|
Provides-Extra: scverse
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[metadata]
|
2
2
|
name = napistu
|
3
|
-
version = 0.
|
3
|
+
version = 0.4.0
|
4
4
|
description = Connecting high-dimensional data to curated pathways
|
5
5
|
long_description = file: README.md
|
6
6
|
long_description_content_type = text/markdown
|
@@ -33,6 +33,7 @@ install_requires =
|
|
33
33
|
numpy>=1.24.0,<3.0.0
|
34
34
|
pandas>=1.5.0,<3.0.0
|
35
35
|
pydantic>=2.0.0,<3.0.0
|
36
|
+
pyarrow>=15.0.0,<20.0.0
|
36
37
|
python-libsbml
|
37
38
|
requests>=2.25.0
|
38
39
|
scipy>=1.10.0,<2.0.0
|
@@ -69,7 +70,6 @@ mcp =
|
|
69
70
|
jupyter-client>=7.0.0
|
70
71
|
nbformat>=5.0.0
|
71
72
|
rpy2 =
|
72
|
-
pyarrow>=15.0.0,<19.0.0
|
73
73
|
rpy2>=3.5.0,<4.0.0
|
74
74
|
rpy2-arrow>=0.1.0,<1.0.0
|
75
75
|
scverse =
|
@@ -621,7 +621,11 @@ def exporter():
|
|
621
621
|
"--format", "-f", default="pickle", help="Output format: gml, edgelist, pickle"
|
622
622
|
)
|
623
623
|
@click.option(
|
624
|
-
"--
|
624
|
+
"--wiring_approach",
|
625
|
+
"-g",
|
626
|
+
type=str,
|
627
|
+
default="bipartite",
|
628
|
+
help="bipartite or regulatory",
|
625
629
|
)
|
626
630
|
@click.option(
|
627
631
|
"--weighting_strategy",
|
@@ -645,7 +649,7 @@ def export_igraph(
|
|
645
649
|
output_uri: str,
|
646
650
|
graph_attrs_spec_uri: str | None,
|
647
651
|
format: str,
|
648
|
-
|
652
|
+
wiring_approach: str,
|
649
653
|
weighting_strategy: str,
|
650
654
|
directed: bool,
|
651
655
|
reverse: bool,
|
@@ -663,7 +667,7 @@ def export_igraph(
|
|
663
667
|
reaction_graph_attrs=graph_attrs_spec,
|
664
668
|
directed=directed,
|
665
669
|
edge_reversed=reverse,
|
666
|
-
|
670
|
+
wiring_approach=wiring_approach,
|
667
671
|
weighting_strategy=weighting_strategy,
|
668
672
|
verbose=True,
|
669
673
|
)
|
@@ -753,7 +757,7 @@ def export_precomputed_distances(
|
|
753
757
|
weights_vars=weights_vars_list,
|
754
758
|
)
|
755
759
|
|
756
|
-
|
760
|
+
utils.save_parquet(precomputed_distances, output_uri)
|
757
761
|
|
758
762
|
|
759
763
|
@exporter.command(name="export_smbl_dfs_tables")
|
@@ -198,22 +198,7 @@ BQB = SimpleNamespace(
|
|
198
198
|
UNKNOWN="BQB_UNKNOWN",
|
199
199
|
)
|
200
200
|
|
201
|
-
VALID_BQB_TERMS =
|
202
|
-
BQB.IS,
|
203
|
-
BQB.HAS_PART,
|
204
|
-
BQB.IS_PART_OF,
|
205
|
-
BQB.IS_VERSION_OF,
|
206
|
-
BQB.HAS_VERSION,
|
207
|
-
BQB.IS_HOMOLOG_TO,
|
208
|
-
BQB.IS_DESCRIBED_BY,
|
209
|
-
BQB.IS_ENCODED_BY,
|
210
|
-
BQB.ENCODES,
|
211
|
-
BQB.OCCURS_IN,
|
212
|
-
BQB.HAS_PROPERTY,
|
213
|
-
BQB.IS_PROPERTY_OF,
|
214
|
-
BQB.HAS_TAXON,
|
215
|
-
BQB.UNKNOWN,
|
216
|
-
]
|
201
|
+
VALID_BQB_TERMS = list(BQB.__dict__.values())
|
217
202
|
|
218
203
|
# molecules are distinctly defined by these BQB terms
|
219
204
|
BQB_DEFINING_ATTRS = [BQB.IS, BQB.IS_HOMOLOG_TO]
|
@@ -266,6 +251,7 @@ SBOTERM_NAMES = SimpleNamespace(
|
|
266
251
|
CATALYST="catalyst",
|
267
252
|
INHIBITOR="inhibitor",
|
268
253
|
STIMULATOR="stimulator",
|
254
|
+
MODIFIED="modified",
|
269
255
|
MODIFIER="modifier",
|
270
256
|
INTERACTOR="interactor",
|
271
257
|
)
|
@@ -274,22 +260,27 @@ MINI_SBO_TO_NAME = {
|
|
274
260
|
"SBO:0000010": SBOTERM_NAMES.REACTANT,
|
275
261
|
"SBO:0000011": SBOTERM_NAMES.PRODUCT,
|
276
262
|
"SBO:0000013": SBOTERM_NAMES.CATALYST,
|
277
|
-
"SBO:0000020": SBOTERM_NAMES.INHIBITOR,
|
278
|
-
"SBO:0000459": SBOTERM_NAMES.STIMULATOR,
|
279
263
|
"SBO:0000019": SBOTERM_NAMES.MODIFIER,
|
264
|
+
"SBO:0000020": SBOTERM_NAMES.INHIBITOR,
|
280
265
|
"SBO:0000336": SBOTERM_NAMES.INTERACTOR,
|
266
|
+
"SBO:0000459": SBOTERM_NAMES.STIMULATOR,
|
267
|
+
"SBO:0000644": SBOTERM_NAMES.MODIFIED,
|
281
268
|
}
|
282
269
|
|
283
270
|
MINI_SBO_FROM_NAME = {
|
284
|
-
SBOTERM_NAMES.REACTANT: "SBO:0000010",
|
285
|
-
SBOTERM_NAMES.PRODUCT: "SBO:0000011",
|
286
271
|
SBOTERM_NAMES.CATALYST: "SBO:0000013",
|
287
272
|
SBOTERM_NAMES.INHIBITOR: "SBO:0000020",
|
288
|
-
SBOTERM_NAMES.STIMULATOR: "SBO:0000459",
|
289
|
-
SBOTERM_NAMES.MODIFIER: "SBO:0000019", # parent category of inhibitor and stimulator (i.e., activator)
|
290
273
|
SBOTERM_NAMES.INTERACTOR: "SBO:0000336", # entity participating in a physical or functional interaction
|
274
|
+
SBOTERM_NAMES.MODIFIED: "SBO:0000644",
|
275
|
+
SBOTERM_NAMES.MODIFIER: "SBO:0000019", # parent category of inhibitor and stimulator (i.e., activator)
|
276
|
+
SBOTERM_NAMES.PRODUCT: "SBO:0000011",
|
277
|
+
SBOTERM_NAMES.REACTANT: "SBO:0000010", # aka substrate
|
278
|
+
SBOTERM_NAMES.STIMULATOR: "SBO:0000459", # aka activator
|
291
279
|
}
|
292
280
|
|
281
|
+
VALID_SBO_TERM_NAMES = list(SBOTERM_NAMES.__dict__.values())
|
282
|
+
VALID_SBO_TERMS = list(MINI_SBO_FROM_NAME.values())
|
283
|
+
|
293
284
|
SBO_MODIFIER_NAMES = {
|
294
285
|
SBOTERM_NAMES.INHIBITOR,
|
295
286
|
SBOTERM_NAMES.STIMULATOR,
|
@@ -297,13 +288,14 @@ SBO_MODIFIER_NAMES = {
|
|
297
288
|
}
|
298
289
|
|
299
290
|
MINI_SBO_NAME_TO_POLARITY = {
|
300
|
-
SBOTERM_NAMES.REACTANT: "activation",
|
301
|
-
SBOTERM_NAMES.PRODUCT: "activation",
|
302
291
|
SBOTERM_NAMES.CATALYST: "activation",
|
303
292
|
SBOTERM_NAMES.INHIBITOR: "inhibition",
|
304
|
-
SBOTERM_NAMES.STIMULATOR: "activation",
|
305
|
-
SBOTERM_NAMES.MODIFIER: "ambiguous",
|
306
293
|
SBOTERM_NAMES.INTERACTOR: "ambiguous",
|
294
|
+
SBOTERM_NAMES.MODIFIED: "ambiguous",
|
295
|
+
SBOTERM_NAMES.MODIFIER: "ambiguous",
|
296
|
+
SBOTERM_NAMES.PRODUCT: "activation",
|
297
|
+
SBOTERM_NAMES.REACTANT: "ambiguous",
|
298
|
+
SBOTERM_NAMES.STIMULATOR: "activation",
|
307
299
|
}
|
308
300
|
|
309
301
|
# how does changing a reactions' membership
|
@@ -321,6 +313,7 @@ SBO_NAME_TO_ROLE = {
|
|
321
313
|
SBOTERM_NAMES.CATALYST: SBO_ROLES_DEFS.REQUIRED,
|
322
314
|
SBOTERM_NAMES.INHIBITOR: SBO_ROLES_DEFS.OPTIONAL,
|
323
315
|
SBOTERM_NAMES.STIMULATOR: SBO_ROLES_DEFS.OPTIONAL,
|
316
|
+
SBOTERM_NAMES.MODIFIED: SBO_ROLES_DEFS.DEFINING,
|
324
317
|
SBOTERM_NAMES.MODIFIER: SBO_ROLES_DEFS.OPTIONAL,
|
325
318
|
}
|
326
319
|
|
@@ -338,7 +331,7 @@ VALID_SBO_ROLES = (
|
|
338
331
|
|
339
332
|
# required variables for the edgelist formats used by the matching subpackage
|
340
333
|
# also used in some network modules
|
341
|
-
|
334
|
+
NAPISTU_EDGELIST = SimpleNamespace(
|
342
335
|
S_ID_UPSTREAM="s_id_upstream",
|
343
336
|
S_ID_DOWNSTREAM="s_id_downstream",
|
344
337
|
SC_ID_UPSTREAM="sc_id_upstream",
|
@@ -352,18 +345,18 @@ CPR_EDGELIST = SimpleNamespace(
|
|
352
345
|
)
|
353
346
|
|
354
347
|
IDENTIFIER_EDGELIST_REQ_VARS = {
|
355
|
-
|
356
|
-
|
348
|
+
NAPISTU_EDGELIST.IDENTIFIER_UPSTREAM,
|
349
|
+
NAPISTU_EDGELIST.IDENTIFIER_DOWNSTREAM,
|
357
350
|
}
|
358
351
|
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
352
|
+
NAPISTU_EDGELIST_REQ_VARS = {
|
353
|
+
NAPISTU_EDGELIST.S_ID_UPSTREAM,
|
354
|
+
NAPISTU_EDGELIST.S_ID_DOWNSTREAM,
|
355
|
+
NAPISTU_EDGELIST.SC_ID_UPSTREAM,
|
356
|
+
NAPISTU_EDGELIST.SC_ID_DOWNSTREAM,
|
364
357
|
}
|
365
358
|
|
366
|
-
|
359
|
+
NAPISTU_PATH_REQ_VARS = {NAPISTU_EDGELIST.SC_ID_ORIGIN, NAPISTU_EDGELIST.SC_ID_DEST}
|
367
360
|
|
368
361
|
FEATURE_ID_VAR_DEFAULT = "feature_id"
|
369
362
|
|
@@ -20,9 +20,9 @@ def remove_reciprocal_interactions(
|
|
20
20
|
|
21
21
|
Args:
|
22
22
|
edgelist (pd.DataFrame): edgelist (pd.DataFrame): edgelist where the first two
|
23
|
-
|
23
|
+
columns are assumed to be the edge vertices
|
24
24
|
extra_defining_vars (list): list (which can be empty) of variables which define
|
25
|
-
|
25
|
+
a unique interaction beyond the vertices
|
26
26
|
|
27
27
|
Returns:
|
28
28
|
indegenerate_edgelist (pd.DataFrame): edgelist with B-A edges removed and A-B retained
|
@@ -58,9 +58,9 @@ def count_fraction_of_reciprocal_interactions(
|
|
58
58
|
|
59
59
|
Args:
|
60
60
|
edgelist (pd.DataFrame): edgelist (pd.DataFrame): edgelist where the first two
|
61
|
-
|
61
|
+
columns are assumed to be the edge vertices
|
62
62
|
extra_defining_vars (list): list (which can be empty) of variables which define
|
63
|
-
|
63
|
+
a unique interaction beyond the vertices
|
64
64
|
|
65
65
|
Returns:
|
66
66
|
fraction (float): fraction of A-B edges which are also included as B-A edges
|
@@ -10,9 +10,9 @@ from napistu import utils
|
|
10
10
|
from napistu import sbml_dfs_core
|
11
11
|
from napistu.matching.species import features_to_pathway_species
|
12
12
|
from napistu.constants import (
|
13
|
-
|
13
|
+
NAPISTU_EDGELIST_REQ_VARS,
|
14
14
|
IDENTIFIER_EDGELIST_REQ_VARS,
|
15
|
-
|
15
|
+
NAPISTU_EDGELIST,
|
16
16
|
SBML_DFS,
|
17
17
|
IDENTIFIERS,
|
18
18
|
)
|
@@ -56,8 +56,8 @@ def edgelist_to_pathway_species(
|
|
56
56
|
"""
|
57
57
|
|
58
58
|
required_vars_distinct_features = {
|
59
|
-
|
60
|
-
|
59
|
+
NAPISTU_EDGELIST.IDENTIFIER_UPSTREAM,
|
60
|
+
NAPISTU_EDGELIST.IDENTIFIER_DOWNSTREAM,
|
61
61
|
}
|
62
62
|
missing_required_vars_distinct_features = (
|
63
63
|
required_vars_distinct_features.difference(
|
@@ -76,8 +76,8 @@ def edgelist_to_pathway_species(
|
|
76
76
|
distinct_identifiers = (
|
77
77
|
pd.concat(
|
78
78
|
[
|
79
|
-
formatted_edgelist[
|
80
|
-
formatted_edgelist[
|
79
|
+
formatted_edgelist[NAPISTU_EDGELIST.IDENTIFIER_UPSTREAM],
|
80
|
+
formatted_edgelist[NAPISTU_EDGELIST.IDENTIFIER_DOWNSTREAM],
|
81
81
|
]
|
82
82
|
)
|
83
83
|
.drop_duplicates()
|
@@ -99,16 +99,16 @@ def edgelist_to_pathway_species(
|
|
99
99
|
edges_on_pathway = formatted_edgelist.merge(
|
100
100
|
features_on_pathway[[SBML_DFS.S_ID, IDENTIFIERS.IDENTIFIER]].rename(
|
101
101
|
{
|
102
|
-
SBML_DFS.S_ID:
|
103
|
-
IDENTIFIERS.IDENTIFIER:
|
102
|
+
SBML_DFS.S_ID: NAPISTU_EDGELIST.S_ID_UPSTREAM,
|
103
|
+
IDENTIFIERS.IDENTIFIER: NAPISTU_EDGELIST.IDENTIFIER_UPSTREAM,
|
104
104
|
},
|
105
105
|
axis=1,
|
106
106
|
)
|
107
107
|
).merge(
|
108
108
|
features_on_pathway[[SBML_DFS.S_ID, IDENTIFIERS.IDENTIFIER]].rename(
|
109
109
|
{
|
110
|
-
SBML_DFS.S_ID:
|
111
|
-
IDENTIFIERS.IDENTIFIER:
|
110
|
+
SBML_DFS.S_ID: NAPISTU_EDGELIST.S_ID_DOWNSTREAM,
|
111
|
+
IDENTIFIERS.IDENTIFIER: NAPISTU_EDGELIST.IDENTIFIER_DOWNSTREAM,
|
112
112
|
},
|
113
113
|
axis=1,
|
114
114
|
)
|
@@ -159,15 +159,15 @@ def edgelist_to_scids(
|
|
159
159
|
|
160
160
|
# expand from s_ids to sc_ids
|
161
161
|
s_id_pairs = edges_on_pathway[
|
162
|
-
[
|
162
|
+
[NAPISTU_EDGELIST.S_ID_UPSTREAM, NAPISTU_EDGELIST.S_ID_DOWNSTREAM]
|
163
163
|
].drop_duplicates()
|
164
164
|
sc_id_pairs = s_id_pairs.merge(
|
165
165
|
sbml_dfs.compartmentalized_species[[SBML_DFS.S_ID]]
|
166
166
|
.reset_index()
|
167
167
|
.rename(
|
168
168
|
{
|
169
|
-
SBML_DFS.S_ID:
|
170
|
-
SBML_DFS.SC_ID:
|
169
|
+
SBML_DFS.S_ID: NAPISTU_EDGELIST.S_ID_UPSTREAM,
|
170
|
+
SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_UPSTREAM,
|
171
171
|
},
|
172
172
|
axis=1,
|
173
173
|
)
|
@@ -176,8 +176,8 @@ def edgelist_to_scids(
|
|
176
176
|
.reset_index()
|
177
177
|
.rename(
|
178
178
|
{
|
179
|
-
SBML_DFS.S_ID:
|
180
|
-
SBML_DFS.SC_ID:
|
179
|
+
SBML_DFS.S_ID: NAPISTU_EDGELIST.S_ID_DOWNSTREAM,
|
180
|
+
SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_DOWNSTREAM,
|
181
181
|
},
|
182
182
|
axis=1,
|
183
183
|
)
|
@@ -232,7 +232,7 @@ def filter_to_direct_mechanistic_interactions(
|
|
232
232
|
)
|
233
233
|
|
234
234
|
# reduce to distinct sc_id pairs
|
235
|
-
sc_id_pairs = edgelist_w_scids[list(
|
235
|
+
sc_id_pairs = edgelist_w_scids[list(NAPISTU_EDGELIST_REQ_VARS)].drop_duplicates()
|
236
236
|
|
237
237
|
# define all existing direct regulatory interactions
|
238
238
|
pathway_interactions = pd.concat(
|
@@ -241,36 +241,36 @@ def filter_to_direct_mechanistic_interactions(
|
|
241
241
|
sbml_dfs.reaction_species[
|
242
242
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] == 0
|
243
243
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]]
|
244
|
-
.rename({SBML_DFS.SC_ID:
|
244
|
+
.rename({SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_UPSTREAM}, axis=1)
|
245
245
|
.merge(
|
246
246
|
sbml_dfs.reaction_species[
|
247
247
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] < 0
|
248
248
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]].rename(
|
249
|
-
{SBML_DFS.SC_ID:
|
249
|
+
{SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_DOWNSTREAM}, axis=1
|
250
250
|
)
|
251
251
|
),
|
252
252
|
# pair <0 -> >0 # substrates affect products
|
253
253
|
sbml_dfs.reaction_species[
|
254
254
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] < 0
|
255
255
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]]
|
256
|
-
.rename({SBML_DFS.SC_ID:
|
256
|
+
.rename({SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_UPSTREAM}, axis=1)
|
257
257
|
.merge(
|
258
258
|
sbml_dfs.reaction_species[
|
259
259
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] > 0
|
260
260
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]].rename(
|
261
|
-
{SBML_DFS.SC_ID:
|
261
|
+
{SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_DOWNSTREAM}, axis=1
|
262
262
|
)
|
263
263
|
),
|
264
264
|
# pair 0 -> >0 # modifiers affect products
|
265
265
|
sbml_dfs.reaction_species[
|
266
266
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] == 0
|
267
267
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]]
|
268
|
-
.rename({SBML_DFS.SC_ID:
|
268
|
+
.rename({SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_UPSTREAM}, axis=1)
|
269
269
|
.merge(
|
270
270
|
sbml_dfs.reaction_species[
|
271
271
|
sbml_dfs.reaction_species[SBML_DFS.STOICHIOMETRY] > 0
|
272
272
|
][[SBML_DFS.R_ID, SBML_DFS.SC_ID]].rename(
|
273
|
-
{SBML_DFS.SC_ID:
|
273
|
+
{SBML_DFS.SC_ID: NAPISTU_EDGELIST.SC_ID_DOWNSTREAM}, axis=1
|
274
274
|
)
|
275
275
|
),
|
276
276
|
]
|
@@ -282,16 +282,16 @@ def filter_to_direct_mechanistic_interactions(
|
|
282
282
|
.merge(
|
283
283
|
sbml_dfs.species[SBML_DFS.S_NAME]
|
284
284
|
.to_frame()
|
285
|
-
.rename({SBML_DFS.S_NAME:
|
286
|
-
left_on=
|
285
|
+
.rename({SBML_DFS.S_NAME: NAPISTU_EDGELIST.S_NAME_UPSTREAM}, axis=1),
|
286
|
+
left_on=NAPISTU_EDGELIST.S_ID_UPSTREAM,
|
287
287
|
right_index=True,
|
288
288
|
# add species metadata for matches
|
289
289
|
)
|
290
290
|
.merge(
|
291
291
|
sbml_dfs.species[SBML_DFS.S_NAME]
|
292
292
|
.to_frame()
|
293
|
-
.rename({SBML_DFS.S_NAME:
|
294
|
-
left_on=
|
293
|
+
.rename({SBML_DFS.S_NAME: NAPISTU_EDGELIST.S_NAME_DOWNSTREAM}, axis=1),
|
294
|
+
left_on=NAPISTU_EDGELIST.S_ID_DOWNSTREAM,
|
295
295
|
right_index=True,
|
296
296
|
# add metadata for reactions where interaction occurs
|
297
297
|
)
|
@@ -305,11 +305,11 @@ def filter_to_direct_mechanistic_interactions(
|
|
305
305
|
edgelist_w_direct_mechanistic_interactions = edgelist_w_scids.merge(
|
306
306
|
direct_edge_interactions[
|
307
307
|
[
|
308
|
-
|
309
|
-
|
308
|
+
NAPISTU_EDGELIST.SC_ID_UPSTREAM,
|
309
|
+
NAPISTU_EDGELIST.SC_ID_DOWNSTREAM,
|
310
310
|
SBML_DFS.R_ID,
|
311
|
-
|
312
|
-
|
311
|
+
NAPISTU_EDGELIST.S_NAME_UPSTREAM,
|
312
|
+
NAPISTU_EDGELIST.S_NAME_DOWNSTREAM,
|
313
313
|
SBML_DFS.R_NAME,
|
314
314
|
]
|
315
315
|
]
|
@@ -369,23 +369,25 @@ def filter_to_indirect_mechanistic_interactions(
|
|
369
369
|
edgelist_w_scids = paths._filter_paths_by_precomputed_distances(
|
370
370
|
edgelist_w_scids.rename(
|
371
371
|
{
|
372
|
-
|
373
|
-
|
372
|
+
NAPISTU_EDGELIST.SC_ID_UPSTREAM: NAPISTU_EDGELIST.SC_ID_ORIGIN,
|
373
|
+
NAPISTU_EDGELIST.SC_ID_DOWNSTREAM: NAPISTU_EDGELIST.SC_ID_DEST,
|
374
374
|
},
|
375
375
|
axis=1,
|
376
376
|
),
|
377
377
|
precomputed_distances,
|
378
378
|
).rename(
|
379
379
|
{
|
380
|
-
|
381
|
-
|
380
|
+
NAPISTU_EDGELIST.SC_ID_ORIGIN: NAPISTU_EDGELIST.SC_ID_UPSTREAM,
|
381
|
+
NAPISTU_EDGELIST.SC_ID_DEST: NAPISTU_EDGELIST.SC_ID_DOWNSTREAM,
|
382
382
|
},
|
383
383
|
axis=1,
|
384
384
|
)
|
385
385
|
|
386
386
|
# find paths from 1 upstream to all desired downstream sc_ids
|
387
387
|
# (this is the convention with igraph)
|
388
|
-
indexed_origin_vertices = edgelist_w_scids.set_index(
|
388
|
+
indexed_origin_vertices = edgelist_w_scids.set_index(
|
389
|
+
NAPISTU_EDGELIST.SC_ID_UPSTREAM
|
390
|
+
)
|
389
391
|
|
390
392
|
# loop through upstream cspecies and find paths to all downstream species
|
391
393
|
global_dict = dict()
|
@@ -410,7 +412,7 @@ def filter_to_indirect_mechanistic_interactions(
|
|
410
412
|
sbml_dfs,
|
411
413
|
origin=an_origin_index,
|
412
414
|
# find all unique destinations (as a list for compatibility with igraph dest)
|
413
|
-
dest=origin_targets[
|
415
|
+
dest=origin_targets[NAPISTU_EDGELIST.SC_ID_DOWNSTREAM].unique().tolist(),
|
414
416
|
weight_var=NAPISTU_GRAPH_EDGES.WEIGHTS,
|
415
417
|
)
|
416
418
|
|
@@ -483,7 +485,7 @@ def filter_to_indirect_mechanistic_interactions(
|
|
483
485
|
|
484
486
|
indirect_shortest_paths = edgelist_w_scids.merge(
|
485
487
|
all_shortest_paths,
|
486
|
-
left_on=[
|
488
|
+
left_on=[NAPISTU_EDGELIST.SC_ID_UPSTREAM, NAPISTU_EDGELIST.SC_ID_DOWNSTREAM],
|
487
489
|
right_on=[NAPISTU_GRAPH_EDGES.FROM, NAPISTU_GRAPH_EDGES.TO],
|
488
490
|
)
|
489
491
|
|
@@ -498,9 +500,9 @@ def _edgelist_to_scids_if_needed(
|
|
498
500
|
) -> pd.DataFrame:
|
499
501
|
"""Map a set of edgelist species to cspecies or skip if cspecies were provided."""
|
500
502
|
|
501
|
-
if utils.match_pd_vars(edgelist,
|
503
|
+
if utils.match_pd_vars(edgelist, NAPISTU_EDGELIST_REQ_VARS).are_present:
|
502
504
|
logger.info(
|
503
|
-
f"An edgelist with {', '.join(
|
505
|
+
f"An edgelist with {', '.join(NAPISTU_EDGELIST_REQ_VARS)} was provided; identifier matching will be skipped"
|
504
506
|
)
|
505
507
|
return edgelist
|
506
508
|
else:
|
@@ -20,6 +20,7 @@ from napistu.constants import MINI_SBO_FROM_NAME
|
|
20
20
|
from napistu.constants import SBOTERM_NAMES
|
21
21
|
from napistu.constants import SOURCE_SPEC
|
22
22
|
from napistu.ingestion.constants import EXCHANGE_COMPARTMENT
|
23
|
+
from napistu.network.constants import GRAPH_WIRING_APPROACHES
|
23
24
|
|
24
25
|
logger = logging.getLogger(__name__)
|
25
26
|
|
@@ -463,7 +464,7 @@ def _identify_species_needing_transport_reactions(
|
|
463
464
|
|
464
465
|
# create a directed graph
|
465
466
|
directed_graph = net_create.create_napistu_graph(
|
466
|
-
sbml_dfs, directed=True,
|
467
|
+
sbml_dfs, directed=True, wiring_approach=GRAPH_WIRING_APPROACHES.BIPARTITE
|
467
468
|
)
|
468
469
|
|
469
470
|
# consider each s_id and protein separately
|
@@ -7,17 +7,6 @@ from types import SimpleNamespace
|
|
7
7
|
from napistu.constants import SBML_DFS
|
8
8
|
from napistu.constants import SBOTERM_NAMES
|
9
9
|
|
10
|
-
# Graph types
|
11
|
-
NAPISTU_GRAPH_TYPES = SimpleNamespace(
|
12
|
-
BIPARTITE="bipartite", REGULATORY="regulatory", SURROGATE="surrogate"
|
13
|
-
)
|
14
|
-
|
15
|
-
VALID_NAPISTU_GRAPH_TYPES = [
|
16
|
-
NAPISTU_GRAPH_TYPES.BIPARTITE,
|
17
|
-
NAPISTU_GRAPH_TYPES.REGULATORY,
|
18
|
-
NAPISTU_GRAPH_TYPES.SURROGATE,
|
19
|
-
]
|
20
|
-
|
21
10
|
NAPISTU_GRAPH = SimpleNamespace(VERTICES="vertices", EDGES="edges", METADATA="metadata")
|
22
11
|
|
23
12
|
NAPISTU_GRAPH_DIRECTEDNESS = SimpleNamespace(
|
@@ -57,6 +46,67 @@ VALID_NAPISTU_GRAPH_NODE_TYPES = [
|
|
57
46
|
NAPISTU_GRAPH_NODE_TYPES.SPECIES,
|
58
47
|
]
|
59
48
|
|
49
|
+
# translating an SBML_dfs -> NapistuGraph
|
50
|
+
|
51
|
+
GRAPH_WIRING_APPROACHES = SimpleNamespace(
|
52
|
+
BIPARTITE="bipartite", REGULATORY="regulatory", SURROGATE="surrogate"
|
53
|
+
)
|
54
|
+
|
55
|
+
VALID_GRAPH_WIRING_APPROACHES = list(GRAPH_WIRING_APPROACHES.__dict__.values())
|
56
|
+
|
57
|
+
GRAPH_WIRING_HIERARCHIES = {
|
58
|
+
# three tiers with reactions in the middle
|
59
|
+
# in a bipartite networks molecules are connected to reactions but not other molecules
|
60
|
+
GRAPH_WIRING_APPROACHES.BIPARTITE: [
|
61
|
+
[
|
62
|
+
SBOTERM_NAMES.CATALYST,
|
63
|
+
SBOTERM_NAMES.INHIBITOR,
|
64
|
+
SBOTERM_NAMES.INTERACTOR,
|
65
|
+
SBOTERM_NAMES.MODIFIER,
|
66
|
+
SBOTERM_NAMES.REACTANT,
|
67
|
+
SBOTERM_NAMES.STIMULATOR,
|
68
|
+
],
|
69
|
+
[NAPISTU_GRAPH_NODE_TYPES.REACTION],
|
70
|
+
[SBOTERM_NAMES.MODIFIED, SBOTERM_NAMES.PRODUCT],
|
71
|
+
],
|
72
|
+
# the regulatory graph defines a hierarchy of upstream and downstream
|
73
|
+
# entities in a reaction
|
74
|
+
# modifier/stimulator/inhibitor -> catalyst -> reactant -> reaction -> product
|
75
|
+
GRAPH_WIRING_APPROACHES.REGULATORY: [
|
76
|
+
[SBOTERM_NAMES.INHIBITOR, SBOTERM_NAMES.MODIFIER, SBOTERM_NAMES.STIMULATOR],
|
77
|
+
[SBOTERM_NAMES.CATALYST],
|
78
|
+
[SBOTERM_NAMES.INTERACTOR, SBOTERM_NAMES.REACTANT],
|
79
|
+
[NAPISTU_GRAPH_NODE_TYPES.REACTION],
|
80
|
+
[SBOTERM_NAMES.MODIFIED, SBOTERM_NAMES.PRODUCT],
|
81
|
+
],
|
82
|
+
# an alternative layout to regulatory where enyzmes are downstream of substrates.
|
83
|
+
# this doesn't make much sense from a regulatory perspective because
|
84
|
+
# enzymes modify substrates not the other way around. but, its what one might
|
85
|
+
# expect if catalysts are a surrogate for reactions as is the case for metabolic
|
86
|
+
# network layouts
|
87
|
+
GRAPH_WIRING_APPROACHES.SURROGATE: [
|
88
|
+
[SBOTERM_NAMES.INHIBITOR, SBOTERM_NAMES.MODIFIER, SBOTERM_NAMES.STIMULATOR],
|
89
|
+
[SBOTERM_NAMES.INTERACTOR, SBOTERM_NAMES.REACTANT],
|
90
|
+
[SBOTERM_NAMES.CATALYST],
|
91
|
+
[NAPISTU_GRAPH_NODE_TYPES.REACTION],
|
92
|
+
[SBOTERM_NAMES.MODIFIED, SBOTERM_NAMES.PRODUCT],
|
93
|
+
],
|
94
|
+
}
|
95
|
+
|
96
|
+
# when should reaction vertices be excluded from the graph?
|
97
|
+
|
98
|
+
DROP_REACTIONS_WHEN = SimpleNamespace(
|
99
|
+
ALWAYS="always",
|
100
|
+
# if there are 2 participants
|
101
|
+
EDGELIST="edgelist",
|
102
|
+
# if there are 2 participants which are both "interactor"
|
103
|
+
SAME_TIER="same_tier",
|
104
|
+
)
|
105
|
+
|
106
|
+
VALID_DROP_REACTIONS_WHEN = list(DROP_REACTIONS_WHEN.__dict__.values())
|
107
|
+
|
108
|
+
# adding weights to NapistuGraph
|
109
|
+
|
60
110
|
NAPISTU_WEIGHTING_STRATEGIES = SimpleNamespace(
|
61
111
|
CALIBRATED="calibrated", MIXED="mixed", TOPOLOGY="topology", UNWEIGHTED="unweighted"
|
62
112
|
)
|
@@ -116,40 +166,6 @@ VALID_NET_POLARITIES = [
|
|
116
166
|
NET_POLARITY.AMBIGUOUS_INHIBITION,
|
117
167
|
]
|
118
168
|
|
119
|
-
# the regulatory graph defines a hierarchy of upstream and downstream
|
120
|
-
# entities in a reaction
|
121
|
-
# modifier/stimulator/inhibitor -> catalyst -> reactant -> reaction -> product
|
122
|
-
|
123
|
-
REGULATORY_GRAPH_HIERARCHY = [
|
124
|
-
[SBOTERM_NAMES.MODIFIER, SBOTERM_NAMES.STIMULATOR, SBOTERM_NAMES.INHIBITOR],
|
125
|
-
[SBOTERM_NAMES.CATALYST],
|
126
|
-
[SBOTERM_NAMES.REACTANT],
|
127
|
-
[NAPISTU_GRAPH_NODE_TYPES.REACTION],
|
128
|
-
# normally we don't expect interactors to be defined because they are handled by
|
129
|
-
# net_create._format_interactors_for_regulatory_graph() but include them here
|
130
|
-
# until Issue #102 is solved
|
131
|
-
[SBOTERM_NAMES.INTERACTOR],
|
132
|
-
[SBOTERM_NAMES.PRODUCT],
|
133
|
-
]
|
134
|
-
|
135
|
-
# an alternative layout to regulatory where enyzmes are downstream of substrates.
|
136
|
-
# this doesn't make much sense from a regulatory perspective because
|
137
|
-
# enzymes modify substrates not the other way around. but, its what one might
|
138
|
-
# expect if catalysts are a surrogate for reactions as is the case for metabolic
|
139
|
-
# network layouts
|
140
|
-
|
141
|
-
SURROGATE_GRAPH_HIERARCHY = [
|
142
|
-
[SBOTERM_NAMES.MODIFIER, SBOTERM_NAMES.STIMULATOR, SBOTERM_NAMES.INHIBITOR],
|
143
|
-
[SBOTERM_NAMES.REACTANT],
|
144
|
-
[SBOTERM_NAMES.CATALYST],
|
145
|
-
[NAPISTU_GRAPH_NODE_TYPES.REACTION],
|
146
|
-
# normally we don't expect interactors to be defined because they are handled by
|
147
|
-
# net_create._format_interactors_for_regulatory_graph() but include them here
|
148
|
-
# until Issue #102 is solved
|
149
|
-
[SBOTERM_NAMES.INTERACTOR],
|
150
|
-
[SBOTERM_NAMES.PRODUCT],
|
151
|
-
]
|
152
|
-
|
153
169
|
NEIGHBORHOOD_NETWORK_TYPES = SimpleNamespace(
|
154
170
|
DOWNSTREAM="downstream", HOURGLASS="hourglass", UPSTREAM="upstream"
|
155
171
|
)
|
@@ -6,7 +6,7 @@ import pandas as pd
|
|
6
6
|
|
7
7
|
from napistu import sbml_dfs_core
|
8
8
|
from napistu.network import net_create
|
9
|
-
from napistu.network.
|
9
|
+
from napistu.network.ng_core import NapistuGraph
|
10
10
|
|
11
11
|
from napistu.constants import SBML_DFS, ENTITIES_W_DATA
|
12
12
|
from napistu.network.constants import NAPISTU_GRAPH, DEFAULT_WT_TRANS, WEIGHTING_SPEC
|
@@ -22,7 +22,7 @@ from napistu.constants import SBML_DFS
|
|
22
22
|
from napistu.constants import MINI_SBO_NAME_TO_POLARITY
|
23
23
|
from napistu.constants import MINI_SBO_TO_NAME
|
24
24
|
|
25
|
-
from napistu.network.constants import
|
25
|
+
from napistu.network.constants import GRAPH_WIRING_APPROACHES
|
26
26
|
from napistu.network.constants import NEIGHBORHOOD_NETWORK_TYPES
|
27
27
|
from napistu.network.constants import VALID_NEIGHBORHOOD_NETWORK_TYPES
|
28
28
|
|
@@ -316,7 +316,7 @@ def create_neighborhood_prefix(network_type: str, order: int, top_n: int) -> str
|
|
316
316
|
def load_neighborhoods_by_partition(
|
317
317
|
selected_partition: int,
|
318
318
|
neighborhood_outdir: str,
|
319
|
-
|
319
|
+
wiring_approach: str = GRAPH_WIRING_APPROACHES.REGULATORY,
|
320
320
|
) -> None:
|
321
321
|
"""
|
322
322
|
Load Neighborhoods By Partition
|
@@ -380,7 +380,7 @@ def load_neighborhoods_by_partition(
|
|
380
380
|
model_prefix="curated",
|
381
381
|
network_dir=consensus_outdir,
|
382
382
|
directed=True,
|
383
|
-
|
383
|
+
wiring_approach=wiring_approach,
|
384
384
|
)
|
385
385
|
|
386
386
|
all_neighborhoods_df, neighborhoods_dict = load_neighborhoods(
|