Skip to content

Commit 06fee32

Browse files
committed
Merge branch 'develop' into remove-hardcoded-paths/rnaseq-gen
# Conflicts: # main/como/rnaseq_gen.py
2 parents 495694f + d416dc9 commit 06fee32

5 files changed

Lines changed: 38 additions & 34 deletions

File tree

main/como/__init__.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 31 additions & 22 deletions
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]
@@ -550,6 +564,7 @@ def _collect_boundary_reactions(path: Path) -> _BoundaryReactions:
550564
df = _create_df(path)
551565
for column in df.columns:
552566
if column not in [
567+
"boundary",
553568
"reaction",
554569
"abbreviation",
555570
"compartment",
@@ -561,31 +576,25 @@ def _collect_boundary_reactions(path: Path) -> _BoundaryReactions:
561576
f"'Minimum Reaction Rate', and 'Maximum Reaction Rate'. Found: {column}"
562577
)
563578

564-
reactions: list[str] = []
579+
reactions: list[str] = [""] * len(df)
565580
boundary_type: list[str] = df["reaction"].tolist()
566581
reaction_abbreviation: list[str] = df["abbreviation"].tolist()
567582
reaction_compartment: list[str] = df["compartment"].tolist()
568-
lower_bounds = df["minimum reaction rate"].tolist()
569-
upper_bounds = df["maximum reaction rate"].tolist()
583+
lower_bound = df["minimum reaction rate"].tolist()
584+
upper_bound = df["maximum reaction rate"].tolist()
585+
boundary_map = {"exchange": "EX", "demand": "DM", "sink": "SK"}
570586
for i in range(len(boundary_type)):
571-
current_type: str = boundary_type[i]
572-
temp_reaction: str = ""
573-
574-
match current_type.lower():
575-
case "exchange":
576-
temp_reaction += "EX_"
577-
case "demand":
578-
temp_reaction += "DM_"
579-
case "sink":
580-
temp_reaction += "SK_"
587+
boundary: str = boundary_type[i].lower()
588+
if boundary not in boundary_map:
589+
raise ValueError(f"Boundary reaction type must be 'Exchange', 'Demand', or 'Sink'. Found: {boundary[i]}")
581590

582591
shorthand_compartment = Compartments.get(reaction_compartment[i])
583-
temp_reaction += f"{reaction_abbreviation[i]}[{shorthand_compartment}]"
584-
reactions.append(temp_reaction)
592+
reactions[i] = f"{boundary_map.get(boundary)}_{reaction_abbreviation[i]}[{shorthand_compartment}]"
593+
585594
return _BoundaryReactions(
586595
reactions=reactions,
587-
lower_bounds=lower_bounds,
588-
upper_bounds=upper_bounds,
596+
lower_bounds=lower_bound,
597+
upper_bounds=upper_bound,
589598
)
590599

591600

@@ -631,10 +640,10 @@ def create_context_specific_model( # noqa: C901
631640
raise ValueError(f"Output file type {output_type} not recognized. Must be one of: 'xml', 'mat', 'json'")
632641

633642
if algorithm not in Algorithm:
634-
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)}")
635644

636645
if solver not in Solver:
637-
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)}")
638647

639648
if boundary_rxns_filepath:
640649
boundary_reactions = _collect_boundary_reactions(boundary_rxns_filepath)
@@ -667,7 +676,7 @@ def create_context_specific_model( # noqa: C901
667676
bound_ub=boundary_reactions.upper_bounds,
668677
exclude_rxns=exclude_rxns,
669678
force_rxns=force_rxns,
670-
solver=solver.value,
679+
solver=solver.value.lower(),
671680
low_thresh=low_threshold,
672681
high_thresh=high_threshold,
673682
)

main/data/boundary_rxns/naiveB_boundary_rxns.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Reaction,Abbreviation,Compartment,Minimum Reaction Rate,Maximum Reaction Rate
1+
Boundary,Abbreviation,Compartment,Minimum Reaction Rate,Maximum Reaction Rate
22
Exchange,glc_D,Extracellular,-100,1000
33
Exchange,fe2,Extracellular,-1000,1000
44
Exchange,gal,Extracellular,0,1000

main/data/boundary_rxns/smB_boundary_rxns.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Reaction,Abbreviation,Compartment,Minimum Reaction Rate,Maximum Reaction Rate
1+
Boundary,Abbreviation,Compartment,Minimum Reaction Rate,Maximum Reaction Rate
22
Exchange,glc_D,Extracellular,-100,1000
33
Exchange,fe2,Extracellular,-1000,1000
44
Exchange,gal,Extracellular,0,1000
@@ -67,4 +67,4 @@ Exchange,orn,Extracellular,-1,1000
6767
Exchange,orn_D,Extracellular,-1,1000
6868
Exchange,so4,Extracellular,-1000,1000
6969
Exchange,ribflv,Extracellular,-1,1000
70-
Exchange,Lcystin,Extracellular,-1,1000
70+
Exchange,Lcystin,Extracellular,-1,1000

pyproject.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ requires-python = ">=3.10,<3.13"
55
dependencies = [
66
"aiofiles>=24.1.0",
77
"aioftp>=0.23.1",
8-
"cobamp",
8+
"cobamp@git+https://github.com/JoshLoecker/cobamp@master",
99
"cobra>=0.28.0",
1010
"fast-bioservices>=0.3.9",
1111
"gurobipy>=11.0",
@@ -20,7 +20,7 @@ dependencies = [
2020
"scikit-learn>=1.5.2",
2121
"scipy>=1.7.3",
2222
"setuptools<60.0",
23-
"troppo",
23+
"troppo@git+https://github.com/JoshLoecker/troppo@master",
2424
]
2525

2626
[project.optional-dependencies]
@@ -57,14 +57,9 @@ dev-dependencies = [
5757
"cz-conventional-gitmoji>=0.6.1",
5858
]
5959

60-
[tool.uv.sources]
61-
troppo = { git = "https://github.com/JoshLoecker/troppo", rev = "update_dependencies" }
62-
cobamp = { git = "https://github.com/JoshLoecker/cobamp", rev = "update_packages" }
63-
pydantic-settings = { git = "https://github.com/pydantic/pydantic-settings" }
64-
6560
[tool.commitizen]
6661
name = "cz_conventional_commits"
6762
tag_format = "$version"
6863
version_scheme = "semver2"
6964
version_provider = "pep621"
70-
update_changelog_on_bump = true
65+
update_changelog_on_bump = true

0 commit comments

Comments
 (0)