napistu 0.3.1.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.
- napistu/__main__.py +1 -1
- napistu/constants.py +0 -80
- napistu/ingestion/constants.py +106 -37
- napistu/ingestion/sbml.py +392 -221
- napistu/ingestion/string.py +2 -2
- napistu/modify/gaps.py +3 -3
- napistu/network/precompute.py +64 -16
- napistu/sbml_dfs_core.py +19 -20
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/METADATA +1 -1
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/RECORD +17 -17
- tests/test_network_precompute.py +58 -8
- tests/test_sbml.py +38 -7
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/WHEEL +0 -0
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/entry_points.txt +0 -0
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/licenses/LICENSE +0 -0
- {napistu-0.3.1.dev1.dist-info → napistu-0.3.3.dist-info}/top_level.txt +0 -0
- /tests/{test_net_propagation.py → test_network_net_propagation.py} +0 -0
napistu/ingestion/string.py
CHANGED
@@ -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 =
|
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 =
|
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 =
|
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/network/precompute.py
CHANGED
@@ -2,12 +2,16 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import logging
|
4
4
|
import math
|
5
|
+
from pathlib import Path
|
6
|
+
from typing import Union
|
5
7
|
|
6
8
|
import numpy as np
|
7
9
|
import pandas as pd
|
10
|
+
from fs.errors import ResourceNotFound
|
8
11
|
|
9
12
|
from napistu.network.napistu_graph_core import NapistuGraph
|
10
13
|
from napistu.network.ig_utils import validate_edge_attributes
|
14
|
+
from napistu.utils import load_json, save_json
|
11
15
|
|
12
16
|
logger = logging.getLogger(__name__)
|
13
17
|
|
@@ -75,21 +79,17 @@ def precompute_distances(
|
|
75
79
|
# interate through all partitions of "from" nodes and find their shortest and lowest weighted paths
|
76
80
|
unique_partitions = vs_to_partition.index.unique().tolist()
|
77
81
|
|
78
|
-
precomputed_distances = (
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
)
|
90
|
-
.reset_index(drop=True)
|
91
|
-
.query("sc_id_origin != sc_id_dest")
|
92
|
-
)
|
82
|
+
precomputed_distances = pd.concat(
|
83
|
+
[
|
84
|
+
_calculate_distances_subset(
|
85
|
+
napistu_graph,
|
86
|
+
vs_to_partition,
|
87
|
+
vs_to_partition.loc[uq_part],
|
88
|
+
weights_vars=weights_vars,
|
89
|
+
)
|
90
|
+
for uq_part in unique_partitions
|
91
|
+
]
|
92
|
+
).query("sc_id_origin != sc_id_dest")
|
93
93
|
|
94
94
|
# filter by path length and/or weight
|
95
95
|
filtered_precomputed_distances = _filter_precomputed_distances(
|
@@ -97,11 +97,59 @@ def precompute_distances(
|
|
97
97
|
max_steps=max_steps,
|
98
98
|
max_score_q=max_score_q,
|
99
99
|
path_weights_vars=["path_" + w for w in weights_vars],
|
100
|
-
)
|
100
|
+
).reset_index(drop=True)
|
101
101
|
|
102
102
|
return filtered_precomputed_distances
|
103
103
|
|
104
104
|
|
105
|
+
def save_precomputed_distances(
|
106
|
+
precomputed_distances: pd.DataFrame, uri: Union[str, Path]
|
107
|
+
) -> None:
|
108
|
+
"""
|
109
|
+
Save a precomputed distances DataFrame to a JSON file.
|
110
|
+
|
111
|
+
Parameters
|
112
|
+
----------
|
113
|
+
precomputed_distances : pd.DataFrame
|
114
|
+
The precomputed distances DataFrame to save
|
115
|
+
uri : Union[str, Path]
|
116
|
+
Path where to save the JSON file. Can be a local path or a GCS URI.
|
117
|
+
|
118
|
+
Raises
|
119
|
+
------
|
120
|
+
OSError
|
121
|
+
If the file cannot be written to (permission issues, etc.)
|
122
|
+
"""
|
123
|
+
save_json(str(uri), precomputed_distances.to_dict(orient="index"))
|
124
|
+
|
125
|
+
|
126
|
+
def load_precomputed_distances(uri: Union[str, Path]) -> pd.DataFrame:
|
127
|
+
"""
|
128
|
+
Load a precomputed distances DataFrame from a JSON file.
|
129
|
+
|
130
|
+
Parameters
|
131
|
+
----------
|
132
|
+
uri : Union[str, Path]
|
133
|
+
Path to the JSON file to load
|
134
|
+
|
135
|
+
Returns
|
136
|
+
-------
|
137
|
+
pd.DataFrame
|
138
|
+
The reconstructed precomputed distances DataFrame
|
139
|
+
|
140
|
+
Raises
|
141
|
+
------
|
142
|
+
FileNotFoundError
|
143
|
+
If the specified file does not exist
|
144
|
+
"""
|
145
|
+
try:
|
146
|
+
data_dict = load_json(str(uri))
|
147
|
+
except ResourceNotFound as e:
|
148
|
+
raise FileNotFoundError(f"File not found: {uri}") from e
|
149
|
+
|
150
|
+
return pd.DataFrame.from_dict(data_dict, orient="index").rename(index=int)
|
151
|
+
|
152
|
+
|
105
153
|
def _calculate_distances_subset(
|
106
154
|
napistu_graph: NapistuGraph,
|
107
155
|
vs_to_partition: pd.DataFrame,
|
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
|
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.
|
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
|
-
|
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
|
-
|
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 =
|
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: [
|
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
|
-
|
2511
|
-
|
2512
|
-
|
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
|
-
|
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
|
-
|
2546
|
-
|
2547
|
-
|
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,10 +1,10 @@
|
|
1
1
|
napistu/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
|
2
|
-
napistu/__main__.py,sha256=
|
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=
|
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=
|
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=
|
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=
|
29
|
-
napistu/ingestion/string.py,sha256=
|
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=
|
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
|
@@ -67,7 +67,7 @@ napistu/network/net_create.py,sha256=2N5ocGmibdBxIUVtv3H36iFWwkbys9ECCERFRlByhLc
|
|
67
67
|
napistu/network/net_propagation.py,sha256=89ZR4p2mGpkCCIemofZ53XbUjQsuNABxIc6UmF8A5n8,4935
|
68
68
|
napistu/network/ng_utils.py,sha256=ijWDa5MTuULJpdV6dcVFGmLmtB_xy87jaUG7F5nvC_k,15240
|
69
69
|
napistu/network/paths.py,sha256=S4ZaV0yVmI-o8sXfom5eXA3yy2IEbleYUyXEvnmVw98,17468
|
70
|
-
napistu/network/precompute.py,sha256=
|
70
|
+
napistu/network/precompute.py,sha256=xDIHWxGWwDyEw1sF1bQKHVbunI8qmeJvo3Iv7wADUys,8960
|
71
71
|
napistu/ontologies/__init__.py,sha256=dFXAhIqlTLJMwowS4BUDT08-Vy3Q0u1L0CMCErSZT1Y,239
|
72
72
|
napistu/ontologies/constants.py,sha256=GyOFvezSxDK1VigATcruTKtNhjcYaid1ggulEf_HEtQ,4345
|
73
73
|
napistu/ontologies/dogma.py,sha256=jGZS-J3d29AoUOow-HVjfVZQJ87lnqO5L1aozieN1ec,8825
|
@@ -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.
|
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
|
@@ -101,21 +101,21 @@ tests/test_matching_species.py,sha256=OuUWp0-X3WYXkc-g51XyOqhp4MgO8cJvUSqt8ZvqRa
|
|
101
101
|
tests/test_mcp_config.py,sha256=GTu9vywqAHTYkolywdYS_BEIW3gBzs4A4qcneMSPpRk,7007
|
102
102
|
tests/test_mcp_documentation_utils.py,sha256=OW0N2N_2IOktbYTcCWhhWz4bANi8IB60l1q3DJi8Ra4,810
|
103
103
|
tests/test_mcp_server.py,sha256=bP3PWVQsEfX6-lAgXKP32njdg__o65n2WuLvkxTTHkQ,11215
|
104
|
-
tests/test_net_propagation.py,sha256=9pKkUdduWejH4iKNCJXKFzAkdNpCfrMbiUWySgI_LH4,3244
|
105
104
|
tests/test_network_data_handling.py,sha256=oBSZuB3IRG9bwmD6n8FY-UZLe2UqGzXpNSxVtkHRSvE,12605
|
106
105
|
tests/test_network_ig_utils.py,sha256=uojDLtL7oT9S9NJrXL8kBEHHFq5DB1GnJQT0v-gHEBE,632
|
107
106
|
tests/test_network_neighborhoods.py,sha256=8BV17m5X1OUd5FwasTTYUOkNYUHDPUkxOKH_VZCsyBE,631
|
108
107
|
tests/test_network_net_create.py,sha256=VNFZTwQawAZQPDnVk_qFevgZErx5KyQZ24bMoZF4T4w,16462
|
108
|
+
tests/test_network_net_propagation.py,sha256=9pKkUdduWejH4iKNCJXKFzAkdNpCfrMbiUWySgI_LH4,3244
|
109
109
|
tests/test_network_ng_utils.py,sha256=CwDw4MKTPhVZXz2HA2XU2QjjBv8CXc1_yQ0drvkBkFw,724
|
110
110
|
tests/test_network_paths.py,sha256=TWZnxY5bF3m6gahcxcYJGrBIawh2-_vUcec1LyPmXV8,1686
|
111
|
-
tests/test_network_precompute.py,sha256=
|
111
|
+
tests/test_network_precompute.py,sha256=W1tuHM-dd90nk0vUUNP_xZ7EhCKSjigI5ndm8oq8l0c,8869
|
112
112
|
tests/test_ontologies_genodexito.py,sha256=hBlunyEPiKskqagjWKW5Z6DJwKvpueYHJLwbfyeeAdo,2256
|
113
113
|
tests/test_ontologies_mygene.py,sha256=BuBLm8VatzpK39-Ew_fFTK9ueLE4eqmKIDS5UKE59n8,1541
|
114
114
|
tests/test_ontologies_renaming.py,sha256=k7bQzP24zG7W3fpULwk1me2sOWEWlxylr4Mhx1_gJJY,3740
|
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
|
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.
|
130
|
-
napistu-0.3.
|
131
|
-
napistu-0.3.
|
132
|
-
napistu-0.3.
|
133
|
-
napistu-0.3.
|
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_network_precompute.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import pytest
|
3
4
|
import os
|
5
|
+
import tempfile
|
4
6
|
|
5
7
|
import numpy as np
|
6
8
|
import pandas as pd
|
@@ -214,11 +216,59 @@ def test_precomputed_distances_neighborhoods():
|
|
214
216
|
assert upstream_disagreement_w_precompute.shape[0] == 0
|
215
217
|
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
219
|
+
@pytest.mark.skip_on_windows
|
220
|
+
def test_precomputed_distances_serialization():
|
221
|
+
"""
|
222
|
+
Test that validates the serialization -> deserialization approach works correctly.
|
223
|
+
|
224
|
+
Notes
|
225
|
+
-----
|
226
|
+
This function creates a sample DataFrame with the structure of precomputed
|
227
|
+
distances data, saves it to a temporary JSON file, loads it back, and
|
228
|
+
validates that all data is preserved correctly through the serialization
|
229
|
+
round-trip.
|
230
|
+
"""
|
231
|
+
# Create a sample DataFrame that mimics the precomputed distances structure
|
232
|
+
sample_data = {
|
233
|
+
"sc_id_origin": {
|
234
|
+
1: "SC00000000",
|
235
|
+
3: "SC00000003",
|
236
|
+
4: "SC00000004",
|
237
|
+
5: "SC00000005",
|
238
|
+
6: "SC00000011",
|
239
|
+
},
|
240
|
+
"sc_id_dest": {
|
241
|
+
1: "SC00000001",
|
242
|
+
3: "SC00000001",
|
243
|
+
4: "SC00000001",
|
244
|
+
5: "SC00000001",
|
245
|
+
6: "SC00000001",
|
246
|
+
},
|
247
|
+
"path_length": {1: 1.0, 3: 4.0, 4: 6.0, 5: 6.0, 6: 1.0},
|
248
|
+
"path_upstream_weights": {1: 1.0, 3: 4.0, 4: 6.0, 5: 6.0, 6: 1.0},
|
249
|
+
"path_weights": {1: 1.0, 3: 4.0, 4: 6.0, 5: 6.0, 6: 1.0},
|
250
|
+
}
|
251
|
+
|
252
|
+
# Create original DataFrame
|
253
|
+
original_df = pd.DataFrame(sample_data)
|
254
|
+
|
255
|
+
# Create a temporary file path
|
256
|
+
with tempfile.NamedTemporaryFile(
|
257
|
+
mode="w", suffix=".json", delete=False
|
258
|
+
) as tmp_file:
|
259
|
+
temp_path = tmp_file.name
|
260
|
+
|
261
|
+
try:
|
262
|
+
# Test serialization
|
263
|
+
precompute.save_precomputed_distances(original_df, temp_path)
|
264
|
+
|
265
|
+
# Test deserialization
|
266
|
+
loaded_df = precompute.load_precomputed_distances(temp_path)
|
267
|
+
|
268
|
+
# Validate that the loaded DataFrame is identical to the original
|
269
|
+
pd.testing.assert_frame_equal(original_df, loaded_df, check_like=True)
|
270
|
+
|
271
|
+
finally:
|
272
|
+
# Clean up the temporary file
|
273
|
+
if os.path.exists(temp_path):
|
274
|
+
os.remove(temp_path)
|
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
|
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
|
-
|
16
|
-
|
17
|
-
|
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"})
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|