Skip to content

Commit 7e018a5

Browse files
authored
Merge pull request #203 from HelikarLab/hotfix
hotfix: allow setting solvers through troppo; update actions
2 parents d5bc837 + 6c08b7b commit 7e018a5

File tree

4 files changed

+27
-17
lines changed

4 files changed

+27
-17
lines changed

.github/workflows/continuous_integration.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
uses: actions/checkout@v4
1515

1616
- name: Install uv
17-
uses: astral-sh/setup-uv@v3
17+
uses: astral-sh/setup-uv@v4
1818

1919
- name: Create Virtual Environment
2020
run: uv venv
@@ -26,17 +26,17 @@ jobs:
2626
run: uv run jupyter nbconvert --clear-output --inplace "main/COMO.ipynb"
2727

2828
- name: Format Python Imports
29-
uses: astral-sh/ruff-action@v1
29+
uses: astral-sh/ruff-action@v2
3030
with:
3131
args: "check --fix --select I"
3232

3333
- name: Format code
34-
uses: astral-sh/ruff-action@v1
34+
uses: astral-sh/ruff-action@v2
3535
with:
3636
args: "format"
3737

3838
- name: Format Notebook
39-
uses: astral-sh/ruff-action@v1
39+
uses: astral-sh/ruff-action@v2
4040
with:
4141
args: "format main/COMO.ipynb"
4242

@@ -54,7 +54,7 @@ jobs:
5454
uses: actions/checkout@v4
5555

5656
- name: Check Lint
57-
uses: astral-sh/ruff-action@v1
57+
uses: astral-sh/ruff-action@v2
5858
with:
5959
args: "check --no-fix --verbose"
6060

main/como/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from como.utils import stringlist_to_list
55

66
__all__ = ["stringlist_to_list", "Config"]
7-
__version__ = "1.10.0"
7+
__version__ = "1.11.1"
88

99

1010
def return_placeholder_data() -> pd.DataFrame:

main/como/create_context_specific_model.py

+19-5
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,16 @@ def _build_with_imat(
308308
expr_vector: npt.NDArray,
309309
expr_thesh: tuple[float, float],
310310
force_gene_ids: Sequence[int],
311+
solver: str,
311312
) -> (cobra.Model, pd.DataFrame):
312313
expr_vector = np.array(expr_vector)
313-
properties = IMATProperties(exp_vector=expr_vector, exp_thresholds=expr_thesh, core=force_gene_ids, epsilon=0.01)
314+
properties = IMATProperties(
315+
exp_vector=expr_vector,
316+
exp_thresholds=expr_thesh,
317+
core=force_gene_ids,
318+
epsilon=0.01,
319+
solver=solver.upper(),
320+
)
314321
algorithm = IMAT(s_matrix, np.array(lb), np.array(ub), properties)
315322
context_rxns: npt.NDArray = algorithm.run()
316323
fluxes: pd.Series = algorithm.sol.to_series()
@@ -507,7 +514,14 @@ def _build_model( # noqa: C901
507514
elif recon_algorithm == Algorithm.IMAT:
508515
context_model_cobra: cobra.Model
509516
context_model_cobra, flux_df = _build_with_imat(
510-
reference_model, s_matrix, lb, ub, expr_vector, exp_thresh, idx_force
517+
reference_model,
518+
s_matrix,
519+
lb,
520+
ub,
521+
expr_vector,
522+
exp_thresh,
523+
idx_force,
524+
solver=solver,
511525
)
512526
imat_reactions = flux_df.rxn
513527
model_reactions = [reaction.id for reaction in context_model_cobra.reactions]
@@ -626,10 +640,10 @@ def create_context_specific_model( # noqa: C901
626640
raise ValueError(f"Output file type {output_type} not recognized. Must be one of: 'xml', 'mat', 'json'")
627641

628642
if algorithm not in Algorithm:
629-
raise ValueError(f"Algorithm {algorithm} not supported. Please use one of: GIMME, FASTCORE, or IMAT")
643+
raise ValueError(f"Algorithm {algorithm} not supported. Use one of {', '.join(a.value for a in Algorithm)}")
630644

631645
if solver not in Solver:
632-
raise ValueError(f"Solver '{solver}' not supported. Use 'GLPK' or 'GUROBI'")
646+
raise ValueError(f"Solver '{solver}' not supported. Use one of {', '.join(s.value for s in Solver)}")
633647

634648
if boundary_rxns_filepath:
635649
boundary_reactions = _collect_boundary_reactions(boundary_rxns_filepath)
@@ -662,7 +676,7 @@ def create_context_specific_model( # noqa: C901
662676
bound_ub=boundary_reactions.upper_bounds,
663677
exclude_rxns=exclude_rxns,
664678
force_rxns=force_rxns,
665-
solver=solver.value,
679+
solver=solver.value.lower(),
666680
low_thresh=low_threshold,
667681
high_thresh=high_threshold,
668682
)

pyproject.toml

+2-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ dependencies = [
1717
"openpyxl>=3.1.5",
1818
"aiofiles>=24.1.0",
1919
"aioftp>=0.23.1",
20-
"troppo",
21-
"cobamp",
20+
"troppo@git+https://github.com/JoshLoecker/troppo@master",
21+
"cobamp@git+https://github.com/JoshLoecker/cobamp@master",
2222
]
2323

2424
[build-system]
@@ -46,7 +46,3 @@ dev-dependencies = [
4646
"hypothesis>=6.122.1",
4747
"pytest-cov>=6.0.0",
4848
]
49-
50-
[tool.uv.sources]
51-
troppo = { git = "https://github.com/JoshLoecker/troppo", rev = "update_dependencies" }
52-
cobamp = { git = "https://github.com/JoshLoecker/cobamp", rev = "update_packages" }

0 commit comments

Comments
 (0)