napistu 0.2.5.dev6__tar.gz → 0.3.1__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.
Files changed (158) hide show
  1. {napistu-0.2.5.dev6/src/napistu.egg-info → napistu-0.3.1}/PKG-INFO +8 -3
  2. {napistu-0.2.5.dev6 → napistu-0.3.1}/README.md +2 -2
  3. {napistu-0.2.5.dev6 → napistu-0.3.1}/setup.cfg +6 -1
  4. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/__main__.py +126 -96
  5. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/constants.py +35 -41
  6. {napistu-0.2.5.dev6/src/napistu/network → napistu-0.3.1/src/napistu/context}/__init__.py +1 -1
  7. napistu-0.3.1/src/napistu/context/discretize.py +462 -0
  8. napistu-0.3.1/src/napistu/context/filtering.py +387 -0
  9. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/gcs/__init__.py +1 -1
  10. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/identifiers.py +74 -15
  11. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/indices.py +68 -0
  12. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/__init__.py +1 -1
  13. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/bigg.py +47 -62
  14. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/constants.py +18 -133
  15. napistu-0.3.1/src/napistu/ingestion/gtex.py +113 -0
  16. napistu-0.3.1/src/napistu/ingestion/hpa.py +147 -0
  17. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/sbml.py +0 -97
  18. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/string.py +2 -2
  19. {napistu-0.2.5.dev6/src/napistu/modify → napistu-0.3.1/src/napistu/matching}/__init__.py +1 -1
  20. napistu-0.3.1/src/napistu/matching/constants.py +18 -0
  21. napistu-0.3.1/src/napistu/matching/interactions.py +518 -0
  22. napistu-0.3.1/src/napistu/matching/mount.py +529 -0
  23. napistu-0.3.1/src/napistu/matching/species.py +510 -0
  24. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/__init__.py +7 -4
  25. napistu-0.3.1/src/napistu/mcp/__main__.py +261 -0
  26. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/client.py +16 -25
  27. napistu-0.3.1/src/napistu/mcp/codebase.py +230 -0
  28. napistu-0.3.1/src/napistu/mcp/component_base.py +170 -0
  29. napistu-0.3.1/src/napistu/mcp/config.py +223 -0
  30. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/constants.py +45 -2
  31. napistu-0.3.1/src/napistu/mcp/documentation.py +283 -0
  32. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/documentation_utils.py +13 -48
  33. napistu-0.3.1/src/napistu/mcp/execution.py +449 -0
  34. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/health.py +49 -67
  35. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/profiles.py +10 -6
  36. napistu-0.3.1/src/napistu/mcp/server.py +272 -0
  37. napistu-0.3.1/src/napistu/mcp/tutorials.py +176 -0
  38. napistu-0.3.1/src/napistu/modify/__init__.py +10 -0
  39. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/modify/gaps.py +1 -1
  40. napistu-0.3.1/src/napistu/network/__init__.py +10 -0
  41. napistu-0.3.1/src/napistu/network/constants.py +184 -0
  42. napistu-0.3.1/src/napistu/network/data_handling.py +388 -0
  43. napistu-0.3.1/src/napistu/network/ig_utils.py +351 -0
  44. napistu-0.3.1/src/napistu/network/napistu_graph_core.py +354 -0
  45. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/network/neighborhoods.py +40 -40
  46. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/network/net_create.py +373 -309
  47. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/network/net_propagation.py +47 -19
  48. napistu-0.2.5.dev6/src/napistu/network/net_utils.py → napistu-0.3.1/src/napistu/network/ng_utils.py +124 -272
  49. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/network/paths.py +67 -51
  50. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/network/precompute.py +11 -11
  51. napistu-0.3.1/src/napistu/ontologies/__init__.py +10 -0
  52. napistu-0.3.1/src/napistu/ontologies/constants.py +129 -0
  53. napistu-0.3.1/src/napistu/ontologies/dogma.py +243 -0
  54. napistu-0.3.1/src/napistu/ontologies/genodexito.py +649 -0
  55. napistu-0.3.1/src/napistu/ontologies/mygene.py +369 -0
  56. napistu-0.3.1/src/napistu/ontologies/renaming.py +198 -0
  57. napistu-0.3.1/src/napistu/rpy2/__init__.py +270 -0
  58. napistu-0.3.1/src/napistu/rpy2/callr.py +138 -0
  59. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/rpy2/constants.py +24 -23
  60. napistu-0.3.1/src/napistu/rpy2/rids.py +112 -0
  61. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/sbml_dfs_core.py +587 -222
  62. napistu-0.3.1/src/napistu/scverse/__init__.py +15 -0
  63. napistu-0.3.1/src/napistu/scverse/constants.py +28 -0
  64. napistu-0.3.1/src/napistu/scverse/loading.py +727 -0
  65. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/utils.py +118 -10
  66. {napistu-0.2.5.dev6 → napistu-0.3.1/src/napistu.egg-info}/PKG-INFO +8 -3
  67. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu.egg-info/SOURCES.txt +48 -12
  68. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu.egg-info/requires.txt +6 -0
  69. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/conftest.py +22 -0
  70. napistu-0.3.1/src/tests/test_context_discretize.py +56 -0
  71. napistu-0.3.1/src/tests/test_context_filtering.py +267 -0
  72. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_identifiers.py +100 -0
  73. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_indices.py +65 -0
  74. napistu-0.2.5.dev6/src/tests/test_edgelist.py → napistu-0.3.1/src/tests/test_ingestion_napistu_edgelist.py +2 -2
  75. napistu-0.3.1/src/tests/test_matching_interactions.py +108 -0
  76. napistu-0.3.1/src/tests/test_matching_mount.py +305 -0
  77. napistu-0.3.1/src/tests/test_matching_species.py +394 -0
  78. napistu-0.3.1/src/tests/test_mcp_config.py +193 -0
  79. napistu-0.3.1/src/tests/test_mcp_documentation_utils.py +22 -0
  80. napistu-0.3.1/src/tests/test_mcp_server.py +356 -0
  81. napistu-0.3.1/src/tests/test_network_data_handling.py +397 -0
  82. napistu-0.3.1/src/tests/test_network_ig_utils.py +23 -0
  83. napistu-0.3.1/src/tests/test_network_neighborhoods.py +19 -0
  84. napistu-0.3.1/src/tests/test_network_net_create.py +459 -0
  85. napistu-0.3.1/src/tests/test_network_ng_utils.py +30 -0
  86. napistu-0.3.1/src/tests/test_network_paths.py +56 -0
  87. napistu-0.2.5.dev6/src/tests/test_precomputed_distances.py → napistu-0.3.1/src/tests/test_network_precompute.py +8 -6
  88. napistu-0.3.1/src/tests/test_ontologies_genodexito.py +58 -0
  89. napistu-0.3.1/src/tests/test_ontologies_mygene.py +39 -0
  90. napistu-0.3.1/src/tests/test_ontologies_renaming.py +110 -0
  91. napistu-0.3.1/src/tests/test_rpy2_callr.py +79 -0
  92. napistu-0.3.1/src/tests/test_rpy2_init.py +151 -0
  93. napistu-0.3.1/src/tests/test_sbml.py +17 -0
  94. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_sbml_dfs_core.py +134 -10
  95. napistu-0.3.1/src/tests/test_scverse_loading.py +778 -0
  96. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_set_coverage.py +2 -2
  97. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_utils.py +121 -1
  98. napistu-0.2.5.dev6/src/napistu/mcp/__main__.py +0 -205
  99. napistu-0.2.5.dev6/src/napistu/mcp/codebase.py +0 -182
  100. napistu-0.2.5.dev6/src/napistu/mcp/documentation.py +0 -166
  101. napistu-0.2.5.dev6/src/napistu/mcp/execution.py +0 -382
  102. napistu-0.2.5.dev6/src/napistu/mcp/server.py +0 -191
  103. napistu-0.2.5.dev6/src/napistu/mcp/tutorials.py +0 -124
  104. napistu-0.2.5.dev6/src/napistu/mechanism_matching.py +0 -1353
  105. napistu-0.2.5.dev6/src/napistu/network/constants.py +0 -117
  106. napistu-0.2.5.dev6/src/napistu/rpy2/__init__.py +0 -127
  107. napistu-0.2.5.dev6/src/napistu/rpy2/callr.py +0 -168
  108. napistu-0.2.5.dev6/src/napistu/rpy2/netcontextr.py +0 -467
  109. napistu-0.2.5.dev6/src/napistu/rpy2/rids.py +0 -699
  110. napistu-0.2.5.dev6/src/tests/test_igraph.py +0 -367
  111. napistu-0.2.5.dev6/src/tests/test_mcp_documentation_utils.py +0 -13
  112. napistu-0.2.5.dev6/src/tests/test_mechanism_matching.py +0 -784
  113. napistu-0.2.5.dev6/src/tests/test_net_utils.py +0 -149
  114. napistu-0.2.5.dev6/src/tests/test_netcontextr.py +0 -105
  115. napistu-0.2.5.dev6/src/tests/test_rpy2.py +0 -61
  116. napistu-0.2.5.dev6/src/tests/test_sbml.py +0 -48
  117. {napistu-0.2.5.dev6 → napistu-0.3.1}/LICENSE +0 -0
  118. {napistu-0.2.5.dev6 → napistu-0.3.1}/pyproject.toml +0 -0
  119. {napistu-0.2.5.dev6 → napistu-0.3.1}/setup.py +0 -0
  120. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/__init__.py +0 -0
  121. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/consensus.py +0 -0
  122. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/gcs/constants.py +0 -0
  123. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/gcs/downloads.py +0 -0
  124. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/gcs/utils.py +0 -0
  125. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/identifiers_etl.py +0 -0
  126. /napistu-0.2.5.dev6/src/napistu/ingestion/cpr_edgelist.py → /napistu-0.3.1/src/napistu/ingestion/napistu_edgelist.py +0 -0
  127. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/obo.py +0 -0
  128. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/psi_mi.py +0 -0
  129. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/reactome.py +0 -0
  130. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/trrust.py +0 -0
  131. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/ingestion/yeast.py +0 -0
  132. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/codebase_utils.py +0 -0
  133. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/tutorials_utils.py +0 -0
  134. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/mcp/utils.py +0 -0
  135. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/modify/constants.py +0 -0
  136. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/modify/curation.py +0 -0
  137. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/modify/pathwayannot.py +0 -0
  138. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/modify/uncompartmentalize.py +0 -0
  139. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/sbml_dfs_utils.py +0 -0
  140. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu/source.py +0 -0
  141. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu.egg-info/dependency_links.txt +0 -0
  142. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu.egg-info/entry_points.txt +0 -0
  143. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/napistu.egg-info/top_level.txt +0 -0
  144. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/__init__.py +0 -0
  145. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_consensus.py +0 -0
  146. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_constants.py +0 -0
  147. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_curation.py +0 -0
  148. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_data/__init__.py +0 -0
  149. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_gaps.py +0 -0
  150. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_gcs.py +0 -0
  151. /napistu-0.2.5.dev6/src/tests/test_obo.py → /napistu-0.3.1/src/tests/test_ingestion_obo.py +0 -0
  152. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_net_propagation.py +0 -0
  153. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_pathwayannot.py +0 -0
  154. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_sbml_dfs_utils.py +0 -0
  155. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_sbo.py +0 -0
  156. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_source.py +0 -0
  157. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/test_uncompartmentalize.py +0 -0
  158. {napistu-0.2.5.dev6 → napistu-0.3.1}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: napistu
3
- Version: 0.2.5.dev6
3
+ Version: 0.3.1
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
@@ -23,6 +23,7 @@ Requires-Dist: fs<3.0.0,>=2.4.0
23
23
  Requires-Dist: fs-gcsfs<2.0.0,>=1.5.0
24
24
  Requires-Dist: igraph
25
25
  Requires-Dist: matplotlib<4.0.0,>=3.5.0
26
+ Requires-Dist: mygene<4.0.0,>=3.0.0
26
27
  Requires-Dist: numpy<3.0.0,>=1.24.0
27
28
  Requires-Dist: pandas<3.0.0,>=1.5.0
28
29
  Requires-Dist: pydantic<3.0.0,>=2.0.0
@@ -32,6 +33,7 @@ Requires-Dist: scipy<2.0.0,>=1.10.0
32
33
  Requires-Dist: tqdm
33
34
  Requires-Dist: zeep<4.0.0,>=3.0.0
34
35
  Provides-Extra: dev
36
+ Requires-Dist: napistu[mcp,scverse]; extra == "dev"
35
37
  Requires-Dist: black>=24.0.0; extra == "dev"
36
38
  Requires-Dist: ipykernel; extra == "dev"
37
39
  Requires-Dist: pre-commit<4.0.0,>=3.0.0; extra == "dev"
@@ -52,6 +54,9 @@ Provides-Extra: rpy2
52
54
  Requires-Dist: pyarrow<19.0.0,>=15.0.0; extra == "rpy2"
53
55
  Requires-Dist: rpy2<4.0.0,>=3.5.0; extra == "rpy2"
54
56
  Requires-Dist: rpy2-arrow<1.0.0,>=0.1.0; extra == "rpy2"
57
+ Provides-Extra: scverse
58
+ Requires-Dist: anndata; extra == "scverse"
59
+ Requires-Dist: mudata; extra == "scverse"
55
60
  Dynamic: license-file
56
61
 
57
62
  # Napistu Python Library
@@ -75,8 +80,8 @@ pip install .
75
80
  ```
76
81
 
77
82
  ## Documentation
78
- 📘 **Full Documentation**: [https://napistu.readthedocs.io](https://napistu.readthedocs.io)
79
- ** Wiki **: [napistu/wiki](https://github.com/napistu/napistu/wiki)
83
+ - 📘 **Library Documentation**: [napistu.readthedocs.io](https://napistu.readthedocs.io)
84
+ - 🚸 **Project Documentation**: [napistu/wiki](https://github.com/napistu/napistu/wiki)
80
85
 
81
86
  ### Quick Links
82
87
  - [Installation Guide](https://napistu.readthedocs.io/en/latest/installation.html)
@@ -19,8 +19,8 @@ pip install .
19
19
  ```
20
20
 
21
21
  ## Documentation
22
- 📘 **Full Documentation**: [https://napistu.readthedocs.io](https://napistu.readthedocs.io)
23
- ** Wiki **: [napistu/wiki](https://github.com/napistu/napistu/wiki)
22
+ - 📘 **Library Documentation**: [napistu.readthedocs.io](https://napistu.readthedocs.io)
23
+ - 🚸 **Project Documentation**: [napistu/wiki](https://github.com/napistu/napistu/wiki)
24
24
 
25
25
  ### Quick Links
26
26
  - [Installation Guide](https://napistu.readthedocs.io/en/latest/installation.html)
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = napistu
3
- version = 0.2.5.dev6
3
+ version = 0.3.1
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
@@ -29,6 +29,7 @@ install_requires =
29
29
  fs-gcsfs>=1.5.0,<2.0.0
30
30
  igraph
31
31
  matplotlib>=3.5.0,<4.0.0
32
+ mygene>=3.0.0,<4.0.0
32
33
  numpy>=1.24.0,<3.0.0
33
34
  pandas>=1.5.0,<3.0.0
34
35
  pydantic>=2.0.0,<3.0.0
@@ -50,6 +51,7 @@ console_scripts =
50
51
 
51
52
  [options.extras_require]
52
53
  dev =
54
+ napistu[mcp, scverse]
53
55
  black>=24.0.0
54
56
  ipykernel
55
57
  pre-commit>=3.0.0,<4.0.0
@@ -70,6 +72,9 @@ rpy2 =
70
72
  pyarrow>=15.0.0,<19.0.0
71
73
  rpy2>=3.5.0,<4.0.0
72
74
  rpy2-arrow>=0.1.0,<1.0.0
75
+ scverse =
76
+ anndata
77
+ mudata
73
78
 
74
79
  [tool:pytest]
75
80
  filterwarnings =
@@ -1,4 +1,4 @@
1
- """The CLI for cpr"""
1
+ """The CLI for Napistu"""
2
2
 
3
3
  from __future__ import annotations
4
4
 
@@ -13,11 +13,14 @@ import napistu
13
13
  import igraph as ig
14
14
  import pandas as pd
15
15
  from napistu import consensus as cpr_consensus
16
- from napistu import constants
17
16
  from napistu import indices
18
17
  from napistu import sbml_dfs_core
19
18
  from napistu import utils
19
+ from napistu.context import filtering
20
+ from napistu.matching import mount
20
21
  from napistu.ingestion import bigg
22
+ from napistu.ingestion import gtex
23
+ from napistu.ingestion import hpa
21
24
  from napistu.ingestion import reactome
22
25
  from napistu.ingestion import sbml
23
26
  from napistu.ingestion import string
@@ -27,15 +30,17 @@ from napistu.modify import gaps
27
30
  from napistu.modify import pathwayannot
28
31
  from napistu.modify import uncompartmentalize
29
32
  from napistu.network import net_create
30
- from napistu.network import net_utils
33
+ from napistu.network.ig_utils import get_graph_summary
34
+ from napistu.network.ng_utils import read_graph_attrs_spec
31
35
  from napistu.network import precompute
32
- from napistu.rpy2 import has_rpy2
36
+ from napistu.ontologies.genodexito import Genodexito
37
+ from napistu.ontologies import dogma
38
+ from napistu.constants import ONTOLOGIES
39
+ from napistu.constants import RESOLVE_MATCHES_AGGREGATORS
40
+ from napistu.ingestion.constants import PROTEINATLAS_SUBCELL_LOC_URL
41
+ from napistu.ingestion.constants import GTEX_RNASEQ_EXPRESSION_URL
33
42
  from fs import open_fs
34
43
 
35
- if has_rpy2:
36
- from napistu.rpy2 import rids
37
- from napistu.rpy2 import netcontextr, callr
38
-
39
44
  logger = logging.getLogger(napistu.__name__)
40
45
  click_logging.basic_config(logger)
41
46
 
@@ -89,15 +94,12 @@ def load_ttrust(target_uri: str):
89
94
  @click.option(
90
95
  "--url",
91
96
  type=str,
92
- default=constants.PROTEINATLAS_SUBCELL_LOC_URL,
97
+ default=PROTEINATLAS_SUBCELL_LOC_URL,
93
98
  help="URL to download the zipped protein atlas subcellular localization tsv from.",
94
99
  )
95
100
  @click_logging.simple_verbosity_option(logger)
96
101
  def load_proteinatlas_subcell(target_uri: str, url: str):
97
- file_ext = constants.PROTEINATLAS_SUBCELL_LOC_URL.split(".")[-1]
98
- target_filename = url.split("/")[-1].split(f".{file_ext}")[0]
99
- logger.info("Start downloading proteinatlas %s to %s", url, target_uri)
100
- utils.download_wget(url, target_uri, target_filename=target_filename)
102
+ hpa.download_hpa_data(target_uri, url)
101
103
 
102
104
 
103
105
  @load.command(name="gtex-rnaseq-expression")
@@ -105,13 +107,12 @@ def load_proteinatlas_subcell(target_uri: str, url: str):
105
107
  @click.option(
106
108
  "--url",
107
109
  type=str,
108
- default=constants.GTEX_RNASEQ_EXPRESSION_URL,
110
+ default=GTEX_RNASEQ_EXPRESSION_URL,
109
111
  help="URL to download the gtex file from.",
110
112
  )
111
113
  @click_logging.simple_verbosity_option(logger)
112
114
  def load_gtex_rnaseq(target_uri: str, url: str):
113
- logger.info("Start downloading gtex %s to %s", url, target_uri)
114
- utils.download_wget(url, target_uri)
115
+ gtex.download_gtex_rnaseq(target_uri, url)
115
116
 
116
117
 
117
118
  @load.command(name="string-db")
@@ -411,7 +412,7 @@ def apply_manual_curations(model_uri: str, curation_dir: str, output_model_uri:
411
412
  """Apply manual curations to a consensus model
412
413
 
413
414
  The curation dir is a directory containing the manual curations
414
- Check cpr.curation.curate_sbml_dfs for more information.
415
+ Check napistu.modify.curation.curate_sbml_dfs for more information.
415
416
  """
416
417
  model = utils.load_pickle(model_uri)
417
418
  model = curation.curate_sbml_dfs(curation_dir=curation_dir, sbml_dfs=model)
@@ -419,52 +420,80 @@ def apply_manual_curations(model_uri: str, curation_dir: str, output_model_uri:
419
420
 
420
421
 
421
422
  @refine.command(name="expand_identifiers")
422
- @click.argument("model_uri", type=str)
423
+ @click.argument("sbml_dfs_uri", type=str)
423
424
  @click.argument("output_model_uri", type=str)
424
- @click.option(
425
- "--id-type",
426
- "-u",
427
- type=click.Choice(["species", "compartments", "reactions"]),
428
- default="species",
429
- )
430
425
  @click.option("--species", "-s", default="Homo sapiens", type=str)
431
426
  @click.option(
432
427
  "--ontologies", "-o", multiple=True, type=str, help="Ontologies to add or complete"
433
428
  )
429
+ @click.option(
430
+ "--preferred_method",
431
+ "-p",
432
+ default="bioconductor",
433
+ type=str,
434
+ help="Preferred method to use for identifier expansion",
435
+ )
436
+ @click.option(
437
+ "--allow_fallback",
438
+ "-a",
439
+ default=True,
440
+ type=bool,
441
+ help="Allow fallback to other methods if preferred method fails",
442
+ )
434
443
  def expand_identifiers(
435
- model_uri: str,
444
+ sbml_dfs_uri: str,
436
445
  output_model_uri: str,
437
- id_type: str,
438
446
  species: str,
439
- ontologies: list[str],
447
+ ontologies: set[str],
448
+ preferred_method: str,
449
+ allow_fallback: bool,
440
450
  ):
441
451
  """Expand identifiers of a model
442
452
 
443
453
  Args:
444
- model_uri (str): uri of model in sbml dfs format
454
+ sbml_dfs_uri (str): uri of model in sbml dfs format
445
455
  output_model_uri (str): output uri of model in sbml dfs format
446
- id_type (str): identifier type, one of: species, compartments, reactions
447
456
  species (str): Species to use
448
- ontologies (list[str]): ontologies to add or update
457
+ ontologies (set[str]): ontologies to add or update
449
458
 
450
459
  Example call:
451
460
  > cpr refine expand_identifiers gs://<uri> ./test.pickle -o ensembl_gene
452
461
  """
453
-
454
- model: sbml.SBML_dfs = utils.load_pickle(model_uri) # type: ignore
462
+ sbml_dfs: sbml.SBML_dfs = utils.load_pickle(sbml_dfs_uri) # type: ignore
455
463
  if len(ontologies) == 0:
456
464
  raise ValueError("No ontologies to expand specified.")
457
- expanded_ids = rids.expand_identifiers(model, id_type, species, ontologies)
458
- rids.update_expanded_identifiers(model, id_type, expanded_ids)
459
- utils.save_pickle(output_model_uri, model)
465
+
466
+ Genodexito(
467
+ species=species,
468
+ preferred_method=preferred_method,
469
+ allow_fallback=allow_fallback,
470
+ ).expand_sbml_dfs_ids(sbml_dfs, ontologies=ontologies)
471
+
472
+ utils.save_pickle(output_model_uri, sbml_dfs)
460
473
 
461
474
 
462
475
  @integrate.command(name="dogmatic_scaffold")
463
476
  @click.argument("output_model_uri", type=str)
464
477
  @click.option("--species", "-s", default="Homo sapiens", type=str)
478
+ @click.option(
479
+ "--preferred_method",
480
+ "-p",
481
+ default="bioconductor",
482
+ type=str,
483
+ help="Preferred method to use for identifier expansion",
484
+ )
485
+ @click.option(
486
+ "--allow_fallback",
487
+ "-a",
488
+ default=True,
489
+ type=bool,
490
+ help="Allow fallback to other methods if preferred method fails",
491
+ )
465
492
  def dogmatic_scaffold(
466
493
  output_model_uri: str,
467
494
  species: str,
495
+ preferred_method: str,
496
+ allow_fallback: bool,
468
497
  ):
469
498
  """Dogmatic Scaffold
470
499
 
@@ -476,25 +505,23 @@ def dogmatic_scaffold(
476
505
  > cpr integrate dogmatic_scaffold ./test.pickle
477
506
  """
478
507
 
479
- dogmatic_sbml_dfs = rids.create_dogmatic_sbml_dfs(species)
508
+ dogmatic_sbml_dfs = dogma.create_dogmatic_sbml_dfs(
509
+ species=species,
510
+ preferred_method=preferred_method,
511
+ allow_fallback=allow_fallback,
512
+ )
513
+
480
514
  utils.save_pickle(output_model_uri, dogmatic_sbml_dfs)
481
515
 
482
516
 
483
517
  @refine.command(name="filter_gtex_tissue")
484
- @click.argument("model_uri", type=str)
518
+ @click.argument("sbml_dfs_uri", type=str)
485
519
  @click.argument("gtex_file_uri", type=str)
486
520
  @click.argument("output_model_uri", type=str)
487
521
  @click.argument("tissue", type=str)
488
- @click.option(
489
- "--filter-non-genic-reactions",
490
- "-f",
491
- default=False,
492
- type=bool,
493
- help="Filter reactions not involving genes?",
494
- )
495
522
  @click_logging.simple_verbosity_option(logger)
496
523
  def filter_gtex_tissue(
497
- model_uri: str,
524
+ sbml_dfs_uri: str,
498
525
  gtex_file_uri: str,
499
526
  output_model_uri: str,
500
527
  tissue: str,
@@ -504,70 +531,73 @@ def filter_gtex_tissue(
504
531
 
505
532
  This uses zfpkm values derived from gtex to filter the model.
506
533
  """
507
- logger.info("Get rcpr from R")
508
- rcpr = callr.get_rcpr()
534
+
509
535
  logger.info("Load sbml_dfs model")
510
- model: sbml.SBML_dfs = utils.load_pickle(model_uri) # type: ignore
536
+ sbml_dfs: sbml.SBML_dfs = utils.load_pickle(sbml_dfs_uri) # type: ignore
511
537
  logger.info("Load and clean gtex tissue expression")
512
- dat_gtex = netcontextr.load_and_clean_gtex_data(
513
- rcpr, gtex_file_uri, by_tissue_zfpkm=True
514
- )
515
- logger.info("Convert sbml_dfs to rcpr reaction graph")
516
- model_r = netcontextr.sbml_dfs_to_rcpr_reactions(model)
538
+ dat_gtex = gtex.load_and_clean_gtex_data(gtex_file_uri)
517
539
  logger.info("Annotate genes with gtex tissue expression")
518
- model_r_annot = netcontextr.annotate_genes(rcpr, model_r, dat_gtex, "tissue")
540
+ mount.bind_wide_results(
541
+ sbml_dfs=sbml_dfs,
542
+ results_df=dat_gtex.reset_index(drop=False),
543
+ results_name="gtex",
544
+ ontologies={ONTOLOGIES.ENSEMBL_GENE},
545
+ numeric_agg=RESOLVE_MATCHES_AGGREGATORS.MAX,
546
+ )
519
547
  logger.info("Trim network by gene attribute")
520
- model_r_trim = netcontextr.trim_reactions_by_gene_attribute(
521
- rcpr, model_r_annot, "tissue", tissue
548
+ filtering.filter_species_by_attribute(
549
+ sbml_dfs,
550
+ "gtex",
551
+ attribute_name=tissue,
552
+ # remove entries which are NOT in the liver
553
+ attribute_value=0,
554
+ inplace=True,
522
555
  )
523
- logger.info("Apply trimmed network")
556
+ # remove the gtex species data from the sbml_dfs
557
+ sbml_dfs.remove_species_data("gtex")
524
558
 
525
- if filter_non_genic_reactions:
526
- logger.info("Filter non genic reactions")
527
- considered_reactions = None
528
- else:
529
- logger.info("Keep genic reactions")
530
- considered_reactions = rcpr._get_rids_from_rcpr_reactions(model_r)
531
- netcontextr.apply_reactions_context_to_sbml_dfs(
532
- model, model_r_trim, considered_reactions=considered_reactions
533
- )
534
- logger.info("Save model to %s", output_model_uri)
535
- utils.save_pickle(output_model_uri, model)
559
+ logger.info("Save sbml_dfs to %s", output_model_uri)
560
+ utils.save_pickle(output_model_uri, sbml_dfs)
536
561
 
537
562
 
538
563
  @refine.command(name="filter_hpa_compartments")
539
- @click.argument("model_uri", type=str)
564
+ @click.argument("sbml_dfs_uri", type=str)
540
565
  @click.argument("hpa_file_uri", type=str)
541
566
  @click.argument("output_model_uri", type=str)
542
567
  @click_logging.simple_verbosity_option(logger)
543
568
  def filter_hpa_gene_compartments(
544
- model_uri: str, hpa_file_uri: str, output_model_uri: str
569
+ sbml_dfs_uri: str, hpa_file_uri: str, output_model_uri: str
545
570
  ):
546
571
  """Filter an interaction network using the human protein atlas
547
572
 
548
- This uses R `rcpr` to filter an interaction network based on the
549
- compartment information from the human protein atlas.
573
+ This uses loads the human proteome atlas and removes reactions (including interactions)
574
+ containing genes which are not colocalized.
550
575
 
551
576
  Only interactions between genes in the same compartment are kept.
552
577
  """
553
- logger.info("Get rcpr from R")
554
- rcpr = callr.get_rcpr()
578
+
555
579
  logger.info("Load sbml_dfs model")
556
- model: sbml.SBML_dfs = utils.load_pickle(model_uri) # type: ignore
580
+ sbml_dfs: sbml.SBML_dfs = utils.load_pickle(sbml_dfs_uri) # type: ignore
557
581
  logger.info("Load and clean hpa data")
558
- dat_hpa = netcontextr.load_and_clean_hpa_data(rcpr, hpa_file_uri)
559
- logger.info("Convert sbml_dfs to rcpr string graph")
560
- model_r = netcontextr.sbml_dfs_to_rcpr_string_graph(model)
582
+ dat_hpa = hpa.load_and_clean_hpa_data(hpa_file_uri)
561
583
  logger.info("Annotate genes with HPA compartments")
562
- model_r_annot = netcontextr.annotate_genes(rcpr, model_r, dat_hpa, "compartment")
563
- logger.info("Trim network by gene attribute")
564
- model_r_trim = netcontextr.trim_network_by_gene_attribute(
565
- rcpr, model_r_annot, "compartment"
584
+ mount.bind_wide_results(
585
+ sbml_dfs=sbml_dfs,
586
+ results_df=dat_hpa.reset_index(drop=False),
587
+ results_name="hpa",
588
+ ontologies={ONTOLOGIES.ENSEMBL_GENE},
589
+ numeric_agg=RESOLVE_MATCHES_AGGREGATORS.MAX,
566
590
  )
567
- logger.info("Apply trimmed network")
568
- netcontextr.apply_context_to_sbml_dfs(model, model_r_trim)
569
- logger.info("Save model to %s", output_model_uri)
570
- utils.save_pickle(output_model_uri, model)
591
+ logger.info(
592
+ "Trim network removing reactions with species in different compartments"
593
+ )
594
+ filtering.filter_reactions_with_disconnected_cspecies(
595
+ sbml_dfs, "hpa", inplace=False
596
+ )
597
+ sbml_dfs.remove_species_data("hpa")
598
+
599
+ logger.info("Save sbml_dfs to %s", output_model_uri)
600
+ utils.save_pickle(output_model_uri, sbml_dfs)
571
601
 
572
602
 
573
603
  @click.group()
@@ -626,9 +656,9 @@ def export_igraph(
626
656
  if graph_attrs_spec_uri is None:
627
657
  graph_attrs_spec = None
628
658
  else:
629
- graph_attrs_spec = net_utils.read_graph_attrs_spec(graph_attrs_spec_uri)
659
+ graph_attrs_spec = read_graph_attrs_spec(graph_attrs_spec_uri)
630
660
 
631
- cpr_graph = net_create.process_cpr_graph(
661
+ napistu_graph = net_create.process_napistu_graph(
632
662
  model,
633
663
  reaction_graph_attrs=graph_attrs_spec,
634
664
  directed=directed,
@@ -642,11 +672,11 @@ def export_igraph(
642
672
  with open_fs(base, create=True, writeable=True) as fs:
643
673
  with fs.openbin(path, "wb") as f:
644
674
  if format == "gml":
645
- cpr_graph.write_gml(f)
675
+ napistu_graph.write_gml(f)
646
676
  elif format == "edgelist":
647
- cpr_graph.write_edgelist(f)
677
+ napistu_graph.write_edgelist(f)
648
678
  elif format == "pickle":
649
- pickle.dump(cpr_graph, f)
679
+ pickle.dump(napistu_graph, f)
650
680
  else:
651
681
  raise ValueError("Unknown format: %s" % format)
652
682
 
@@ -704,11 +734,11 @@ def export_precomputed_distances(
704
734
  with open_fs(base) as fs:
705
735
  with fs.openbin(path) as f:
706
736
  if format == "gml":
707
- cpr_graph = ig.Graph.Read_GML(f)
737
+ napistu_graph = ig.Graph.Read_GML(f)
708
738
  elif format == "edgelist":
709
- cpr_graph = ig.Graph.Read_Edgelist(f)
739
+ napistu_graph = ig.Graph.Read_Edgelist(f)
710
740
  elif format == "pickle":
711
- cpr_graph = ig.Graph.Read_Pickle(f)
741
+ napistu_graph = ig.Graph.Read_Pickle(f)
712
742
  else:
713
743
  raise ValueError("Unknown format: %s" % format)
714
744
 
@@ -716,7 +746,7 @@ def export_precomputed_distances(
716
746
  weights_vars_list = utils.click_str_to_list(weights_vars)
717
747
 
718
748
  precomputed_distances = precompute.precompute_distances(
719
- cpr_graph,
749
+ napistu_graph,
720
750
  max_steps=max_steps,
721
751
  max_score_q=max_score_q,
722
752
  partition_size=partition_size,
@@ -850,7 +880,7 @@ def calculate_sbml_dfs_stats(input_uri, output_uri):
850
880
  def calculate_igraph_stats(input_uri, output_uri):
851
881
  """Calculate statistics for an igraph object"""
852
882
  graph: ig.Graph = utils.load_pickle(input_uri) # type: ignore
853
- stats = net_utils.get_graph_summary(graph)
883
+ stats = get_graph_summary(graph)
854
884
  utils.save_json(output_uri, stats)
855
885
 
856
886
 
@@ -21,16 +21,6 @@ PACKAGE_DEFS = SimpleNamespace(
21
21
  CACHE_DIR="napistu_data",
22
22
  )
23
23
 
24
- PROTEINATLAS_SUBCELL_LOC_URL = (
25
- "https://www.proteinatlas.org/download/tsv/subcellular_location.tsv.zip"
26
- )
27
-
28
- # GTEx
29
- GTEX_RNASEQ_EXPRESSION_URL = "https://storage.googleapis.com/adult-gtex/bulk-gex/v8/rna-seq/GTEx_Analysis_2017-06-05_v8_RNASeQCv1.1.9_gene_median_tpm.gct.gz"
30
-
31
- # Gencode
32
- GENCODE_URL = "https://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/release_26/gencode.v26.transcripts.fa.gz"
33
-
34
24
  FILE_EXT_ZIP = "zip"
35
25
  FILE_EXT_GZ = "gz"
36
26
 
@@ -131,6 +121,11 @@ SBML_DFS_SCHEMA = SimpleNamespace(
131
121
 
132
122
  ENTITIES_W_DATA = {SBML_DFS.SPECIES, SBML_DFS.REACTIONS}
133
123
 
124
+ ENTITIES_TO_ENTITY_DATA = {
125
+ SBML_DFS.SPECIES: SBML_DFS.SPECIES_DATA,
126
+ SBML_DFS.REACTIONS: SBML_DFS.REACTIONS_DATA,
127
+ }
128
+
134
129
  REQUIRED_REACTION_FROMEDGELIST_COLUMNS = [
135
130
  "sc_id_up",
136
131
  "sc_id_down",
@@ -211,11 +206,14 @@ IDENTIFIERS = SimpleNamespace(
211
206
  ONTOLOGY="ontology", IDENTIFIER="identifier", BQB="bqb", URL="url"
212
207
  )
213
208
 
214
- SPECIES_IDENTIFIERS_REQUIRED_VARS = {
215
- SBML_DFS.S_ID,
209
+ IDENTIFIERS_REQUIRED_VARS = {
216
210
  IDENTIFIERS.ONTOLOGY,
217
211
  IDENTIFIERS.IDENTIFIER,
218
212
  IDENTIFIERS.BQB,
213
+ }
214
+
215
+ SPECIES_IDENTIFIERS_REQUIRED_VARS = IDENTIFIERS_REQUIRED_VARS | {
216
+ SBML_DFS.S_ID,
219
217
  SBML_DFS.S_NAME,
220
218
  }
221
219
 
@@ -296,29 +294,34 @@ MINI_SBO_NAME_TO_POLARITY = {
296
294
  # affect whether a reaction can occur
297
295
  # for example, if I remove any substrate a reaction won't occur
298
296
  # but I would have to remove all catalysts for it to not occur
297
+ SBO_ROLES_DEFS = SimpleNamespace(
298
+ DEFINING="DEFINING", REQUIRED="REQUIRED", OPTIONAL="OPTIONAL", SBO_ROLE="sbo_role"
299
+ )
300
+
299
301
  SBO_NAME_TO_ROLE = {
300
- SBOTERM_NAMES.REACTANT: "DEFINING",
301
- SBOTERM_NAMES.PRODUCT: "DEFINING",
302
- SBOTERM_NAMES.INTERACTOR: "DEFINING",
303
- SBOTERM_NAMES.CATALYST: "REQUIRED",
304
- SBOTERM_NAMES.INHIBITOR: "OPTIONAL",
305
- SBOTERM_NAMES.STIMULATOR: "OPTIONAL",
306
- SBOTERM_NAMES.MODIFIER: "OPTIONAL",
302
+ SBOTERM_NAMES.REACTANT: SBO_ROLES_DEFS.DEFINING,
303
+ SBOTERM_NAMES.PRODUCT: SBO_ROLES_DEFS.DEFINING,
304
+ SBOTERM_NAMES.INTERACTOR: SBO_ROLES_DEFS.DEFINING,
305
+ SBOTERM_NAMES.CATALYST: SBO_ROLES_DEFS.REQUIRED,
306
+ SBOTERM_NAMES.INHIBITOR: SBO_ROLES_DEFS.OPTIONAL,
307
+ SBOTERM_NAMES.STIMULATOR: SBO_ROLES_DEFS.OPTIONAL,
308
+ SBOTERM_NAMES.MODIFIER: SBO_ROLES_DEFS.OPTIONAL,
307
309
  }
308
310
 
309
311
  # see also https://github.com/calico/netcontextr/blob/main/R/reactionTrimmingFunctions.R
310
312
  VALID_SBO_ROLES = (
311
313
  # there is a direct correspondence between the set of defining entries and the identity of a reaction
312
314
  # e.g., the stoichiometery of a metabolic reaction or the members of a protein-protein interaction
313
- "DEFINING",
315
+ SBO_ROLES_DEFS.DEFINING,
314
316
  # 1+ entries are needed if entries were initially defined. i.e., reactions which require a catalyst
315
317
  # would no longer exist if the catalyst was removed, but many reactions do not require a catalyst.
316
- "REQUIRED",
318
+ SBO_ROLES_DEFS.REQUIRED,
317
319
  # 0+ entries. optional species can be added or removed to a reaction without changing its identity
318
- "OPTIONAL",
320
+ SBO_ROLES_DEFS.OPTIONAL,
319
321
  )
320
322
 
321
- # required variables for the edgelist formats used by mechanism_matching
323
+ # required variables for the edgelist formats used by the matching subpackage
324
+ # also used in some network modules
322
325
  CPR_EDGELIST = SimpleNamespace(
323
326
  S_ID_UPSTREAM="s_id_upstream",
324
327
  S_ID_DOWNSTREAM="s_id_downstream",
@@ -354,24 +357,8 @@ RESOLVE_MATCHES_AGGREGATORS = SimpleNamespace(
354
357
 
355
358
  RESOLVE_MATCHES_TMP_WEIGHT_COL = "__tmp_weight_for_aggregation__"
356
359
 
357
- # specifying weighting schemes schema
358
-
359
- DEFAULT_WT_TRANS = "identity"
360
-
361
- DEFINED_WEIGHT_TRANSFORMATION = {
362
- DEFAULT_WT_TRANS: "_wt_transformation_identity",
363
- "string": "_wt_transformation_string",
364
- "string_inv": "_wt_transformation_string_inv",
365
- }
360
+ # source information
366
361
 
367
- SCORE_CALIBRATION_POINTS_DICT = {
368
- "weights": {"strong": 3, "good": 7, "okay": 20, "weak": 40},
369
- "string_wt": {"strong": 950, "good": 400, "okay": 230, "weak": 150},
370
- }
371
-
372
- SOURCE_VARS_DICT = {"string_wt": 10}
373
-
374
- # source
375
362
  SOURCE_SPEC = SimpleNamespace(
376
363
  PATHWAY_ID="pathway_id",
377
364
  MODEL="model",
@@ -399,8 +386,11 @@ EXPECTED_PW_INDEX_COLUMNS = {
399
386
  ONTOLOGIES = SimpleNamespace(
400
387
  CHEBI="chebi",
401
388
  ENSEMBL_GENE="ensembl_gene",
389
+ ENSEMBL_GENE_VERSION="ensembl_gene_version",
402
390
  ENSEMBL_TRANSCRIPT="ensembl_transcript",
391
+ ENSEMBL_TRANSCRIPT_VERSION="ensembl_transcript_version",
403
392
  ENSEMBL_PROTEIN="ensembl_protein",
393
+ ENSEMBL_PROTEIN_VERSION="ensembl_protein_version",
404
394
  GENE_NAME="gene_name",
405
395
  GO="go",
406
396
  MIRBASE="mirbase",
@@ -419,7 +409,11 @@ CHARACTERISTIC_COMPLEX_ONTOLOGIES = [
419
409
  ONTOLOGIES.MIRBASE,
420
410
  ]
421
411
 
422
- ONTOLOGY_ALIASES = SimpleNamespace(NCBI_ENTREZ_GENE={"ncbigene", "ncbi_gene"})
412
+ ONTOLOGY_SPECIES_ALIASES = {
413
+ ONTOLOGIES.NCBI_ENTREZ_GENE: {"ncbigene", "ncbi_gene"},
414
+ ONTOLOGIES.ENSEMBL_GENE: {"ensembl_gene_id"},
415
+ ONTOLOGIES.UNIPROT: {"Uniprot"},
416
+ }
423
417
 
424
418
  ENSEMBL_MOLECULE_TYPES_TO_ONTOLOGY = {
425
419
  "G": ONTOLOGIES.ENSEMBL_GENE,
@@ -4,7 +4,7 @@ from importlib.metadata import PackageNotFoundError
4
4
  from importlib.metadata import version
5
5
 
6
6
  try:
7
- __version__ = version("calicolabs-cpr")
7
+ __version__ = version("napistu-py")
8
8
  except PackageNotFoundError:
9
9
  # package is not installed
10
10
  pass