napistu 0.4.5__tar.gz → 0.4.6__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 (150) hide show
  1. {napistu-0.4.5/src/napistu.egg-info → napistu-0.4.6}/PKG-INFO +1 -1
  2. {napistu-0.4.5 → napistu-0.4.6}/setup.cfg +1 -1
  3. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/constants.py +12 -1
  4. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/neighborhoods.py +129 -87
  5. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/ng_utils.py +4 -4
  6. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/paths.py +28 -18
  7. {napistu-0.4.5 → napistu-0.4.6/src/napistu.egg-info}/PKG-INFO +1 -1
  8. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_neighborhoods.py +31 -21
  9. napistu-0.4.6/src/tests/test_network_paths.py +80 -0
  10. napistu-0.4.5/src/tests/test_network_paths.py +0 -56
  11. {napistu-0.4.5 → napistu-0.4.6}/LICENSE +0 -0
  12. {napistu-0.4.5 → napistu-0.4.6}/README.md +0 -0
  13. {napistu-0.4.5 → napistu-0.4.6}/pyproject.toml +0 -0
  14. {napistu-0.4.5 → napistu-0.4.6}/setup.py +0 -0
  15. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/__init__.py +0 -0
  16. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/__main__.py +0 -0
  17. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/consensus.py +0 -0
  18. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/constants.py +0 -0
  19. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/context/__init__.py +0 -0
  20. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/context/discretize.py +0 -0
  21. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/context/filtering.py +0 -0
  22. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/gcs/__init__.py +0 -0
  23. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/gcs/constants.py +0 -0
  24. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/gcs/downloads.py +0 -0
  25. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/gcs/utils.py +0 -0
  26. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/identifiers.py +0 -0
  27. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/indices.py +0 -0
  28. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/__init__.py +0 -0
  29. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/bigg.py +0 -0
  30. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/constants.py +0 -0
  31. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/gtex.py +0 -0
  32. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/hpa.py +0 -0
  33. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/identifiers_etl.py +0 -0
  34. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/napistu_edgelist.py +0 -0
  35. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/obo.py +0 -0
  36. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/psi_mi.py +0 -0
  37. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/reactom_fi.py +0 -0
  38. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/reactome.py +0 -0
  39. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/sbml.py +0 -0
  40. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/string.py +0 -0
  41. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/trrust.py +0 -0
  42. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ingestion/yeast.py +0 -0
  43. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/matching/__init__.py +0 -0
  44. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/matching/constants.py +0 -0
  45. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/matching/interactions.py +0 -0
  46. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/matching/mount.py +0 -0
  47. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/matching/species.py +0 -0
  48. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/__init__.py +0 -0
  49. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/__main__.py +0 -0
  50. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/client.py +0 -0
  51. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/codebase.py +0 -0
  52. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/codebase_utils.py +0 -0
  53. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/component_base.py +0 -0
  54. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/config.py +0 -0
  55. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/constants.py +0 -0
  56. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/documentation.py +0 -0
  57. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/documentation_utils.py +0 -0
  58. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/execution.py +0 -0
  59. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/health.py +0 -0
  60. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/profiles.py +0 -0
  61. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/server.py +0 -0
  62. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/tutorials.py +0 -0
  63. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/tutorials_utils.py +0 -0
  64. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/mcp/utils.py +0 -0
  65. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/__init__.py +0 -0
  66. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/constants.py +0 -0
  67. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/curation.py +0 -0
  68. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/gaps.py +0 -0
  69. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/pathwayannot.py +0 -0
  70. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/modify/uncompartmentalize.py +0 -0
  71. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/__init__.py +0 -0
  72. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/data_handling.py +0 -0
  73. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/ig_utils.py +0 -0
  74. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/net_create.py +0 -0
  75. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/net_create_utils.py +0 -0
  76. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/net_propagation.py +0 -0
  77. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/ng_core.py +0 -0
  78. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/network/precompute.py +0 -0
  79. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/__init__.py +0 -0
  80. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/constants.py +0 -0
  81. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/dogma.py +0 -0
  82. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/genodexito.py +0 -0
  83. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/id_tables.py +0 -0
  84. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/mygene.py +0 -0
  85. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/ontologies/renaming.py +0 -0
  86. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/rpy2/__init__.py +0 -0
  87. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/rpy2/callr.py +0 -0
  88. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/rpy2/constants.py +0 -0
  89. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/rpy2/rids.py +0 -0
  90. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/sbml_dfs_core.py +0 -0
  91. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/sbml_dfs_utils.py +0 -0
  92. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/scverse/__init__.py +0 -0
  93. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/scverse/constants.py +0 -0
  94. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/scverse/loading.py +0 -0
  95. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/source.py +0 -0
  96. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/statistics/__init__.py +0 -0
  97. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/statistics/hypothesis_testing.py +0 -0
  98. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/statistics/quantiles.py +0 -0
  99. {napistu-0.4.5 → napistu-0.4.6}/src/napistu/utils.py +0 -0
  100. {napistu-0.4.5 → napistu-0.4.6}/src/napistu.egg-info/SOURCES.txt +0 -0
  101. {napistu-0.4.5 → napistu-0.4.6}/src/napistu.egg-info/dependency_links.txt +0 -0
  102. {napistu-0.4.5 → napistu-0.4.6}/src/napistu.egg-info/entry_points.txt +0 -0
  103. {napistu-0.4.5 → napistu-0.4.6}/src/napistu.egg-info/requires.txt +0 -0
  104. {napistu-0.4.5 → napistu-0.4.6}/src/napistu.egg-info/top_level.txt +0 -0
  105. {napistu-0.4.5 → napistu-0.4.6}/src/tests/__init__.py +0 -0
  106. {napistu-0.4.5 → napistu-0.4.6}/src/tests/conftest.py +0 -0
  107. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_consensus.py +0 -0
  108. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_constants.py +0 -0
  109. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_context_discretize.py +0 -0
  110. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_context_filtering.py +0 -0
  111. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_curation.py +0 -0
  112. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_data/__init__.py +0 -0
  113. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_gaps.py +0 -0
  114. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_gcs.py +0 -0
  115. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_identifiers.py +0 -0
  116. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_indices.py +0 -0
  117. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ingestion_napistu_edgelist.py +0 -0
  118. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ingestion_obo.py +0 -0
  119. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_matching_interactions.py +0 -0
  120. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_matching_mount.py +0 -0
  121. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_matching_species.py +0 -0
  122. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_mcp_config.py +0 -0
  123. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_mcp_documentation_utils.py +0 -0
  124. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_mcp_server.py +0 -0
  125. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_data_handling.py +0 -0
  126. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_ig_utils.py +0 -0
  127. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_net_create.py +0 -0
  128. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_net_create_utils.py +0 -0
  129. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_net_propagation.py +0 -0
  130. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_ng_core.py +0 -0
  131. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_ng_utils.py +0 -0
  132. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_network_precompute.py +0 -0
  133. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ontologies_genodexito.py +0 -0
  134. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ontologies_id_tables.py +0 -0
  135. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ontologies_mygene.py +0 -0
  136. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_ontologies_renaming.py +0 -0
  137. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_pathwayannot.py +0 -0
  138. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_rpy2_callr.py +0 -0
  139. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_rpy2_init.py +0 -0
  140. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_sbml.py +0 -0
  141. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_sbml_dfs_core.py +0 -0
  142. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_sbml_dfs_utils.py +0 -0
  143. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_sbo.py +0 -0
  144. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_scverse_loading.py +0 -0
  145. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_source.py +0 -0
  146. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_statistics_hypothesis_testing.py +0 -0
  147. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_statistics_quantiles.py +0 -0
  148. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_uncompartmentalize.py +0 -0
  149. {napistu-0.4.5 → napistu-0.4.6}/src/tests/test_utils.py +0 -0
  150. {napistu-0.4.5 → napistu-0.4.6}/src/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: napistu
3
- Version: 0.4.5
3
+ Version: 0.4.6
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = napistu
3
- version = 0.4.5
3
+ version = 0.4.6
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
@@ -14,7 +14,11 @@ NAPISTU_GRAPH_DIRECTEDNESS = SimpleNamespace(
14
14
  DIRECTED="directed", UNDIRECTED="undirected"
15
15
  )
16
16
 
17
- NAPISTU_GRAPH_VERTICES = SimpleNamespace(NAME="name")
17
+ NAPISTU_GRAPH_VERTICES = SimpleNamespace(
18
+ NAME="name", # internal name
19
+ NODE_NAME="node_name", # human readable name
20
+ NODE_TYPE="node_type", # type of node (species or reaction)
21
+ )
18
22
 
19
23
  NAPISTU_GRAPH_EDGES = SimpleNamespace(
20
24
  DIRECTED="directed",
@@ -220,3 +224,10 @@ PARAMETRIC_NULL_DEFAULT_DISTRIBUTION = "norm"
220
224
  MASK_KEYWORDS = SimpleNamespace(
221
225
  ATTR="attr",
222
226
  )
227
+
228
+ NEIGHBORHOOD_DICT_KEYS = SimpleNamespace(
229
+ GRAPH="graph",
230
+ VERTICES="vertices",
231
+ EDGES="edges",
232
+ REACTION_SOURCES="reaction_sources",
233
+ )
@@ -18,13 +18,21 @@ from napistu import utils
18
18
  from napistu.network import ng_utils
19
19
  from napistu.network import paths
20
20
 
21
- from napistu.constants import SBML_DFS
22
- from napistu.constants import MINI_SBO_NAME_TO_POLARITY
23
- from napistu.constants import MINI_SBO_TO_NAME
24
-
25
- from napistu.network.constants import GRAPH_WIRING_APPROACHES
26
- from napistu.network.constants import NEIGHBORHOOD_NETWORK_TYPES
27
- from napistu.network.constants import VALID_NEIGHBORHOOD_NETWORK_TYPES
21
+ from napistu.constants import (
22
+ MINI_SBO_NAME_TO_POLARITY,
23
+ MINI_SBO_TO_NAME,
24
+ NAPISTU_EDGELIST,
25
+ SBML_DFS,
26
+ )
27
+
28
+ from napistu.network.constants import (
29
+ GRAPH_WIRING_APPROACHES,
30
+ NAPISTU_GRAPH_VERTICES,
31
+ NEIGHBORHOOD_DICT_KEYS,
32
+ NEIGHBORHOOD_NETWORK_TYPES,
33
+ NET_POLARITY,
34
+ VALID_NEIGHBORHOOD_NETWORK_TYPES,
35
+ )
28
36
 
29
37
  logger = logging.getLogger(__name__)
30
38
 
@@ -34,8 +42,9 @@ def find_and_prune_neighborhoods(
34
42
  napistu_graph: ig.Graph,
35
43
  compartmentalized_species: str | list[str],
36
44
  precomputed_distances: pd.DataFrame | None = None,
45
+ min_pw_size: int = 3,
37
46
  source_total_counts: pd.Series | None = None,
38
- network_type: str = NEIGHBORHOOD_NETWORK_TYPES.DOWNSTREAM,
47
+ network_type: str = NEIGHBORHOOD_NETWORK_TYPES.HOURGLASS,
39
48
  order: int = 3,
40
49
  verbose: bool = True,
41
50
  top_n: int = 10,
@@ -55,6 +64,8 @@ def find_and_prune_neighborhoods(
55
64
  Compartmentalized species IDs for neighborhood centers
56
65
  precomputed_distances : pd.DataFrame or None
57
66
  If provided, an edgelist of origin->destination path weights and lengths
67
+ min_pw_size: int
68
+ the minimum size of a pathway to be considered
58
69
  source_total_counts: pd.Series | None
59
70
  Optional, A series of the total counts of each source. As produced by
60
71
  source.get_source_total_counts()
@@ -111,9 +122,10 @@ def find_and_prune_neighborhoods(
111
122
  compartmentalized_species=compartmentalized_species,
112
123
  network_type=network_type,
113
124
  order=order,
114
- verbose=verbose,
115
125
  precomputed_neighbors=precomputed_neighbors,
126
+ min_pw_size=min_pw_size,
116
127
  source_total_counts=source_total_counts,
128
+ verbose=verbose,
117
129
  )
118
130
 
119
131
  pruned_neighborhoods = prune_neighborhoods(neighborhoods, top_n=top_n)
@@ -283,7 +295,9 @@ def create_neighborhoods(
283
295
 
284
296
  neighborhood_entities = pd.concat(
285
297
  [
286
- neighborhoods[sc_id]["vertices"].assign(focal_sc_id=sc_id)
298
+ neighborhoods[sc_id][NEIGHBORHOOD_DICT_KEYS.VERTICES].assign(
299
+ focal_sc_id=sc_id
300
+ )
287
301
  for sc_id in neighborhoods.keys()
288
302
  ]
289
303
  ).assign(focal_s_id=s_id)
@@ -321,6 +335,7 @@ def create_neighborhood_prefix(network_type: str, order: int, top_n: int) -> str
321
335
  def load_neighborhoods_by_partition(
322
336
  selected_partition: int,
323
337
  neighborhood_outdir: str,
338
+ cache_dir: str,
324
339
  wiring_approach: str = GRAPH_WIRING_APPROACHES.REGULATORY,
325
340
  ) -> None:
326
341
  """
@@ -343,19 +358,18 @@ def load_neighborhoods_by_partition(
343
358
 
344
359
  """
345
360
 
346
- consensus_root = "/group/cpr/consensus"
347
- consensus_name = "reactome"
348
- consensus_outdir = os.path.join(consensus_root, consensus_name)
349
-
350
361
  if not os.path.isdir(neighborhood_outdir):
351
362
  raise FileNotFoundError(f"{neighborhood_outdir} does not exist")
352
363
 
364
+ if not os.path.isdir(cache_dir):
365
+ raise FileNotFoundError(f"{cache_dir} does not exist")
366
+
353
367
  partition_output = os.path.join(
354
368
  neighborhood_outdir, f"partition_{selected_partition}"
355
369
  )
356
370
  # initialize an empty output
357
371
  if os.path.isdir(partition_output):
358
- print(f"removing existing directory: {partition_output}")
372
+ logger.warning(f"removing existing directory: {partition_output}")
359
373
  shutil.rmtree(partition_output)
360
374
  os.makedirs(partition_output)
361
375
 
@@ -375,7 +389,7 @@ def load_neighborhoods_by_partition(
375
389
 
376
390
  # read model containing Calico curations. this is primarily to support search programs
377
391
  # to not use these switch to refined.pkl
378
- refined_model_pkl_path = os.path.join(consensus_outdir, "curated.pkl")
392
+ refined_model_pkl_path = os.path.join(cache_dir, "curated.pkl")
379
393
  with open(refined_model_pkl_path, "rb") as in_file:
380
394
  refined_model = pickle.load(in_file)
381
395
  refined_model.validate()
@@ -383,12 +397,12 @@ def load_neighborhoods_by_partition(
383
397
  # load the graph
384
398
  napistu_graph = ng_utils.read_network_pkl(
385
399
  model_prefix="curated",
386
- network_dir=consensus_outdir,
400
+ network_dir=cache_dir,
387
401
  directed=True,
388
402
  wiring_approach=wiring_approach,
389
403
  )
390
404
 
391
- all_neighborhoods_df, neighborhoods_dict = load_neighborhoods(
405
+ _, _ = load_neighborhoods(
392
406
  s_ids=parition_sids,
393
407
  sbml_dfs=refined_model,
394
408
  napistu_graph=napistu_graph,
@@ -510,7 +524,7 @@ def find_neighborhoods(
510
524
  sbml_dfs: sbml_dfs_core.SBML_dfs,
511
525
  napistu_graph: ig.Graph,
512
526
  compartmentalized_species: list[str],
513
- network_type: str = "downstream",
527
+ network_type: str = NEIGHBORHOOD_NETWORK_TYPES.HOURGLASS,
514
528
  order: int = 3,
515
529
  min_pw_size: int = 3,
516
530
  precomputed_neighbors: pd.DataFrame | None = None,
@@ -557,10 +571,9 @@ def find_neighborhoods(
557
571
  if not isinstance(network_type, str):
558
572
  raise TypeError(f"network_type was a {type(network_type)} and must be a str")
559
573
 
560
- valid_network_types = ["downstream", "upstream", "hourglass"]
561
- if network_type not in valid_network_types:
574
+ if network_type not in VALID_NEIGHBORHOOD_NETWORK_TYPES:
562
575
  raise ValueError(
563
- f"network_type must be one of {', '.join(valid_network_types)}"
576
+ f"network_type must be one of {', '.join(VALID_NEIGHBORHOOD_NETWORK_TYPES)}"
564
577
  )
565
578
 
566
579
  if not isinstance(order, int):
@@ -634,8 +647,8 @@ def create_neighborhood_dict_entry(
634
647
  nodes in the neighborhood
635
648
  edges: pd.DataFrame
636
649
  edges in the neighborhood
637
- edge_sources: pd.DataFrame
638
- models that edges were derived from
650
+ reaction_sources: pd.DataFrame
651
+ models that reactions were derived from
639
652
  neighborhood_path_entities: dict
640
653
  upstream and downstream dicts representing entities in paths.
641
654
  If the keys are to be included in a neighborhood, the
@@ -669,7 +682,7 @@ def create_neighborhood_dict_entry(
669
682
  )
670
683
 
671
684
  try:
672
- edge_sources = ng_utils.get_minimal_sources_edges(
685
+ reaction_sources = ng_utils.get_minimal_sources_edges(
673
686
  vertices.rename(columns={"name": "node"}),
674
687
  sbml_dfs,
675
688
  min_pw_size=min_pw_size,
@@ -677,7 +690,7 @@ def create_neighborhood_dict_entry(
677
690
  source_total_counts=source_total_counts,
678
691
  )
679
692
  except Exception:
680
- edge_sources = None
693
+ reaction_sources = None
681
694
 
682
695
  # to add weights to the network solve the shortest path problem
683
696
  # from the focal node to each neighbor
@@ -807,7 +820,7 @@ def create_neighborhood_dict_entry(
807
820
  "graph": updated_napistu_graph,
808
821
  "vertices": vertices,
809
822
  "edges": edges,
810
- "edge_sources": edge_sources,
823
+ "reaction_sources": reaction_sources,
811
824
  "neighborhood_path_entities": neighborhood_path_entities,
812
825
  }
813
826
 
@@ -868,8 +881,10 @@ def add_vertices_uri_urls(
868
881
  # add uri urls for each node
869
882
 
870
883
  # add s_ids
871
- neighborhood_species = vertices[vertices["node_type"] == "species"].merge(
872
- sbml_dfs.compartmentalized_species["s_id"],
884
+ neighborhood_species = vertices[
885
+ vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "species"
886
+ ].merge(
887
+ sbml_dfs.compartmentalized_species[SBML_DFS.S_ID],
873
888
  left_on="name",
874
889
  right_index=True,
875
890
  how="left",
@@ -877,24 +892,29 @@ def add_vertices_uri_urls(
877
892
 
878
893
  # add a standard reference identifier
879
894
  neighborhood_species_aug = neighborhood_species.merge(
880
- sbml_dfs.get_uri_urls("species", neighborhood_species["s_id"]),
881
- left_on="s_id",
895
+ sbml_dfs.get_uri_urls("species", neighborhood_species[SBML_DFS.S_ID]),
896
+ left_on=SBML_DFS.S_ID,
882
897
  right_index=True,
883
898
  how="left",
884
899
  # add pharos ids where available
885
900
  ).merge(
886
901
  sbml_dfs.get_uri_urls(
887
- "species", neighborhood_species["s_id"], required_ontology="pharos"
902
+ "species", neighborhood_species[SBML_DFS.S_ID], required_ontology="pharos"
888
903
  ).rename("pharos"),
889
- left_on="s_id",
904
+ left_on=SBML_DFS.S_ID,
890
905
  right_index=True,
891
906
  how="left",
892
907
  )
893
908
 
894
- if sum(vertices["node_type"] == "reaction") > 0:
895
- neighborhood_reactions = vertices[vertices["node_type"] == "reaction"].merge(
909
+ if sum(vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "reaction") > 0:
910
+ neighborhood_reactions = vertices[
911
+ vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "reaction"
912
+ ].merge(
896
913
  sbml_dfs.get_uri_urls(
897
- "reactions", vertices[vertices["node_type"] == "reaction"]["name"]
914
+ "reactions",
915
+ vertices[vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "reaction"][
916
+ "name"
917
+ ],
898
918
  ),
899
919
  left_on="name",
900
920
  right_index=True,
@@ -955,38 +975,54 @@ def prune_neighborhoods(neighborhoods: dict, top_n: int = 100) -> dict:
955
975
  pruned_vertices = _prune_vertex_set(one_neighborhood, top_n=top_n)
956
976
 
957
977
  # reduce neighborhood to this set of high-weight vertices
958
- all_neighbors = pd.DataFrame({"name": one_neighborhood["graph"].vs["name"]})
978
+ all_neighbors = pd.DataFrame(
979
+ {
980
+ NAPISTU_GRAPH_VERTICES.NODE_NAME: one_neighborhood[
981
+ NEIGHBORHOOD_DICT_KEYS.GRAPH
982
+ ].vs[NAPISTU_GRAPH_VERTICES.NODE_NAME]
983
+ }
984
+ )
959
985
  pruned_vertices_indices = all_neighbors[
960
- all_neighbors["name"].isin(pruned_vertices["name"])
986
+ all_neighbors[NAPISTU_GRAPH_VERTICES.NODE_NAME].isin(
987
+ pruned_vertices[NAPISTU_GRAPH_VERTICES.NODE_NAME]
988
+ )
961
989
  ].index.tolist()
962
990
 
963
- pruned_neighborhood = one_neighborhood["graph"].subgraph(
964
- one_neighborhood["graph"].vs[pruned_vertices_indices],
991
+ pruned_neighborhood = one_neighborhood[NEIGHBORHOOD_DICT_KEYS.GRAPH].subgraph(
992
+ one_neighborhood[NEIGHBORHOOD_DICT_KEYS.GRAPH].vs[pruned_vertices_indices],
965
993
  implementation="auto",
966
994
  )
967
995
 
968
996
  pruned_edges = pd.DataFrame([e.attributes() for e in pruned_neighborhood.es])
969
997
 
970
- pruned_reactions = pruned_vertices[pruned_vertices["node_type"] == "reaction"][
971
- "name"
972
- ]
998
+ pruned_reactions = pruned_vertices[
999
+ pruned_vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "reaction"
1000
+ ][NAPISTU_GRAPH_VERTICES.NODE_NAME]
973
1001
 
974
1002
  if pruned_reactions.shape[0] != 0:
975
- if one_neighborhood["edge_sources"] is None:
1003
+ if one_neighborhood[NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES] is None:
976
1004
  # allow for missing source information since this is currently optional
977
- pruned_edge_sources = one_neighborhood["edge_sources"]
1005
+ pruned_reaction_sources = one_neighborhood[
1006
+ NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES
1007
+ ]
978
1008
  else:
979
- pruned_edge_sources = one_neighborhood["edge_sources"][
980
- one_neighborhood["edge_sources"]["r_id"].isin(pruned_reactions)
1009
+ pruned_reaction_sources = one_neighborhood[
1010
+ NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES
1011
+ ][
1012
+ one_neighborhood[NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES][
1013
+ SBML_DFS.R_ID
1014
+ ].isin(pruned_reactions)
981
1015
  ]
982
1016
  else:
983
- pruned_edge_sources = one_neighborhood["edge_sources"]
1017
+ pruned_reaction_sources = one_neighborhood[
1018
+ NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES
1019
+ ]
984
1020
 
985
1021
  pruned_neighborhoods_dict[an_sc_id] = {
986
- "graph": pruned_neighborhood,
987
- "vertices": pruned_vertices,
988
- "edges": pruned_edges,
989
- "edge_sources": pruned_edge_sources,
1022
+ NEIGHBORHOOD_DICT_KEYS.GRAPH: pruned_neighborhood,
1023
+ NEIGHBORHOOD_DICT_KEYS.VERTICES: pruned_vertices,
1024
+ NEIGHBORHOOD_DICT_KEYS.EDGES: pruned_edges,
1025
+ NEIGHBORHOOD_DICT_KEYS.REACTION_SOURCES: pruned_reaction_sources,
990
1026
  }
991
1027
 
992
1028
  return pruned_neighborhoods_dict
@@ -1034,11 +1070,11 @@ def plot_neighborhood(
1034
1070
  }
1035
1071
 
1036
1072
  edge_polarity_colors = {
1037
- "ambiguous": "dimgray",
1038
- "activation": "gold",
1039
- "inhibition": "royalblue",
1040
- "ambiguous activation": "palegoldenrod",
1041
- "ambiguous inhibition": "powerblue",
1073
+ NET_POLARITY.AMBIGUOUS: "dimgray",
1074
+ NET_POLARITY.ACTIVATION: "gold",
1075
+ NET_POLARITY.INHIBITION: "royalblue",
1076
+ NET_POLARITY.AMBIGUOUS_ACTIVATION: "palegoldenrod",
1077
+ NET_POLARITY.AMBIGUOUS_INHIBITION: "powerblue",
1042
1078
  np.nan: "dimgray",
1043
1079
  }
1044
1080
 
@@ -1047,17 +1083,19 @@ def plot_neighborhood(
1047
1083
  visual_style["vertex_size"] = 10
1048
1084
  if name_nodes:
1049
1085
  visual_style["vertex_label"] = [
1050
- textwrap.fill(x, 15) for x in neighborhood_graph.vs["node_name"]
1086
+ textwrap.fill(x, 15)
1087
+ for x in neighborhood_graph.vs[NAPISTU_GRAPH_VERTICES.NODE_NAME]
1051
1088
  ]
1052
1089
  visual_style["vertex_label_color"] = "white"
1053
1090
  visual_style["vertex_label_size"] = 8
1054
1091
  visual_style["vertex_label_angle"] = 90
1055
1092
  visual_style["vertex_label_dist"] = 3
1056
1093
  visual_style["vertex_color"] = [
1057
- color_dict[x] for x in neighborhood_graph.vs["node_type"]
1094
+ color_dict[x] for x in neighborhood_graph.vs[NAPISTU_GRAPH_VERTICES.NODE_TYPE]
1058
1095
  ]
1059
1096
  visual_style["edge_color"] = [
1060
- edge_polarity_colors[x] for x in neighborhood_graph.es["net_polarity"]
1097
+ edge_polarity_colors[x]
1098
+ for x in neighborhood_graph.es[NET_POLARITY.NET_POLARITY]
1061
1099
  ]
1062
1100
  visual_style["layout"] = neighborhood_graph_layout
1063
1101
  visual_style["bbox"] = (plot_size, plot_size)
@@ -1089,8 +1127,8 @@ def _precompute_neighbors(
1089
1127
 
1090
1128
  # check that compartmentalized_species are included in precomputed_distances
1091
1129
  all_cspecies = {
1092
- *precomputed_distances["sc_id_origin"].tolist(),
1093
- *precomputed_distances["sc_id_dest"].tolist(),
1130
+ *precomputed_distances[NAPISTU_EDGELIST.SC_ID_ORIGIN].tolist(),
1131
+ *precomputed_distances[NAPISTU_EDGELIST.SC_ID_DEST].tolist(),
1094
1132
  }
1095
1133
  missing_cspecies = set(compartmentalized_species).difference(all_cspecies)
1096
1134
  if len(missing_cspecies) > 0:
@@ -1105,14 +1143,16 @@ def _precompute_neighbors(
1105
1143
  NEIGHBORHOOD_NETWORK_TYPES.DOWNSTREAM,
1106
1144
  NEIGHBORHOOD_NETWORK_TYPES.HOURGLASS,
1107
1145
  ]:
1108
- valid_origin = precomputed_distances["sc_id_origin"].isin(
1146
+ valid_origin = precomputed_distances[NAPISTU_EDGELIST.SC_ID_ORIGIN].isin(
1109
1147
  compartmentalized_species
1110
1148
  )
1111
1149
  if network_type in [
1112
1150
  NEIGHBORHOOD_NETWORK_TYPES.UPSTREAM,
1113
1151
  NEIGHBORHOOD_NETWORK_TYPES.HOURGLASS,
1114
1152
  ]:
1115
- valid_dest = precomputed_distances["sc_id_dest"].isin(compartmentalized_species)
1153
+ valid_dest = precomputed_distances[NAPISTU_EDGELIST.SC_ID_DEST].isin(
1154
+ compartmentalized_species
1155
+ )
1116
1156
 
1117
1157
  if network_type == NEIGHBORHOOD_NETWORK_TYPES.HOURGLASS:
1118
1158
  cspecies_subset_precomputed_distances = precomputed_distances[
@@ -1149,7 +1189,7 @@ def _precompute_neighbors(
1149
1189
  ]
1150
1190
  # sort by path_weight so we can retain the lowest weight neighbors
1151
1191
  .sort_values("path_weights")
1152
- .groupby("sc_id_origin")
1192
+ .groupby(NAPISTU_EDGELIST.SC_ID_ORIGIN)
1153
1193
  .head(top_n)
1154
1194
  )
1155
1195
 
@@ -1161,9 +1201,9 @@ def _precompute_neighbors(
1161
1201
  ]:
1162
1202
  top_ancestors = (
1163
1203
  close_cspecies_subset_precomputed_distances[
1164
- close_cspecies_subset_precomputed_distances["sc_id_dest"].isin(
1165
- compartmentalized_species
1166
- )
1204
+ close_cspecies_subset_precomputed_distances[
1205
+ NAPISTU_EDGELIST.SC_ID_DEST
1206
+ ].isin(compartmentalized_species)
1167
1207
  ]
1168
1208
  # sort by path_upstream_weights so we can retain the lowest weight neighbors
1169
1209
  # we allow for upstream weights to differ from downstream weights
@@ -1177,7 +1217,7 @@ def _precompute_neighbors(
1177
1217
  # we penalize based on the number of parents of a node when
1178
1218
  # we use it (i.e., the default upstream_weights).
1179
1219
  .sort_values("path_upstream_weights")
1180
- .groupby("sc_id_dest")
1220
+ .groupby(NAPISTU_EDGELIST.SC_ID_DEST)
1181
1221
  .head(top_n)
1182
1222
  )
1183
1223
 
@@ -1217,8 +1257,8 @@ def _precompute_neighbors(
1217
1257
  # an sc_id_origin-specific subgraph
1218
1258
  identity_df = pd.DataFrame(
1219
1259
  {
1220
- "sc_id_origin": compartmentalized_species,
1221
- "sc_id_dest": compartmentalized_species,
1260
+ NAPISTU_EDGELIST.SC_ID_ORIGIN: compartmentalized_species,
1261
+ NAPISTU_EDGELIST.SC_ID_DEST: compartmentalized_species,
1222
1262
  }
1223
1263
  )
1224
1264
 
@@ -1232,14 +1272,16 @@ def _precompute_neighbors(
1232
1272
  downstream_reactions, # type: ignore
1233
1273
  identity_df,
1234
1274
  ]
1235
- )[["sc_id_origin", "sc_id_dest"]].drop_duplicates()
1275
+ )[
1276
+ [NAPISTU_EDGELIST.SC_ID_ORIGIN, NAPISTU_EDGELIST.SC_ID_DEST]
1277
+ ].drop_duplicates()
1236
1278
  elif network_type == NEIGHBORHOOD_NETWORK_TYPES.DOWNSTREAM:
1237
1279
  precomputed_neighbors = pd.concat([top_descendants, downstream_reactions, identity_df])[ # type: ignore
1238
- ["sc_id_origin", "sc_id_dest"]
1280
+ [NAPISTU_EDGELIST.SC_ID_ORIGIN, NAPISTU_EDGELIST.SC_ID_DEST]
1239
1281
  ].drop_duplicates()
1240
1282
  elif network_type == NEIGHBORHOOD_NETWORK_TYPES.UPSTREAM:
1241
1283
  precomputed_neighbors = pd.concat([top_ancestors, upstream_reactions, identity_df])[ # type: ignore
1242
- ["sc_id_origin", "sc_id_dest"]
1284
+ [NAPISTU_EDGELIST.SC_ID_ORIGIN, NAPISTU_EDGELIST.SC_ID_DEST]
1243
1285
  ].drop_duplicates()
1244
1286
  else:
1245
1287
  raise ValueError("This error shouldn't happen")
@@ -1333,11 +1375,11 @@ def _find_neighbors(
1333
1375
  )
1334
1376
 
1335
1377
  if relationship == "descendants":
1336
- bait_id = "sc_id_origin"
1337
- target_id = "sc_id_dest"
1378
+ bait_id = NAPISTU_EDGELIST.SC_ID_ORIGIN
1379
+ target_id = NAPISTU_EDGELIST.SC_ID_DEST
1338
1380
  elif relationship == "ancestors":
1339
- bait_id = "sc_id_dest"
1340
- target_id = "sc_id_origin"
1381
+ bait_id = NAPISTU_EDGELIST.SC_ID_DEST
1382
+ target_id = NAPISTU_EDGELIST.SC_ID_ORIGIN
1341
1383
  else:
1342
1384
  raise ValueError(
1343
1385
  f"relationship must be 'descendants' or 'ancestors' but was {relationship}"
@@ -1348,7 +1390,7 @@ def _find_neighbors(
1348
1390
  precomputed_neighbors[bait_id].isin(compartmentalized_species)
1349
1391
  ]
1350
1392
  .merge(nodes_to_names.rename({"name": target_id}, axis=1))
1351
- .rename({bait_id: "sc_id"}, axis=1)
1393
+ .rename({bait_id: SBML_DFS.SC_ID}, axis=1)
1352
1394
  .drop([target_id], axis=1)
1353
1395
  .assign(relationship=relationship)
1354
1396
  )
@@ -1371,7 +1413,7 @@ def _find_neighbors(
1371
1413
 
1372
1414
  neighbors_df = pd.concat(
1373
1415
  [
1374
- pd.DataFrame({"sc_id": c, "neighbor": x}, index=range(0, len(x)))
1416
+ pd.DataFrame({SBML_DFS.SC_ID: c, "neighbor": x}, index=range(0, len(x)))
1375
1417
  for c, x in zip(compartmentalized_species, neighbors)
1376
1418
  ]
1377
1419
  ).assign(relationship=relationship)
@@ -1402,11 +1444,11 @@ def _find_reactions_by_relationship(
1402
1444
  return None
1403
1445
 
1404
1446
  if relationship == "descendants":
1405
- bait_id = "sc_id_origin"
1406
- target_id = "sc_id_dest"
1447
+ bait_id = NAPISTU_EDGELIST.SC_ID_ORIGIN
1448
+ target_id = NAPISTU_EDGELIST.SC_ID_DEST
1407
1449
  elif relationship == "ancestors":
1408
- bait_id = "sc_id_dest"
1409
- target_id = "sc_id_origin"
1450
+ bait_id = NAPISTU_EDGELIST.SC_ID_DEST
1451
+ target_id = NAPISTU_EDGELIST.SC_ID_ORIGIN
1410
1452
  else:
1411
1453
  raise ValueError(
1412
1454
  f"relationship must be 'descendants' or 'ancestors' but was {relationship}"
@@ -1437,8 +1479,8 @@ def _find_reactions_by_relationship(
1437
1479
  relatives_cspecies = {*relatives, *[uq]}
1438
1480
  # count the number of relative cspecies including each reaction
1439
1481
  rxn_species_counts = sbml_dfs.reaction_species[
1440
- sbml_dfs.reaction_species["sc_id"].isin(relatives_cspecies)
1441
- ].value_counts("r_id")
1482
+ sbml_dfs.reaction_species[SBML_DFS.SC_ID].isin(relatives_cspecies)
1483
+ ].value_counts(SBML_DFS.R_ID)
1442
1484
 
1443
1485
  # retain reactions involving 2+ cspecies.
1444
1486
  # some of these reactions will be irrelevant and will be excluded when
@@ -1486,7 +1528,7 @@ def _prune_vertex_set(one_neighborhood: dict, top_n: int) -> pd.DataFrame:
1486
1528
  neighborhood_vertices = one_neighborhood["vertices"]
1487
1529
 
1488
1530
  indexed_neighborhood_species = neighborhood_vertices[
1489
- neighborhood_vertices["node_type"] == "species"
1531
+ neighborhood_vertices[NAPISTU_GRAPH_VERTICES.NODE_TYPE] == "species"
1490
1532
  ].set_index("node_orientation")
1491
1533
 
1492
1534
  pruned_oriented_neighbors = list()
@@ -133,8 +133,8 @@ def get_minimal_sources_edges(
133
133
 
134
134
  Returns
135
135
  -------
136
- edge_sources: pd.DataFrame
137
- A table of edges and the sources they are assigned to.
136
+ reaction_sources: pd.DataFrame
137
+ A table of reactions and the sources they are assigned to.
138
138
  """
139
139
 
140
140
  nodes = vertices["node"].tolist()
@@ -148,10 +148,10 @@ def get_minimal_sources_edges(
148
148
  if source_df is None:
149
149
  return None
150
150
  else:
151
- edge_sources = source.source_set_coverage(
151
+ reaction_sources = source.source_set_coverage(
152
152
  source_df, source_total_counts, sbml_dfs, min_pw_size=min_pw_size
153
153
  )
154
- return edge_sources.reset_index()[
154
+ return reaction_sources.reset_index()[
155
155
  [SBML_DFS.R_ID, SOURCE_SPEC.PATHWAY_ID, SOURCE_SPEC.NAME]
156
156
  ]
157
157
 
@@ -11,13 +11,19 @@ from napistu import sbml_dfs_core
11
11
  from napistu import utils
12
12
  from napistu.network.ng_core import NapistuGraph
13
13
  from napistu.network.ng_utils import get_minimal_sources_edges
14
- from napistu.constants import NAPISTU_PATH_REQ_VARS
15
- from napistu.constants import MINI_SBO_NAME_TO_POLARITY
16
- from napistu.constants import MINI_SBO_TO_NAME
17
- from napistu.constants import SBML_DFS
18
- from napistu.network.constants import NET_POLARITY
19
- from napistu.network.constants import NAPISTU_GRAPH_EDGES
20
- from napistu.network.constants import VALID_LINK_POLARITIES
14
+ from napistu.constants import (
15
+ MINI_SBO_NAME_TO_POLARITY,
16
+ MINI_SBO_TO_NAME,
17
+ NAPISTU_EDGELIST,
18
+ NAPISTU_PATH_REQ_VARS,
19
+ SBML_DFS,
20
+ )
21
+ from napistu.network.constants import (
22
+ NAPISTU_GRAPH_EDGES,
23
+ NAPISTU_GRAPH_VERTICES,
24
+ NET_POLARITY,
25
+ VALID_LINK_POLARITIES,
26
+ )
21
27
 
22
28
  logger = logging.getLogger(__name__)
23
29
 
@@ -273,8 +279,8 @@ def find_all_shortest_reaction_paths(
273
279
  Nodes in all shortest paths
274
280
  all_shortest_reaction_path_edges_df : pd.DataFrame
275
281
  Edges in all shortest paths
276
- edge_sources : pd.DataFrame
277
- Sources of edge identifying the models where they originated
282
+ reaction_sources : pd.DataFrame
283
+ Sources of reactions identifying the models where they originated
278
284
  paths_graph : igraph.Graph
279
285
  Network formed by all shortest paths
280
286
  """
@@ -297,8 +303,8 @@ def find_all_shortest_reaction_paths(
297
303
  paths = find_shortest_reaction_paths(
298
304
  napistu_graph,
299
305
  sbml_dfs,
300
- origin=one_search["sc_id_origin"],
301
- dest=one_search["sc_id_dest"],
306
+ origin=one_search[NAPISTU_EDGELIST.SC_ID_ORIGIN],
307
+ dest=one_search[NAPISTU_EDGELIST.SC_ID_DEST],
302
308
  weight_var=weight_var,
303
309
  )
304
310
 
@@ -309,12 +315,14 @@ def find_all_shortest_reaction_paths(
309
315
 
310
316
  all_shortest_reaction_paths.append(
311
317
  shortest_paths_df.assign(
312
- origin=one_search["sc_id_origin"], dest=one_search["sc_id_dest"]
318
+ origin=one_search[NAPISTU_EDGELIST.SC_ID_ORIGIN],
319
+ dest=one_search[NAPISTU_EDGELIST.SC_ID_DEST],
313
320
  )
314
321
  )
315
322
  all_shortest_reaction_path_edges.append(
316
323
  shortest_path_edges_df.assign(
317
- origin=one_search["sc_id_origin"], dest=one_search["sc_id_dest"]
324
+ origin=one_search[NAPISTU_EDGELIST.SC_ID_ORIGIN],
325
+ dest=one_search[NAPISTU_EDGELIST.SC_ID_DEST],
318
326
  )
319
327
  )
320
328
 
@@ -332,7 +340,7 @@ def find_all_shortest_reaction_paths(
332
340
  ).reset_index()
333
341
 
334
342
  # at a minimal set of pathway sources to organize reactions
335
- edge_sources = get_minimal_sources_edges(
343
+ reaction_sources = get_minimal_sources_edges(
336
344
  all_shortest_reaction_paths_df,
337
345
  sbml_dfs,
338
346
  min_pw_size=min_pw_size,
@@ -353,13 +361,13 @@ def find_all_shortest_reaction_paths(
353
361
  edges=all_shortest_reaction_path_edges_df.to_dict("records"),
354
362
  directed=directed,
355
363
  vertex_name_attr="node",
356
- edge_foreign_keys=("from", "to"),
364
+ edge_foreign_keys=(NAPISTU_GRAPH_EDGES.FROM, NAPISTU_GRAPH_EDGES.TO),
357
365
  )
358
366
 
359
367
  return (
360
368
  all_shortest_reaction_paths_df,
361
369
  all_shortest_reaction_path_edges_df,
362
- edge_sources,
370
+ reaction_sources,
363
371
  paths_graph,
364
372
  )
365
373
 
@@ -387,9 +395,11 @@ def plot_shortest_paths(napistu_graph: NapistuGraph) -> NapistuGraph.plot:
387
395
  visual_style["vertex_label_size"] = 8
388
396
  visual_style["vertex_label_angle"] = 90
389
397
  visual_style["vertex_color"] = [
390
- color_dict[x] for x in napistu_graph.vs["node_type"]
398
+ color_dict[x] for x in napistu_graph.vs[NAPISTU_GRAPH_VERTICES.NODE_TYPE]
399
+ ]
400
+ visual_style["edge_width"] = [
401
+ math.sqrt(x) for x in napistu_graph.es[NAPISTU_GRAPH_EDGES.WEIGHTS]
391
402
  ]
392
- visual_style["edge_width"] = [math.sqrt(x) for x in napistu_graph.es["weights"]]
393
403
  visual_style["edge_color"] = "dimgray"
394
404
  visual_style["layout"] = paths_graph_layout
395
405
  visual_style["bbox"] = (2000, 2000)