Skip to content

Commit 7fc7109

Browse files
committed
Merge branch 'main' into develop
# Conflicts: # main/como/rnaseq.py
2 parents d1882b6 + 02d5213 commit 7fc7109

4 files changed

Lines changed: 28 additions & 20 deletions

File tree

main/como/create_context_specific_model.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ def _collect_boundary_reactions(path: Path) -> _BoundaryReactions:
550550
df = _create_df(path)
551551
for column in df.columns:
552552
if column not in [
553+
"boundary",
553554
"reaction",
554555
"abbreviation",
555556
"compartment",
@@ -561,31 +562,25 @@ def _collect_boundary_reactions(path: Path) -> _BoundaryReactions:
561562
f"'Minimum Reaction Rate', and 'Maximum Reaction Rate'. Found: {column}"
562563
)
563564

564-
reactions: list[str] = []
565+
reactions: list[str] = [""] * len(df)
565566
boundary_type: list[str] = df["reaction"].tolist()
566567
reaction_abbreviation: list[str] = df["abbreviation"].tolist()
567568
reaction_compartment: list[str] = df["compartment"].tolist()
568-
lower_bounds = df["minimum reaction rate"].tolist()
569-
upper_bounds = df["maximum reaction rate"].tolist()
569+
lower_bound = df["minimum reaction rate"].tolist()
570+
upper_bound = df["maximum reaction rate"].tolist()
571+
boundary_map = {"exchange": "EX", "demand": "DM", "sink": "SK"}
570572
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_"
573+
boundary: str = boundary_type[i].lower()
574+
if boundary not in boundary_map:
575+
raise ValueError(f"Boundary reaction type must be 'Exchange', 'Demand', or 'Sink'. Found: {boundary[i]}")
581576

582577
shorthand_compartment = Compartments.get(reaction_compartment[i])
583-
temp_reaction += f"{reaction_abbreviation[i]}[{shorthand_compartment}]"
584-
reactions.append(temp_reaction)
578+
reactions[i] = f"{boundary_map.get(boundary)}_{reaction_abbreviation[i]}[{shorthand_compartment}]"
579+
585580
return _BoundaryReactions(
586581
reactions=reactions,
587-
lower_bounds=lower_bounds,
588-
upper_bounds=upper_bounds,
582+
lower_bounds=lower_bound,
583+
upper_bounds=upper_bound,
589584
)
590585

591586

main/como/rnaseq_gen.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import asyncio
55
from dataclasses import dataclass
6+
from pathlib import Path
67

78
import pandas as pd
89
from fast_bioservices import Taxon
@@ -24,6 +25,7 @@ class _Arguments:
2425
minimum_cutoff: int | str
2526
library_prep: RNAPrepMethod
2627
taxon: Taxon
28+
write_zfpkm_png_filepath: Path
2729

2830
def __post_init__(self):
2931
self.library_prep = RNAPrepMethod.from_string(str(self.library_prep))
@@ -48,6 +50,7 @@ async def _handle_context_batch(
4850
cut_off: int | float | str,
4951
prep: RNAPrepMethod,
5052
taxon: Taxon,
53+
write_zfpkm_png_filepath: Path,
5154
) -> None:
5255
"""Iterate through each context type and create rnaseq expression file.
5356
@@ -110,6 +113,7 @@ async def _handle_context_batch(
110113
technique=technique,
111114
cut_off=cut_off,
112115
taxon_id=taxon,
116+
write_zfpkm_png_filepath=write_zfpkm_png_filepath,
113117
)
114118
logger.success(f"Results saved at '{rnaseq_output_filepath}'")
115119

@@ -119,6 +123,7 @@ async def rnaseq_gen(
119123
config_filename: str,
120124
prep: RNAPrepMethod,
121125
taxon_id: int | str | Taxon,
126+
write_zfpkm_png_filepath: Path,
122127
replicate_ratio: float = 0.5,
123128
high_replicate_ratio: float = 1.0,
124129
batch_ratio: float = 0.5,
@@ -180,6 +185,7 @@ async def rnaseq_gen(
180185
cut_off=cut_off,
181186
prep=prep,
182187
taxon=taxon_id,
188+
write_zfpkm_png_filepath=write_zfpkm_png_filepath,
183189
)
184190

185191

@@ -287,6 +293,12 @@ def _parse_args() -> _Arguments:
287293
"Will separate samples into groups to only compare similarly prepared libraries. "
288294
"For example, mRNA, total-rna, scRNA, etc",
289295
)
296+
parser.add_argument(
297+
"--write-zfpkm-png-filepath",
298+
required=False,
299+
type=Path,
300+
help="If using zFPKM, the location to write graphs",
301+
)
290302
args = parser.parse_args()
291303
args.filtering_technique = args.filtering_technique.lower()
292304
args.taxon = Taxon.from_int(int(args.taxon)) if str(args.taxon).isdigit() else Taxon.from_string(str(args.taxon)) # type: ignore
@@ -306,5 +318,6 @@ def _parse_args() -> _Arguments:
306318
cut_off=args.minimum_cutoff,
307319
prep=args.library_prep,
308320
taxon_id=args.taxon,
321+
write_zfpkm_png_filepath=args.write_zfpkm_png_filepath,
309322
)
310323
)

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

0 commit comments

Comments
 (0)