napistu 0.2.5.dev6__py3-none-any.whl → 0.3.1__py3-none-any.whl

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 (107) hide show
  1. napistu/__main__.py +126 -96
  2. napistu/constants.py +35 -41
  3. napistu/context/__init__.py +10 -0
  4. napistu/context/discretize.py +462 -0
  5. napistu/context/filtering.py +387 -0
  6. napistu/gcs/__init__.py +1 -1
  7. napistu/identifiers.py +74 -15
  8. napistu/indices.py +68 -0
  9. napistu/ingestion/__init__.py +1 -1
  10. napistu/ingestion/bigg.py +47 -62
  11. napistu/ingestion/constants.py +18 -133
  12. napistu/ingestion/gtex.py +113 -0
  13. napistu/ingestion/hpa.py +147 -0
  14. napistu/ingestion/sbml.py +0 -97
  15. napistu/ingestion/string.py +2 -2
  16. napistu/matching/__init__.py +10 -0
  17. napistu/matching/constants.py +18 -0
  18. napistu/matching/interactions.py +518 -0
  19. napistu/matching/mount.py +529 -0
  20. napistu/matching/species.py +510 -0
  21. napistu/mcp/__init__.py +7 -4
  22. napistu/mcp/__main__.py +128 -72
  23. napistu/mcp/client.py +16 -25
  24. napistu/mcp/codebase.py +201 -153
  25. napistu/mcp/component_base.py +170 -0
  26. napistu/mcp/config.py +223 -0
  27. napistu/mcp/constants.py +45 -2
  28. napistu/mcp/documentation.py +253 -136
  29. napistu/mcp/documentation_utils.py +13 -48
  30. napistu/mcp/execution.py +372 -305
  31. napistu/mcp/health.py +49 -67
  32. napistu/mcp/profiles.py +10 -6
  33. napistu/mcp/server.py +161 -80
  34. napistu/mcp/tutorials.py +139 -87
  35. napistu/modify/__init__.py +1 -1
  36. napistu/modify/gaps.py +1 -1
  37. napistu/network/__init__.py +1 -1
  38. napistu/network/constants.py +101 -34
  39. napistu/network/data_handling.py +388 -0
  40. napistu/network/ig_utils.py +351 -0
  41. napistu/network/napistu_graph_core.py +354 -0
  42. napistu/network/neighborhoods.py +40 -40
  43. napistu/network/net_create.py +373 -309
  44. napistu/network/net_propagation.py +47 -19
  45. napistu/network/{net_utils.py → ng_utils.py} +124 -272
  46. napistu/network/paths.py +67 -51
  47. napistu/network/precompute.py +11 -11
  48. napistu/ontologies/__init__.py +10 -0
  49. napistu/ontologies/constants.py +129 -0
  50. napistu/ontologies/dogma.py +243 -0
  51. napistu/ontologies/genodexito.py +649 -0
  52. napistu/ontologies/mygene.py +369 -0
  53. napistu/ontologies/renaming.py +198 -0
  54. napistu/rpy2/__init__.py +229 -86
  55. napistu/rpy2/callr.py +47 -77
  56. napistu/rpy2/constants.py +24 -23
  57. napistu/rpy2/rids.py +61 -648
  58. napistu/sbml_dfs_core.py +587 -222
  59. napistu/scverse/__init__.py +15 -0
  60. napistu/scverse/constants.py +28 -0
  61. napistu/scverse/loading.py +727 -0
  62. napistu/utils.py +118 -10
  63. {napistu-0.2.5.dev6.dist-info → napistu-0.3.1.dist-info}/METADATA +8 -3
  64. napistu-0.3.1.dist-info/RECORD +133 -0
  65. tests/conftest.py +22 -0
  66. tests/test_context_discretize.py +56 -0
  67. tests/test_context_filtering.py +267 -0
  68. tests/test_identifiers.py +100 -0
  69. tests/test_indices.py +65 -0
  70. tests/{test_edgelist.py → test_ingestion_napistu_edgelist.py} +2 -2
  71. tests/test_matching_interactions.py +108 -0
  72. tests/test_matching_mount.py +305 -0
  73. tests/test_matching_species.py +394 -0
  74. tests/test_mcp_config.py +193 -0
  75. tests/test_mcp_documentation_utils.py +12 -3
  76. tests/test_mcp_server.py +356 -0
  77. tests/test_network_data_handling.py +397 -0
  78. tests/test_network_ig_utils.py +23 -0
  79. tests/test_network_neighborhoods.py +19 -0
  80. tests/test_network_net_create.py +459 -0
  81. tests/test_network_ng_utils.py +30 -0
  82. tests/test_network_paths.py +56 -0
  83. tests/{test_precomputed_distances.py → test_network_precompute.py} +8 -6
  84. tests/test_ontologies_genodexito.py +58 -0
  85. tests/test_ontologies_mygene.py +39 -0
  86. tests/test_ontologies_renaming.py +110 -0
  87. tests/test_rpy2_callr.py +79 -0
  88. tests/test_rpy2_init.py +151 -0
  89. tests/test_sbml.py +0 -31
  90. tests/test_sbml_dfs_core.py +134 -10
  91. tests/test_scverse_loading.py +778 -0
  92. tests/test_set_coverage.py +2 -2
  93. tests/test_utils.py +121 -1
  94. napistu/mechanism_matching.py +0 -1353
  95. napistu/rpy2/netcontextr.py +0 -467
  96. napistu-0.2.5.dev6.dist-info/RECORD +0 -97
  97. tests/test_igraph.py +0 -367
  98. tests/test_mechanism_matching.py +0 -784
  99. tests/test_net_utils.py +0 -149
  100. tests/test_netcontextr.py +0 -105
  101. tests/test_rpy2.py +0 -61
  102. /napistu/ingestion/{cpr_edgelist.py → napistu_edgelist.py} +0 -0
  103. {napistu-0.2.5.dev6.dist-info → napistu-0.3.1.dist-info}/WHEEL +0 -0
  104. {napistu-0.2.5.dev6.dist-info → napistu-0.3.1.dist-info}/entry_points.txt +0 -0
  105. {napistu-0.2.5.dev6.dist-info → napistu-0.3.1.dist-info}/licenses/LICENSE +0 -0
  106. {napistu-0.2.5.dev6.dist-info → napistu-0.3.1.dist-info}/top_level.txt +0 -0
  107. /tests/{test_obo.py → test_ingestion_obo.py} +0 -0
@@ -1,467 +0,0 @@
1
- """Module containing functions to interoperate with rcpr's netcontextr functions"""
2
-
3
- from __future__ import annotations
4
-
5
- import logging
6
- import os
7
- from tempfile import NamedTemporaryFile
8
- from typing import Any
9
- from typing import Callable
10
- from typing import Iterable
11
-
12
- import pandas as pd
13
- from napistu import sbml_dfs_core
14
- from napistu import utils
15
- from napistu.rpy2 import has_rpy2
16
- from napistu.rpy2 import warn_if_no_rpy2
17
-
18
- from napistu.rpy2.constants import COL_GENE
19
- from napistu.rpy2.constants import COL_PROTEIN_1
20
- from napistu.rpy2.constants import COL_PROTEIN_2
21
- from napistu.rpy2.constants import FIELD_INTERACTIONS
22
- from napistu.rpy2.constants import FIELD_GENES
23
- from napistu.rpy2.constants import FIELD_REACTIONS
24
- from napistu.rpy2.constants import COL_ROLE
25
- from napistu.rpy2.constants import COL_REACTION_ID
26
- from napistu.rpy2.constants import COL_STOICHIOMETRY
27
- from napistu.rpy2.constants import NETCONTEXTR_ONTOLOGY
28
- from napistu.rpy2.constants import NETCONTEXTR_SBO_MAP
29
-
30
- if has_rpy2:
31
- from napistu.rpy2.callr import pandas_to_r_dataframe
32
- from rpy2.robjects import ListVector
33
- import rpy2.robjects as robjs
34
-
35
- logger = logging.getLogger(__name__)
36
-
37
-
38
- @warn_if_no_rpy2
39
- def _none2null(none_obj):
40
- return robjs.r("NULL")
41
-
42
-
43
- @warn_if_no_rpy2
44
- def sbml_dfs_to_rcpr_string_graph(
45
- sbml_dfs: sbml_dfs_core.SBML_dfs,
46
- reaction_data: str = "string",
47
- identifier_ontology: str = "ensembl_gene",
48
- rescale_data: Callable[[pd.DataFrame], pd.DataFrame] | None = lambda x: x / 1000,
49
- ) -> ListVector:
50
- """Converts an sbml_dfs to a rcpr string graph
51
-
52
- This utility converts the sbml_dfs to the format returned
53
- by `rcpr::createStringGraph`.
54
-
55
- Args:
56
- sbml_dfs (SBML_dfs): the sbml_dfs from string.
57
- It is assumed that this sbml_dfs has only reactions with exactly
58
- two reactands and a 1:1 mapping between s_id and sc_id.
59
- reaction_data (str, optional): The reaction data that contains
60
- the string scores. Defaults to 'string'.
61
- identifier_ontology (str, optional): The ontology to use for the
62
- protein identifiers. Defaults to `ensembl_gene` (default in rcpr)
63
- rescale_data (Callable[pd.DataFrame], optional): A function to rescale
64
- the data. Defaults to lambda x: x/1000 (default in rcpr)
65
-
66
- Returns:
67
- This is a list of dataframes almost the same as `rcpr::createStringGraph`:
68
- - `genes`: a dataframe with column `gene`
69
- and the extra column `s_id`, `sc_id`
70
- - `interactions`: a dataframe with columns `protein1`, `protein2` and
71
- the scores from string
72
- and the extra column `r_id`
73
-
74
- The extra columns `s_id` and `r_id` are used to map the genes and reactions
75
- to the sbml_dfs. This is useful for mapping back rcpr results to the
76
- sbml_dfs.
77
- """
78
-
79
- dat_gene = (
80
- sbml_dfs.species["s_Identifiers"]
81
- # Get the identifiers for the given ontology
82
- .map(lambda ids: ids.hoist(identifier_ontology))
83
- .rename(COL_GENE)
84
- .to_frame()
85
- # Merge with compartmentalized species to get the sc_id
86
- .merge(
87
- sbml_dfs.compartmentalized_species[["s_id"]].reset_index(drop=False),
88
- left_index=True,
89
- right_on="s_id",
90
- )[[COL_GENE, "sc_id", "s_id"]]
91
- )
92
-
93
- # Perform validations
94
- if not dat_gene["s_id"].is_unique:
95
- raise ValueError("dat_gene['s_id'] must be unique")
96
- if not dat_gene["sc_id"].is_unique:
97
- raise ValueError("dat_gene['sc_id'] must be unique")
98
- if not dat_gene[COL_GENE].is_unique:
99
- raise ValueError("dat_gene[COL_GENE] must be unique")
100
- if dat_gene[COL_GENE].hasnans:
101
- raise ValueError("dat_gene[COL_GENE] must not have NaNs")
102
-
103
- # Reshape into the correct format
104
- dat_reactions = dat_gene[["sc_id", COL_GENE]].merge(
105
- sbml_dfs.reaction_species[["r_id", "sc_id"]], on="sc_id"
106
- )[[COL_GENE, "r_id"]]
107
- # assert that this has the correct shape, ie 2x the shape of the number
108
- # of reactions
109
- if dat_reactions.shape[0] != 2 * sbml_dfs.reactions.shape[0]:
110
- raise ValueError("There should be exactly 2 reactants per reaction")
111
-
112
- # This is the fastest way I found to reshape this into the
113
- # Edgelist format
114
- dat_reactions["flag"] = dat_reactions["r_id"].duplicated()
115
- dat_interactions = dat_reactions.pivot(
116
- index="r_id", columns="flag", values=COL_GENE
117
- )
118
- dat_interactions.columns = pd.Index([COL_PROTEIN_1, COL_PROTEIN_2], dtype=object)
119
- if rescale_data is not None:
120
- reaction_df = rescale_data(sbml_dfs.reactions_data[reaction_data])
121
- else:
122
- reaction_df = sbml_dfs.reactions_data[reaction_data]
123
-
124
- dat_interactions = dat_interactions.join(reaction_df).reset_index(drop=False)
125
-
126
- genes = pandas_to_r_dataframe(dat_gene)
127
- interactions = pandas_to_r_dataframe(dat_interactions)
128
-
129
- out = ListVector({FIELD_GENES: genes, FIELD_INTERACTIONS: interactions})
130
- return out
131
-
132
-
133
- @warn_if_no_rpy2
134
- def load_and_clean_hpa_data(
135
- rcpr,
136
- uri_hpa: str,
137
- ):
138
- """Load and cleans HPA data using rcpr
139
-
140
- Args:
141
- rcpr (): The rpy2 rcpr object
142
- uri_hpa (str): The uri of the HPA data
143
-
144
- Returns:
145
- rpy2 object: The cleaned HPA data
146
- """
147
-
148
- with NamedTemporaryFile() as f:
149
- # R cannot work with gcs uris
150
- # thus download the file to a temporary
151
- # location incase it is a gcs uri
152
- if os.path.exists(uri_hpa):
153
- # if the file is already a local
154
- # file, just use it
155
- path_hpa = uri_hpa
156
- else:
157
- path_hpa = f.name
158
- utils.copy_uri(uri_hpa, path_hpa)
159
-
160
- hpa_localization_data = rcpr.load_and_clean_hpa_data(path_hpa)
161
- return hpa_localization_data
162
-
163
-
164
- @warn_if_no_rpy2
165
- def load_and_clean_gtex_data(rcpr_rpy2, uri_gtex: str, by_tissue_zfpkm: bool = False):
166
- """Load and cleans GTEx data using rcpr
167
-
168
- Args:
169
- rcpr_rpy2 (): The rpy2 rcpr object
170
- uri_gtex (str): The uri of the GTEx data
171
- by_tissue_zfpkm (bool, optional): Whether to return the data normalized
172
- by tissue using zfpkm. Defaults to False.
173
- Returns:
174
- rpy2 object: The cleaned GTEx data
175
- """
176
- with NamedTemporaryFile() as f:
177
- # R cannot work with gcs uris
178
- # thus download the file to a temporary
179
- # location incase it is a gcs uri
180
- if os.path.exists(uri_gtex):
181
- # if the file is already a local
182
- # file, just use it
183
- path_gtex = uri_gtex
184
- else:
185
- path_gtex = f.name
186
- utils.copy_uri(uri_gtex, path_gtex)
187
-
188
- gtex_tissue_data = rcpr_rpy2.load_and_clean_gtex_data(path_gtex)
189
-
190
- if by_tissue_zfpkm:
191
- gtex_tissue_data = rcpr_rpy2.gene_expression_by_tissue(gtex_tissue_data)
192
- return gtex_tissue_data
193
-
194
-
195
- def annotate_genes(
196
- rcpr, rcpr_graph: ListVector, data, field_name: str, **kwargs
197
- ) -> ListVector:
198
- """Annotates the genes in the graph with the given gene data
199
-
200
- See the rcpr documentation about the exact format
201
- required.
202
-
203
- Args:
204
- rcpr (): The rpy2 rcpr object
205
- rcpr_graph (ListVector): The graph to annotate
206
- data (complicated): "
207
- field_name (str): The name of the column in the gene data to annotate with
208
-
209
- Returns:
210
- ListVector: The annotated graph
211
- """
212
- # Annotate the genes
213
- rcpr_graph_annot = rcpr.annotate_genes(rcpr_graph, data, field_name, **kwargs)
214
- return rcpr_graph_annot
215
-
216
-
217
- def trim_network_by_gene_attribute(
218
- rcpr,
219
- rcpr_graph: ListVector,
220
- field_name: str,
221
- field_value: Any = None,
222
- **kwargs,
223
- ) -> ListVector:
224
- """Trims the network by a gene attribute
225
-
226
- See the R function `rcpr::trim_network_by_gene_attribute` for
227
- more details.
228
-
229
- Args:
230
- rcpr (): The rpy2 rcpr object
231
- rcpr_graph (ListVector): The graph to trim
232
- field_name (str): The name of the column in the gene data to trim by
233
- field_value (Any): One or more values to trim by
234
-
235
- Returns:
236
- ListVector: The trimmed graph
237
- """
238
- if field_value is None:
239
- field_value = robjs.r("NaN")
240
- rcpr_graph_trimmed = rcpr.trim_network_by_gene_attribute(
241
- rcpr_graph, field_name=field_name, field_value=field_value, **kwargs
242
- )
243
- return rcpr_graph_trimmed
244
-
245
-
246
- def apply_context_to_sbml_dfs(
247
- sbml_dfs: sbml_dfs_core.SBML_dfs,
248
- rcpr_graph: ListVector,
249
- inplace=True,
250
- remove_species=False,
251
- ) -> sbml_dfs_core.SBML_dfs:
252
- """Applies the context to the SBML dfs
253
-
254
- This is currently an in-place modification of
255
- the sbml_dfs object.
256
-
257
- Args:
258
- sbml_dfs (SbmlDfs): The SBML dfs to apply the context to
259
- rcpr_graph (ListVector): The graph to apply the context from
260
- inplace (bool, optional): Whether to modify the sbml_dfs in-place
261
- when applying the context. Defaults to True. "False" not yet implemented.
262
- remove_species (bool, optional): Whether to remove
263
- (compartmentalized) species that are no longer in the reactions.
264
- Defaults to False.
265
-
266
- Returns:
267
- SbmlDfs: The SBML dfs with the context applied
268
- """
269
- if not inplace:
270
- raise NotImplementedError("Only inplace is currently supported")
271
-
272
- # r_ids after trimming
273
- r_ids_new = set(rcpr_graph.rx("interactions")[0].rx("r_id")[0])
274
-
275
- # find original r_ids
276
- r_ids_old = set(sbml_dfs.reactions.index.tolist())
277
-
278
- # find the r_ids that are in the original but not in the new
279
- r_ids_to_remove = r_ids_old - r_ids_new
280
-
281
- # assert that no new r_ids were added
282
- if len(diff_ids := r_ids_new - r_ids_old) != 0:
283
- raise ValueError(
284
- f"New reactions present in rcpr, not present in smbl_dfs: {', '.join(diff_ids)}"
285
- )
286
-
287
- sbml_dfs.remove_reactions(r_ids_to_remove, remove_species=remove_species)
288
-
289
- return sbml_dfs
290
-
291
-
292
- def sbml_dfs_to_rcpr_reactions(
293
- sbml_dfs: sbml_dfs_core.SBML_dfs,
294
- identifier_ontology: str = NETCONTEXTR_ONTOLOGY,
295
- ) -> ListVector:
296
- """Converts an sbml_dfs to a rcpr reaction graph
297
-
298
- This utility converts the sbml_dfs to the format validated by
299
- by `rcpr::validate_netcontextr_reactions`.
300
-
301
- It converts the smbl_dfs into a reaction graph by:
302
- - Building the `reactions` dataframe:
303
- - Using the `species` identifiers to map `reaction_species`
304
- to `genes` using the `identifier_ontology`.
305
- Note that one species may be split into multiple `genes`
306
- and multiple species may be combined into a single `gene`.
307
- - Converting `sbo_terms` to roles.
308
- - renaming `r_id` to `reaction_id`
309
- - Building `genes` dataframe by taking all unique `genes` from the `reactions`
310
-
311
- Args:
312
- sbml_dfs (SBML_dfs): an sbml_dfs.
313
- identifier_ontology (str, optional): The ontology to use for the
314
- identifiers. Defaults to `ensembl_gene` (default in rcpr)
315
-
316
- Returns:
317
- This is a list of dataframes that validate with validate_netcontextr_reactions:
318
- - `genes`: a dataframe with column `gene`
319
- - `reactions`: a dataframe with columns "gene", "reaction_id", "role", "rsc_id"
320
- representing the reaction data split up into individual reactions.
321
- """
322
-
323
- # Get the reactions
324
- dat_reactions = _get_reactions(sbml_dfs, identifier_ontology)
325
- # Get the genes
326
- dat_gene = dat_reactions[[COL_GENE]].drop_duplicates()
327
- # Note that no 1:1 mapping between genes and species can be made
328
- # as multiple species could have the same gene annotation
329
- # and also even one species could have multiple gene identifiers
330
- genes = pandas_to_r_dataframe(dat_gene)
331
- reactions = pandas_to_r_dataframe(dat_reactions)
332
-
333
- out = ListVector({FIELD_GENES: genes, FIELD_REACTIONS: reactions})
334
- return out
335
-
336
-
337
- def trim_reactions_by_gene_attribute(
338
- rcpr,
339
- rcpr_reactions: ListVector,
340
- field_name: str,
341
- field_value: Any = None,
342
- **kwargs,
343
- ) -> ListVector:
344
- """Trims rcpr reactions by a gene attribute
345
-
346
- See the R function `rcpr::trim_reactions_by_gene_attribute` for
347
- more details.
348
-
349
- Args:
350
- rcpr (): The rpy2 rcpr object
351
- rcpr_reactions (ListVector): The graph to trim
352
- field_name (str): The name of the column in the gene data to trim by
353
- field_value (Any): One or more values to trim by
354
-
355
- Returns:
356
- ListVector: The trimmed graph
357
- """
358
- if field_value is None:
359
- field_value = robjs.r("NaN")
360
- rcpr_reactions_trimmed = rcpr.trim_reactions_by_gene_attribute(
361
- rcpr_reactions, field_name=field_name, field_value=field_value, **kwargs
362
- )
363
- return rcpr_reactions_trimmed
364
-
365
-
366
- def apply_reactions_context_to_sbml_dfs(
367
- sbml_dfs: sbml_dfs_core.SBML_dfs,
368
- rcpr_reactions: ListVector,
369
- considered_reactions: Iterable[str] | None = None,
370
- inplace=True,
371
- remove_species=False,
372
- ) -> sbml_dfs_core.SBML_dfs:
373
- """Applies the context to the SBML dfs
374
-
375
- This is currently an in-place modification of
376
- the sbml_dfs object.
377
-
378
- Args:
379
- sbml_dfs (sbml_dfs_core.SBML_dfs): The SBML dfs to apply the context to
380
- rcpr_reactions (ListVector): The contextualized
381
- considered_reactions (Iterable[str], optional): The reactions that were
382
- considered for contextualisation. If None, all reactions that are
383
- in the sbml_dfs are considered and filtered out if they are not part of
384
- the rcpr_reactions. If provided, only reactions considered and not part
385
- of the rcpr_reactions are removed. Defaults to None.
386
- inplace (bool, optional): Whether to apply the context inplace.
387
- Only True currently implemented.
388
- remove_species (bool, optional): Whether to remove
389
- (compartmentalized) species that are no longer in the reactions.
390
- Defaults to False.
391
-
392
- Returns:
393
- SbmlDfs: The SBML dfs with the context applied
394
- """
395
- if not inplace:
396
- raise NotImplementedError("Only inplace is currently supported")
397
-
398
- # r_ids after trimming
399
- r_ids_new = _get_rids_from_rcpr_reactions(rcpr_reactions)
400
-
401
- # find original r_ids
402
- if considered_reactions is None:
403
- r_ids_old = set(sbml_dfs.reactions.index.tolist())
404
- else:
405
- r_ids_old = set(considered_reactions)
406
-
407
- # find the r_ids that are in the original but not in the new
408
- r_ids_to_remove = r_ids_old - r_ids_new
409
-
410
- # assert that no new r_ids were added
411
- if len(diff_ids := r_ids_new - r_ids_old) != 0:
412
- raise ValueError(
413
- "New reactions present in rcpr, not present in the considered "
414
- f"reactions: {', '.join(diff_ids)}"
415
- )
416
-
417
- sbml_dfs.remove_reactions(r_ids_to_remove, remove_species=remove_species)
418
-
419
- return sbml_dfs
420
-
421
-
422
- def _get_rids_from_rcpr_reactions(rcpr_reactions: ListVector) -> set[str]:
423
- """Gets the r_ids from the rcpr reactions"""
424
- return set(rcpr_reactions.rx(FIELD_REACTIONS)[0].rx(COL_REACTION_ID)[0])
425
-
426
-
427
- def _get_reactions(
428
- sbml_dfs: sbml_dfs_core.SBML_dfs, identifier_ontology: str = NETCONTEXTR_ONTOLOGY
429
- ) -> pd.DataFrame:
430
- """Gets the reactions from the sbml_dfs"""
431
- dat_reaction = (
432
- sbml_dfs.species["s_Identifiers"]
433
- # Get the identifiers for the given ontology
434
- .map(lambda ids: ids.hoist(identifier_ontology, squeeze=False))
435
- .map(lambda x: x if len(x) > 0 else None)
436
- .dropna()
437
- .rename(COL_GENE)
438
- .to_frame()
439
- .explode(COL_GENE)
440
- # Merge with compartmentalized species to get the sc_id
441
- .merge(
442
- sbml_dfs.compartmentalized_species[["s_id"]].reset_index(drop=False),
443
- left_index=True,
444
- right_on="s_id",
445
- )[[COL_GENE, "sc_id"]]
446
- .merge(
447
- sbml_dfs.reaction_species[
448
- ["r_id", "sc_id", "sbo_term", "stoichiometry"]
449
- ].reset_index(drop=False),
450
- on="sc_id",
451
- )
452
- .assign(**{COL_ROLE: lambda x: x["sbo_term"].map(NETCONTEXTR_SBO_MAP)})
453
- .rename({"r_id": COL_REACTION_ID, "stoichiometry": COL_STOICHIOMETRY}, axis=1)
454
- )
455
- fil = dat_reaction[COL_ROLE].isna()
456
- if fil.sum() > 0:
457
- missing_sbo_terms = dat_reaction.loc[fil, "sbo_term"].unique()
458
- logger.warning(
459
- f"Found {fil.sum()} reactions had an sbo term that was not"
460
- "mappable to a rcpr role. These are ignored. "
461
- f"The sbo terms are: {', '.join(missing_sbo_terms)}"
462
- )
463
-
464
- dat_reaction = dat_reaction.loc[~fil, :]
465
- return dat_reaction[
466
- [COL_ROLE, COL_GENE, COL_REACTION_ID, COL_STOICHIOMETRY, "rsc_id"]
467
- ]
@@ -1,97 +0,0 @@
1
- napistu/__init__.py,sha256=HEXcB6w8PCTD-tm4rq7AoFi7ufZNDuoG3EoM0kz9aPY,269
2
- napistu/__main__.py,sha256=i1OyReHD58GjyGYShXmMuBfA0VoGBF9dirg2nA4JCa8,28334
3
- napistu/consensus.py,sha256=UbKKSLP1O46e3Rk8d_aqNlhRHeR3sZRztAgIm7-XK6Y,69960
4
- napistu/constants.py,sha256=2I-JxgvZ1_0VG2J9wHkxIM9-axRS5_zp5KhbRJZzbYk,15431
5
- napistu/identifiers.py,sha256=cgtg4tankKnao4DZfAmvDUSf1fZxnsYSgblVKcpBPFQ,32316
6
- napistu/indices.py,sha256=UeJjjsYs0sGvZIKz1y4ZQ6aUkABn-6TCUDZ2VCVT9JI,7534
7
- napistu/mechanism_matching.py,sha256=sgHV3KI5zYKVBBzebBLWYo_LOeVwuMX9t4WD7kWmepY,49923
8
- napistu/sbml_dfs_core.py,sha256=lHdfLc1cnwMuKJa-cpQrHlH9nafOfqIQXd89U6k1iGg,80262
9
- napistu/sbml_dfs_utils.py,sha256=LJo6WWTrmnE58ZLDuibeeHk88uCdfunWdja7XxdZpps,11525
10
- napistu/source.py,sha256=9uUJrkY4jHaKlzz5nNcQQ8wUAep2pfqhlHxHw1hmEkI,13648
11
- napistu/utils.py,sha256=Fo1cidsXIGKsHYMo7NdPpguUK4nOuhuS9raYmx28_94,30203
12
- napistu/gcs/__init__.py,sha256=1kqmRHlEyI7VpILzurZb1URwC_UIc1PTMEBHQnjXW6s,246
13
- napistu/gcs/constants.py,sha256=g6PaU99GY5XvaRHx4BGmWHUpcJ36-Zh_GzeNVOeHviM,2856
14
- napistu/gcs/downloads.py,sha256=SvGv9WYr_Vt3guzyz1QiAuBndeKPTBtWSFLj1-QbLf4,6348
15
- napistu/gcs/utils.py,sha256=eLSsvewWJdCguyj2k0ozUGP5BTemaE1PZg41Z3aY5kM,571
16
- napistu/ingestion/__init__.py,sha256=1kqmRHlEyI7VpILzurZb1URwC_UIc1PTMEBHQnjXW6s,246
17
- napistu/ingestion/bigg.py,sha256=XPJZv64mrIMCuKe1mjQfS5QPR9tmengGvndSjc3QFLA,5559
18
- napistu/ingestion/constants.py,sha256=KrLFyIGI5WsyOROwRo6QIv0GZXeeSAM4BNX7rSw01QE,9856
19
- napistu/ingestion/cpr_edgelist.py,sha256=eVT9M7gmdBuGHcAYlvkD_zzvTtyzXufKWjwDiT8OxF4,3572
20
- napistu/ingestion/identifiers_etl.py,sha256=6ppDUA6lEZurdmVbiFLOUzphYbr-hndMhtqsQnq_yAc,5009
21
- napistu/ingestion/obo.py,sha256=AQkIPWbjA464Lma0tx91JucWkIwLjC7Jgv5VHGRTDkE,9601
22
- napistu/ingestion/psi_mi.py,sha256=5eJjm7XWogL9oTyGqR52kntHClLwLsTePKqCvUGyi-w,10111
23
- napistu/ingestion/reactome.py,sha256=Hn9X-vDp4o_HK-OtaQvel3vJeZ8_TC1-4N2rruK9Oks,7099
24
- napistu/ingestion/sbml.py,sha256=gK6_jHgo6oaiG16WlrbBSvxq_0VzFR4a5fG9IQrp5bU,24153
25
- napistu/ingestion/string.py,sha256=tsaHrjppgFbl9NnRcB2DytpoontqrpfQL65zD9HPgEM,11668
26
- napistu/ingestion/trrust.py,sha256=ccjZc_eF3PdxxurnukiEo_e0-aKc_3z22NYbaJBtHdY,9774
27
- napistu/ingestion/yeast.py,sha256=bwFBNxRq-dLDaddgBL1hpfZj0eQ56nBXyR_9n0NZT9Y,5233
28
- napistu/mcp/__init__.py,sha256=gDkP4J4vAjgq96_760lXKDURPUpQxVIxaRO9XzYrqdA,1970
29
- napistu/mcp/__main__.py,sha256=UcxLERiTFp7H8OvA5bQ1KhCnmOQKp1DsQ4oYr5WFVw0,6410
30
- napistu/mcp/client.py,sha256=nTMKgEG-yEGM0bS54LXK85jVtlJvDXOniWsQbnj4FOI,6616
31
- napistu/mcp/codebase.py,sha256=H32R5vRJqsLpClURIUpemTO8F_YnFW1RDdaeEbYWotk,5674
32
- napistu/mcp/codebase_utils.py,sha256=r1nbDmGzq-NaH9cT11jC53mEjszQpwQ0uZUJkMHvgVs,10567
33
- napistu/mcp/constants.py,sha256=s0anHxVre6i6JYFQimB_ppRLDdqiCxbMHNVEYvf6O0U,2852
34
- napistu/mcp/documentation.py,sha256=L99GF5ilhq7CpzYkRy2BeOzKVQnolK_S9wqf8ChZY2Y,5216
35
- napistu/mcp/documentation_utils.py,sha256=JH3BfVk2dpSLUvnC77iaeTIRknOBpNMBQ2qhquUhuJM,7099
36
- napistu/mcp/execution.py,sha256=cYhLzIvihtLjG4J195FZuCM8uVihtgW-R6J4zuPAY5s,12422
37
- napistu/mcp/health.py,sha256=l6Y8houdip7IOtYZ_pPJrFAFfynN6PntVJwdkcoQKmg,8249
38
- napistu/mcp/profiles.py,sha256=Nbr1e-n7muJMcY0HxuEJQePUQWPM2koQ9roVLEZa7Pg,2027
39
- napistu/mcp/server.py,sha256=gCDcrUVirheJTF_P0NoKZSVD8VH51eKyDb21kx7P24c,6041
40
- napistu/mcp/tutorials.py,sha256=QMX32aWaqRqj4vIc_PVDdT_t55ZBpw4xOWnfQyewZMk,3395
41
- napistu/mcp/tutorials_utils.py,sha256=6_s6FP2i8Na6VaKVzLDnSnA5JQVgyd3ZHEIz8HSHtzU,6599
42
- napistu/mcp/utils.py,sha256=WB4c6s8aPZLgi_Wvhhq0DE8Cnz2QGff0V8hrF1feVRg,1296
43
- napistu/modify/__init__.py,sha256=1kqmRHlEyI7VpILzurZb1URwC_UIc1PTMEBHQnjXW6s,246
44
- napistu/modify/constants.py,sha256=H6K6twzPlxt0yp6QLAxIx0Tp8YzYhtKKXPdmXi5V_QQ,3689
45
- napistu/modify/curation.py,sha256=sQeSO53ZLdn14ww2GSKkoP0vJnDpAoSWb-YDjUf5hDQ,21743
46
- napistu/modify/gaps.py,sha256=YrILH3e9kXIxm6kTrPYHZyfrUH5j5eLC-CHZ-A6XGhA,26739
47
- napistu/modify/pathwayannot.py,sha256=xuBSMDFWbg_d6-Gzv0Td3Q5nnFTa-Qzic48g1b1AZtQ,48081
48
- napistu/modify/uncompartmentalize.py,sha256=U5X4Q7Z-YIkC8_711x3sU21vTVdv9rKfauwz4JNzl6c,9690
49
- napistu/network/__init__.py,sha256=1kqmRHlEyI7VpILzurZb1URwC_UIc1PTMEBHQnjXW6s,246
50
- napistu/network/constants.py,sha256=jz8vRjgns74piUcvmoIP_f-8s9w15SxWAEw2lf6XmDY,3661
51
- napistu/network/neighborhoods.py,sha256=TkZjFWqmrYVxQftl1-2oLKOo4PDIFjxYlPjUHHIQOBk,55931
52
- napistu/network/net_create.py,sha256=G5xQNEZgrBAspdFbkkSyvDBSzWW1v1qZozP0YknfhS8,67331
53
- napistu/network/net_propagation.py,sha256=3PVKZ3zNkX_UZ6nq1LhnxgrojPF7BnyDVZjPKmwkf6I,3990
54
- napistu/network/net_utils.py,sha256=G_ciC7WinXnrGBMeNkv0-jyDNcT9EXBfmS8mBxLbQJE,20230
55
- napistu/network/paths.py,sha256=a2J3JWIdMufdNs8Amh6I7s3TOVD2EzLV9khqbWHvGlA,16652
56
- napistu/network/precompute.py,sha256=83Vr2pxCmEtJJmE_Lq1BI-pEmESDNG0N7vByXjBf_oQ,7517
57
- napistu/rpy2/__init__.py,sha256=B9tZHiEp6bvysjqvBRQ1aGY493Ks9kouwb0pW7KsKqA,4100
58
- napistu/rpy2/callr.py,sha256=76ICWj7Jso-qrYLNfiV-DgPyrMTdRXz_EhyGOD9CbFM,4301
59
- napistu/rpy2/constants.py,sha256=JpJqsxImZis8fFFfePXYdbkhUZhXDZoHSHVf92w1h8U,2619
60
- napistu/rpy2/netcontextr.py,sha256=fZKd3NXXu5nfB-z0UW6wedxBkZA8dJ4uB1uOD9wI_eg,16523
61
- napistu/rpy2/rids.py,sha256=lKyOujjdosuN-Oc54uCQI1nKchTx4zXPwgFbG7QX7d8,24153
62
- napistu-0.2.5.dev6.dist-info/licenses/LICENSE,sha256=kW8wVT__JWoHjl2BbbJDAZInWa9AxzJeR_uv6-i5x1g,1063
63
- tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
- tests/conftest.py,sha256=Xj5PWhedsR7HELbJfBY5XXzv_BAHbFMc1K2n6Nrbrno,2595
65
- tests/test_consensus.py,sha256=3dJvvPsPG7bHbw_FY4Pm647N_Gt_Ud9157OKYfPCUd4,9502
66
- tests/test_constants.py,sha256=gJLDv7QMeeBiiupyMazj6mumk20KWvGMgm2myHMKKfc,531
67
- tests/test_curation.py,sha256=-Q2J0D7qs9PGjHZX-rM4NxRLLdwxoapytSo_98q9ItY,3864
68
- tests/test_edgelist.py,sha256=bdEtQJdd4MeQsNtng9afHYNVDsEy0U07sfVwguAdIBM,560
69
- tests/test_gaps.py,sha256=mGGeyx1vUnmEOF__bsqfCYq9Y8a1P-9mefqna4Qgc_k,4062
70
- tests/test_gcs.py,sha256=p_uQWuY2TcGj3zV3qFC-GXBqj4St8YENR_XRpQ6UH5g,570
71
- tests/test_identifiers.py,sha256=RyuPAMhYI8cDOl2r62idweLxgy7rAs9omeZQ62h56kY,5019
72
- tests/test_igraph.py,sha256=vSGP13Bwaoznk6LsnOXoARxyh7VoT4fHvvTYcHT2lkw,11353
73
- tests/test_indices.py,sha256=-TrKfX4qXsofg_TPQEhHaQc_CuQMEd4_0maJgGCgSfE,2468
74
- tests/test_mcp_documentation_utils.py,sha256=lh9cKQIyMKntFVRG7Ui6oJ-gkawDta1Rfj_GEVG5k4M,470
75
- tests/test_mechanism_matching.py,sha256=RYNlOG2voocPMv78xuvVIDZ8GpPyEEXaQXpkokn-EEI,28813
76
- tests/test_net_propagation.py,sha256=9pKkUdduWejH4iKNCJXKFzAkdNpCfrMbiUWySgI_LH4,3244
77
- tests/test_net_utils.py,sha256=QxZvZ5dPt-Of4zTOKe3_4Lv1VTZI3ClHiJWt2NJXZd0,4708
78
- tests/test_netcontextr.py,sha256=PKH0D-8EL0HNrCMtF-fAaYv5Lao4mwVPDZLQ5LHJXqc,3399
79
- tests/test_obo.py,sha256=47qNCElPzu2nA36Oq83Dqp1RGhITqztjl7UyZ5cMsj4,959
80
- tests/test_pathwayannot.py,sha256=bceosccNy9tgxQei_7j7ATBSSvBSxOngJvK-mAzR_K0,3312
81
- tests/test_precomputed_distances.py,sha256=ht7lVz0wGOOQl9UTI1o9ftm0Dk7q8E40UV2jxVmE-Tg,7203
82
- tests/test_rpy2.py,sha256=beihvGlWsQA9U7V3tfqBIOUL-S8m8Nj84Bg2Wt2sNH8,1491
83
- tests/test_sbml.py,sha256=oEngnwT19GVnPYeoqoTU_p2o3wVFoHXQB50IwO5Ru_M,1319
84
- tests/test_sbml_dfs_core.py,sha256=iF_xDrfWFIoxYUjFJY7tUSK4Yw-Vi6YWNockMqhGvUA,11953
85
- tests/test_sbml_dfs_utils.py,sha256=onFWdhrTix30XR1-CMrMXld37BYxEGi6TZrweugLDzI,505
86
- tests/test_sbo.py,sha256=x_PENFaXYsrZIzOZu9cj_Wrej7i7SNGxgBYYvcigLs0,308
87
- tests/test_set_coverage.py,sha256=gM6Zl3MhVRHUi0_z0ISqpeXckWT8XdpXb58ipCoWyHU,1606
88
- tests/test_source.py,sha256=hT0IlpexR5zP0OhWl5BBaho9d1aCYQlFZLwRIRRnw_Y,1969
89
- tests/test_uncompartmentalize.py,sha256=nAk5kfAVLU9a2VWe2x2HYVcKqj-EnwmwddERIPRax8c,1289
90
- tests/test_utils.py,sha256=B9frW_ugWtGWsM-q7Lw7pnfE9a_d6LZTow9BrWU9UDw,17939
91
- tests/utils.py,sha256=SoWQ_5roJteFGcMaOeEiQ5ucwq3Z2Fa3AAs9iXHTsJY,749
92
- tests/test_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
93
- napistu-0.2.5.dev6.dist-info/METADATA,sha256=ceZlEGrJznAanVPi8UFIeB7sRe9l6wMvoSPKte11seE,3202
94
- napistu-0.2.5.dev6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
95
- napistu-0.2.5.dev6.dist-info/entry_points.txt,sha256=_QnaPOvJNA3IltxmZgWIiBoen-L1bPYX18YQfC7oJgQ,41
96
- napistu-0.2.5.dev6.dist-info/top_level.txt,sha256=Gpvk0a_PjrtqhYcQ9IDr3zR5LqpZ-uIHidQMIpjlvhY,14
97
- napistu-0.2.5.dev6.dist-info/RECORD,,