Repository navigation
Expand file tree
/
Copy pathcuration.py
More file actions
79 lines (69 loc) · 2.4 KB
/
Copy pathcuration.py
File metadata and controls
79 lines (69 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
"""Yeast-GEM batch curation entry point.
Thin wrapper over :func:`raven_toolbox.curation.batch_curate` (and its
``from_tsv`` companion) that pins the yeast-GEM id prefixes
(``'s_'`` for new metabolites, ``'r_'`` for new reactions). All
schema details (column names, MIRIAM-auto-detection, match keys) live
upstream — see ``raven_toolbox.curation`` for the full reference.
The MATLAB counterpart is ``code/modelCuration/curateMetsRxnsGenes.m``
(also a shim over RAVEN's ``curateModelFromTables``).
"""
from __future__ import annotations
from pathlib import Path
import cobra
import pandas as pd
from raven_toolbox.curation import (
CurationResult,
)
from raven_toolbox.curation import (
batch_curate as _ra_batch_curate,
)
from raven_toolbox.curation import (
batch_curate_from_tsv as _ra_batch_curate_from_tsv,
)
# Yeast-GEM id prefixes — frozen for both Python and MATLAB callers.
_MET_ID_PREFIX = "s_"
_RXN_ID_PREFIX = "r_"
def curate_mets_rxns_genes(
model: cobra.Model,
*,
mets_df: pd.DataFrame | None = None,
genes_df: pd.DataFrame | None = None,
rxns_df: pd.DataFrame | None = None,
rxns_coeffs_df: pd.DataFrame | None = None,
) -> CurationResult:
"""Add or update metabolites / reactions / genes from DataFrames.
Yeast-GEM-specific id prefixes are applied automatically (``s_`` /
``r_``); everything else is delegated to
:func:`raven_toolbox.curation.batch_curate`. See its docstring for
the schema, match-key rules and the MIRIAM-auto-detection
convention.
"""
return _ra_batch_curate(
model,
mets_df=mets_df,
genes_df=genes_df,
rxns_df=rxns_df,
rxns_coeffs_df=rxns_coeffs_df,
met_id_prefix=_MET_ID_PREFIX,
rxn_id_prefix=_RXN_ID_PREFIX,
)
def curate_mets_rxns_genes_from_tsv(
model: cobra.Model,
*,
mets_tsv: str | Path | None = None,
genes_tsv: str | Path | None = None,
rxns_tsv: str | Path | None = None,
rxns_coeffs_tsv: str | Path | None = None,
) -> CurationResult:
"""File-path convenience wrapper — same shape as the MATLAB
``curateMetsRxnsGenes(model, metsInfo, genesInfo, rxnsCoeffs,
rxnsInfo)``."""
return _ra_batch_curate_from_tsv(
model,
mets_tsv=mets_tsv,
genes_tsv=genes_tsv,
rxns_tsv=rxns_tsv,
rxns_coeffs_tsv=rxns_coeffs_tsv,
met_id_prefix=_MET_ID_PREFIX,
rxn_id_prefix=_RXN_ID_PREFIX,
)