napistu 0.3.2.dev1__py3-none-any.whl → 0.3.3__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.
@@ -8,7 +8,6 @@ from napistu import sbml_dfs_core
8
8
  from napistu import source
9
9
  from napistu import utils
10
10
  from napistu.constants import BQB
11
- from napistu.constants import COMPARTMENTS
12
11
  from napistu.constants import MINI_SBO_FROM_NAME
13
12
  from napistu.ingestion import napistu_edgelist
14
13
  from napistu.ingestion.constants import SBML_SPECIES_DICT_IDENTIFIERS
@@ -28,6 +27,7 @@ from napistu.ingestion.constants import STRING_UPSTREAM_COMPARTMENT
28
27
  from napistu.ingestion.constants import STRING_UPSTREAM_NAME
29
28
  from napistu.ingestion.constants import STRING_URL_EXPRESSIONS
30
29
  from napistu.ingestion.constants import STRING_VERSION
30
+ from napistu.ingestion.constants import GENERIC_COMPARTMENT
31
31
  from fs import open_fs
32
32
 
33
33
  logger = logging.getLogger(__name__)
@@ -297,7 +297,7 @@ def _build_interactor_edgelist(
297
297
  downstream_col_name: str = STRING_TARGET,
298
298
  add_reverse_interactions: bool = False,
299
299
  sbo_term: str = "interactor",
300
- compartment: str = COMPARTMENTS["CELLULAR_COMPONENT"],
300
+ compartment: str = GENERIC_COMPARTMENT,
301
301
  ) -> pd.DataFrame:
302
302
  """Format STRING interactions as reactions."""
303
303
 
napistu/modify/gaps.py CHANGED
@@ -15,18 +15,18 @@ from napistu import utils
15
15
  from napistu.network import net_create
16
16
 
17
17
  from napistu.constants import SBML_DFS
18
- from napistu.constants import COMPARTMENTS
19
18
  from napistu.constants import IDENTIFIERS
20
19
  from napistu.constants import MINI_SBO_FROM_NAME
21
20
  from napistu.constants import SBOTERM_NAMES
22
21
  from napistu.constants import SOURCE_SPEC
22
+ from napistu.ingestion.constants import EXCHANGE_COMPARTMENT
23
23
 
24
24
  logger = logging.getLogger(__name__)
25
25
 
26
26
 
27
27
  def add_transportation_reactions(
28
28
  sbml_dfs: sbml_dfs_core.SBML_dfs,
29
- exchange_compartment: str = COMPARTMENTS["CYTOSOL"],
29
+ exchange_compartment: str = EXCHANGE_COMPARTMENT,
30
30
  ) -> sbml_dfs_core.SBML_dfs:
31
31
  """
32
32
  Add transportation reactions to connect all forms of a protein across compartments.
@@ -73,7 +73,7 @@ def add_transportation_reactions(
73
73
  def update_sbml_df_with_exchange(
74
74
  species_needing_transport_rxns: np.ndarray,
75
75
  sbml_dfs: sbml_dfs_core.SBML_dfs,
76
- exchange_compartment: str = COMPARTMENTS["CYTOSOL"],
76
+ exchange_compartment: str = EXCHANGE_COMPARTMENT,
77
77
  ) -> sbml_dfs_core.SBML_dfs:
78
78
  """
79
79
  Add transportation reactions between all locations of a set of molecular species by
napistu/sbml_dfs_core.py CHANGED
@@ -13,6 +13,7 @@ from napistu import identifiers
13
13
  from napistu import sbml_dfs_utils
14
14
  from napistu import source
15
15
  from napistu import utils
16
+ from napistu.ingestion import sbml
16
17
  from napistu.constants import SBML_DFS
17
18
  from napistu.constants import SBML_DFS_SCHEMA
18
19
  from napistu.constants import IDENTIFIERS
@@ -23,9 +24,6 @@ from napistu.constants import BQB_PRIORITIES
23
24
  from napistu.constants import ONTOLOGY_PRIORITIES
24
25
  from napistu.constants import BQB
25
26
  from napistu.constants import BQB_DEFINING_ATTRS
26
- from napistu.constants import COMPARTMENTS
27
- from napistu.constants import COMPARTMENT_ALIASES
28
- from napistu.constants import COMPARTMENTS_GO_TERMS
29
27
  from napistu.constants import MINI_SBO_FROM_NAME
30
28
  from napistu.constants import MINI_SBO_TO_NAME
31
29
  from napistu.constants import ONTOLOGIES
@@ -35,7 +33,9 @@ from napistu.constants import SBO_ROLES_DEFS
35
33
  from napistu.constants import ENTITIES_W_DATA
36
34
  from napistu.constants import ENTITIES_TO_ENTITY_DATA
37
35
  from napistu.constants import CHARACTERISTIC_COMPLEX_ONTOLOGIES
38
- from napistu.ingestion import sbml
36
+ from napistu.ingestion.constants import GENERIC_COMPARTMENT
37
+ from napistu.ingestion.constants import COMPARTMENT_ALIASES
38
+ from napistu.ingestion.constants import COMPARTMENTS_GO_TERMS
39
39
  from fs import open_fs
40
40
 
41
41
  logger = logging.getLogger(__name__)
@@ -145,7 +145,7 @@ class SBML_dfs:
145
145
  if ent in sbml_model:
146
146
  setattr(self, ent, sbml_model[ent])
147
147
  else:
148
- self = sbml.sbml_df_from_sbml(self, sbml_model)
148
+ self = sbml.sbml_dfs_from_sbml(self, sbml_model)
149
149
 
150
150
  for ent in SBML_DFS_SCHEMA.OPTIONAL_ENTITIES:
151
151
  # Initialize optional entities if not set
@@ -1421,8 +1421,8 @@ def filter_to_characteristic_species_ids(
1421
1421
  complexes and non-characteristic annotations such as pubmed references and
1422
1422
  homologues.
1423
1423
 
1424
- Parameters
1425
- ----------
1424
+ Parameters
1425
+ ----------
1426
1426
  species_ids: pd.DataFrame
1427
1427
  A table of identifiers produced by sdbml_dfs.get_identifiers("species")
1428
1428
  max_complex_size: int
@@ -1812,8 +1812,8 @@ def export_sbml_dfs(
1812
1812
  If True then treat genes, transcript, and proteins as separate species. If False
1813
1813
  then treat them interchangeably.
1814
1814
 
1815
- Returns
1816
- -------
1815
+ Returns
1816
+ -------
1817
1817
  None
1818
1818
 
1819
1819
  """
@@ -2257,7 +2257,7 @@ def _sbml_dfs_from_edgelist_check_cspecies_merge(
2257
2257
 
2258
2258
 
2259
2259
  def _stub_compartments(
2260
- stubbed_compartment: str = "CELLULAR_COMPONENT",
2260
+ stubbed_compartment: str = GENERIC_COMPARTMENT,
2261
2261
  ) -> pd.DataFrame:
2262
2262
  """Stub Compartments
2263
2263
 
@@ -2281,7 +2281,6 @@ def _stub_compartments(
2281
2281
  f"{stubbed_compartment} is not defined in constants.COMPARTMENTS_GO_TERMS"
2282
2282
  )
2283
2283
 
2284
- stubbed_compartment_name = COMPARTMENTS[stubbed_compartment]
2285
2284
  stubbed_compartment_id = COMPARTMENTS_GO_TERMS[stubbed_compartment]
2286
2285
 
2287
2286
  formatted_uri = identifiers.format_uri(
@@ -2294,7 +2293,7 @@ def _stub_compartments(
2294
2293
 
2295
2294
  compartments_df = pd.DataFrame(
2296
2295
  {
2297
- SBML_DFS.C_NAME: [stubbed_compartment_name],
2296
+ SBML_DFS.C_NAME: [stubbed_compartment],
2298
2297
  SBML_DFS.C_IDENTIFIERS: [identifiers.Identifiers([formatted_uri])],
2299
2298
  }
2300
2299
  )
@@ -2507,9 +2506,9 @@ def validate_sbml_dfs_table(table_data: pd.DataFrame, table_name: str) -> None:
2507
2506
  table_name : str
2508
2507
  Name of the table in the SBML_dfs schema
2509
2508
 
2510
- Raises
2511
- ------
2512
- ValueError
2509
+ Raises
2510
+ ------
2511
+ ValueError
2513
2512
  If table_name is not in schema or validation fails
2514
2513
  """
2515
2514
  if table_name not in SBML_DFS_SCHEMA.SCHEMA:
@@ -2533,8 +2532,8 @@ def _perform_sbml_dfs_table_validation(
2533
2532
  This function performs the actual validation checks for any table against its schema,
2534
2533
  regardless of whether it's part of an SBML_dfs object or standalone.
2535
2534
 
2536
- Parameters
2537
- ----------
2535
+ Parameters
2536
+ ----------
2538
2537
  table_data : pd.DataFrame
2539
2538
  The table data to validate
2540
2539
  table_schema : dict
@@ -2542,9 +2541,9 @@ def _perform_sbml_dfs_table_validation(
2542
2541
  table_name : str
2543
2542
  Name of the table (for error messages)
2544
2543
 
2545
- Raises
2546
- ------
2547
- ValueError
2544
+ Raises
2545
+ ------
2546
+ ValueError
2548
2547
  If the table does not conform to its schema:
2549
2548
  - Not a DataFrame
2550
2549
  - Wrong index name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: napistu
3
- Version: 0.3.2.dev1
3
+ Version: 0.3.3
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,10 +1,10 @@
1
1
  napistu/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
2
2
  napistu/__main__.py,sha256=PbzIsFAoFHNQuSyi-ql-D7tQLEOuqgmTcgk0PY-OGeU,28636
3
3
  napistu/consensus.py,sha256=UbKKSLP1O46e3Rk8d_aqNlhRHeR3sZRztAgIm7-XK6Y,69960
4
- napistu/constants.py,sha256=Wb1eir8DKSAjukNPknNkKTS4kQSqZjTcTjFaOYNyrC8,15317
4
+ napistu/constants.py,sha256=M-zGc85bo1DDRe7uvyeEMUoD9Qf59Qz53nx4R6PwHvk,12483
5
5
  napistu/identifiers.py,sha256=wsVriQdvPllA5uvh5CiREklA2tYW2MIB14dV7CPaMVU,34003
6
6
  napistu/indices.py,sha256=E_djN1XWc6l1lrFw_QnQXfZTKYTaUv8-jFPP7cHkY5A,9780
7
- napistu/sbml_dfs_core.py,sha256=5t2TYQeuvZeBqR3_eX0oEfAVHyaWSYMLkEO7zmSpo4Y,91779
7
+ napistu/sbml_dfs_core.py,sha256=TUPp2nzaxRWkHKsXrbFzgp0_p5CzEGAmA5cg3dOUm84,91794
8
8
  napistu/sbml_dfs_utils.py,sha256=LJo6WWTrmnE58ZLDuibeeHk88uCdfunWdja7XxdZpps,11525
9
9
  napistu/source.py,sha256=9uUJrkY4jHaKlzz5nNcQQ8wUAep2pfqhlHxHw1hmEkI,13648
10
10
  napistu/utils.py,sha256=TcholWrFbRSu_sn9ODMA8y2YyAhekEKZjwf4S0WQNzI,33241
@@ -17,7 +17,7 @@ napistu/gcs/downloads.py,sha256=SvGv9WYr_Vt3guzyz1QiAuBndeKPTBtWSFLj1-QbLf4,6348
17
17
  napistu/gcs/utils.py,sha256=eLSsvewWJdCguyj2k0ozUGP5BTemaE1PZg41Z3aY5kM,571
18
18
  napistu/ingestion/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
19
19
  napistu/ingestion/bigg.py,sha256=q0HeVSO6pFftbrxxVfFGUtMvCoak9Wi9ngMggRfjFjo,4364
20
- napistu/ingestion/constants.py,sha256=JmIefW8qektzpJr5t0GBtcAq-4bVLougTrOAegm5bl8,5410
20
+ napistu/ingestion/constants.py,sha256=9UP47VImZ11q0kz17N3EJg2155USqLewwNWyKpA-cbA,8089
21
21
  napistu/ingestion/gtex.py,sha256=X0hSC1yrpf4xSJWFhpeNcnHwJzKDII2MvjfUqYA0JN8,3720
22
22
  napistu/ingestion/hpa.py,sha256=R27ExrryKQ4Crxv9ATXmBJCa-yd01TMOrDjkeBhIQac,5054
23
23
  napistu/ingestion/identifiers_etl.py,sha256=6ppDUA6lEZurdmVbiFLOUzphYbr-hndMhtqsQnq_yAc,5009
@@ -25,8 +25,8 @@ napistu/ingestion/napistu_edgelist.py,sha256=eVT9M7gmdBuGHcAYlvkD_zzvTtyzXufKWjw
25
25
  napistu/ingestion/obo.py,sha256=AQkIPWbjA464Lma0tx91JucWkIwLjC7Jgv5VHGRTDkE,9601
26
26
  napistu/ingestion/psi_mi.py,sha256=5eJjm7XWogL9oTyGqR52kntHClLwLsTePKqCvUGyi-w,10111
27
27
  napistu/ingestion/reactome.py,sha256=Hn9X-vDp4o_HK-OtaQvel3vJeZ8_TC1-4N2rruK9Oks,7099
28
- napistu/ingestion/sbml.py,sha256=muLTo-LTeL9lvvdEOjnSg82PQM2jpRExkK0UyF1qea8,20262
29
- napistu/ingestion/string.py,sha256=8igOC3j8cPdG_pMl14Z2OZsbvHUldPTJOJOUD7IJ-Mc,11676
28
+ napistu/ingestion/sbml.py,sha256=N7neMwjTEF7OMhAcNvQJ29V_d3PqMLjLOZqvJTlK9q0,24743
29
+ napistu/ingestion/string.py,sha256=YSWqaKm3I8bOixzvSA8fU4yfR2izddPYs4qJiqwjbxk,11678
30
30
  napistu/ingestion/trrust.py,sha256=ccjZc_eF3PdxxurnukiEo_e0-aKc_3z22NYbaJBtHdY,9774
31
31
  napistu/ingestion/yeast.py,sha256=bwFBNxRq-dLDaddgBL1hpfZj0eQ56nBXyR_9n0NZT9Y,5233
32
32
  napistu/matching/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
@@ -54,7 +54,7 @@ napistu/mcp/utils.py,sha256=WB4c6s8aPZLgi_Wvhhq0DE8Cnz2QGff0V8hrF1feVRg,1296
54
54
  napistu/modify/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
55
55
  napistu/modify/constants.py,sha256=H6K6twzPlxt0yp6QLAxIx0Tp8YzYhtKKXPdmXi5V_QQ,3689
56
56
  napistu/modify/curation.py,sha256=sQeSO53ZLdn14ww2GSKkoP0vJnDpAoSWb-YDjUf5hDQ,21743
57
- napistu/modify/gaps.py,sha256=nhoo30iQai16NzYYfHQ4PE42psWp5hA20Oq7yae1pzw,26743
57
+ napistu/modify/gaps.py,sha256=qprylC2BbSk_vPWayYPVT8lwURXDMOlW5zNLV_wMFZ4,26755
58
58
  napistu/modify/pathwayannot.py,sha256=xuBSMDFWbg_d6-Gzv0Td3Q5nnFTa-Qzic48g1b1AZtQ,48081
59
59
  napistu/modify/uncompartmentalize.py,sha256=U5X4Q7Z-YIkC8_711x3sU21vTVdv9rKfauwz4JNzl6c,9690
60
60
  napistu/network/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
@@ -81,7 +81,7 @@ napistu/rpy2/rids.py,sha256=AfXLTfTdonfspgAHYO0Ph7jSUWv8YuyT8x3fyLfAqc8,3413
81
81
  napistu/scverse/__init__.py,sha256=Lgxr3iMQAkTzXE9BNz93CndNP5djzerLvmHM-D0PU3I,357
82
82
  napistu/scverse/constants.py,sha256=0iAkhyJUIeFGHdLLU3fCaEU1O3Oix4qAsxr3CxGTjVs,653
83
83
  napistu/scverse/loading.py,sha256=jqiE71XB-wdV50GyZrauFNY0Lai4bX9Fm2Gv80VR8t8,27016
84
- napistu-0.3.2.dev1.dist-info/licenses/LICENSE,sha256=kW8wVT__JWoHjl2BbbJDAZInWa9AxzJeR_uv6-i5x1g,1063
84
+ napistu-0.3.3.dist-info/licenses/LICENSE,sha256=kW8wVT__JWoHjl2BbbJDAZInWa9AxzJeR_uv6-i5x1g,1063
85
85
  tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
86
86
  tests/conftest.py,sha256=XVkd0tQywhnf2cgab7fIjBo3NlaTVX3cO8HaRS2jIwM,3190
87
87
  tests/test_consensus.py,sha256=3dJvvPsPG7bHbw_FY4Pm647N_Gt_Ud9157OKYfPCUd4,9502
@@ -115,7 +115,7 @@ tests/test_ontologies_renaming.py,sha256=k7bQzP24zG7W3fpULwk1me2sOWEWlxylr4Mhx1_
115
115
  tests/test_pathwayannot.py,sha256=bceosccNy9tgxQei_7j7ATBSSvBSxOngJvK-mAzR_K0,3312
116
116
  tests/test_rpy2_callr.py,sha256=UVzXMvYN3wcc-ikDIjH2sA4BqkbwiNbMm561BcbnbD4,2936
117
117
  tests/test_rpy2_init.py,sha256=APrNt9GEQV9va3vU5k250TxFplAoWFc-FJRFhM2GcDk,5927
118
- tests/test_sbml.py,sha256=-Lxr_Iu7zl15c98NLG-ty9d1V9lLYHsieKbU_s96F6s,471
118
+ tests/test_sbml.py,sha256=f25zj1NogYrmLluvBDboLameTuCiQ309433Qn3iPvhg,1483
119
119
  tests/test_sbml_dfs_core.py,sha256=z2dYl5-3ZvIsEeK_sHxm8VtWSdL81Eljz_9aeedlM6U,16806
120
120
  tests/test_sbml_dfs_utils.py,sha256=onFWdhrTix30XR1-CMrMXld37BYxEGi6TZrweugLDzI,505
121
121
  tests/test_sbo.py,sha256=x_PENFaXYsrZIzOZu9cj_Wrej7i7SNGxgBYYvcigLs0,308
@@ -126,8 +126,8 @@ tests/test_uncompartmentalize.py,sha256=nAk5kfAVLU9a2VWe2x2HYVcKqj-EnwmwddERIPRa
126
126
  tests/test_utils.py,sha256=JRJFmjDNZpjG59a-73JkTyGqa_a7Z8d0fE2cZt0CRII,22580
127
127
  tests/utils.py,sha256=SoWQ_5roJteFGcMaOeEiQ5ucwq3Z2Fa3AAs9iXHTsJY,749
128
128
  tests/test_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
- napistu-0.3.2.dev1.dist-info/METADATA,sha256=go09DE0iiD9UQmhyGSTdq2iGLGgODt84uZ9vKbridIg,3418
130
- napistu-0.3.2.dev1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
131
- napistu-0.3.2.dev1.dist-info/entry_points.txt,sha256=_QnaPOvJNA3IltxmZgWIiBoen-L1bPYX18YQfC7oJgQ,41
132
- napistu-0.3.2.dev1.dist-info/top_level.txt,sha256=Gpvk0a_PjrtqhYcQ9IDr3zR5LqpZ-uIHidQMIpjlvhY,14
133
- napistu-0.3.2.dev1.dist-info/RECORD,,
129
+ napistu-0.3.3.dist-info/METADATA,sha256=Y5HCnBOuVO0Rvc1S-P3llVgWJSeBR1hes6UTt0cyhB4,3413
130
+ napistu-0.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
131
+ napistu-0.3.3.dist-info/entry_points.txt,sha256=_QnaPOvJNA3IltxmZgWIiBoen-L1bPYX18YQfC7oJgQ,41
132
+ napistu-0.3.3.dist-info/top_level.txt,sha256=Gpvk0a_PjrtqhYcQ9IDr3zR5LqpZ-uIHidQMIpjlvhY,14
133
+ napistu-0.3.3.dist-info/RECORD,,
tests/test_sbml.py CHANGED
@@ -1,17 +1,48 @@
1
1
  from __future__ import annotations
2
2
 
3
- import pandas as pd
4
3
  from napistu import sbml_dfs_core
5
4
  from napistu.ingestion import sbml
5
+ import pytest
6
+ from pydantic import ValidationError
6
7
 
7
8
 
8
9
  def test_sbml_dfs(sbml_path):
9
10
  sbml_model = sbml.SBML(sbml_path)
10
- _ = sbml_model.model
11
+ _ = sbml_dfs_core.SBML_dfs(sbml_model)
11
12
 
12
- dfs = sbml_dfs_core.SBML_dfs(sbml_model)
13
- dfs.validate()
14
13
 
15
- assert type(dfs.get_cspecies_features()) is pd.DataFrame
16
- assert type(dfs.get_species_features()) is pd.DataFrame
17
- assert type(dfs.get_identifiers("species")) is pd.DataFrame
14
+ def test_compartment_aliases_validation_positive():
15
+ """
16
+ Tests that a valid compartment aliases dictionary passes validation.
17
+ """
18
+ valid_aliases = {
19
+ "extracellular": ["ECM", "extracellular space"],
20
+ "cytosol": ["cytoplasm"],
21
+ }
22
+ # This should not raise an exception
23
+ sbml.CompartmentAliasesValidator.model_validate(valid_aliases)
24
+
25
+
26
+ def test_compartment_aliases_validation_negative():
27
+ """
28
+ Tests that an invalid compartment aliases dictionary raises a ValidationError.
29
+ """
30
+ invalid_aliases = {
31
+ "extracellular": ["ECM"],
32
+ "not_a_real_compartment": ["fake"],
33
+ }
34
+ with pytest.raises(ValidationError):
35
+ sbml.CompartmentAliasesValidator.model_validate(invalid_aliases)
36
+
37
+
38
+ def test_compartment_aliases_validation_bad_type():
39
+ """
40
+ Tests that a validation error is raised for incorrect data types.
41
+ """
42
+ # Test with a non-dict input
43
+ with pytest.raises(ValidationError):
44
+ sbml.CompartmentAliasesValidator.model_validate(["extracellular"])
45
+
46
+ # Test with incorrect value types in the dictionary
47
+ with pytest.raises(ValidationError):
48
+ sbml.CompartmentAliasesValidator.model_validate({"extracellular": "ECM"})