Skip to content

Commit 7e1fc9f

Browse files
committed
small tweaks to resplicing
1 parent 3df6281 commit 7e1fc9f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

bin/resplice_primers.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ def resplice_primers(dedup_partitioned: list[pl.DataFrame]) -> list[pl.DataFrame
252252
return mutated_frames
253253

254254

255-
def finalize_primer_pairings(mutated_frames: list[pl.DataFrame]) -> pl.DataFrame:
255+
def finalize_primer_pairings(
256+
mutated_frames: list[pl.DataFrame],
257+
fwd_suffix: str,
258+
rev_suffix: str,
259+
) -> pl.DataFrame:
256260
"""
257261
`finalize_primer_pairings()` removes any spikeins with possible pairings
258262
that could not be determined.
@@ -271,12 +275,12 @@ def finalize_primer_pairings(mutated_frames: list[pl.DataFrame]) -> pl.DataFrame
271275
fwd_keepers = [
272276
primer
273277
for primer in df.select("NAME").to_series().to_list()
274-
if "_LEFT" in primer
278+
if fwd_suffix in primer
275279
]
276280
rev_keepers = [
277281
primer
278282
for primer in df.select("NAME").to_series().to_list()
279-
if "_RIGHT" in primer
283+
if rev_suffix in primer
280284
]
281285
if len(fwd_keepers) > 0 and len(rev_keepers) > 0:
282286
final_frames.append(df)
@@ -293,7 +297,7 @@ def main() -> None:
293297

294298
partitioned_bed = (
295299
pl.read_csv(
296-
args.input_bed,
300+
args.bed_file,
297301
separator="\t",
298302
has_header=False,
299303
new_columns=[
@@ -308,7 +312,7 @@ def main() -> None:
308312
.with_columns(pl.col("NAME").alias("ORIG_NAME"))
309313
.with_columns(
310314
pl.col("NAME")
311-
.str.replace_all(args.fwd_suffix, "")
315+
.str.replace_all(args.fwd_prefix, "")
312316
.str.replace_all(args.rev_suffix, "")
313317
.str.replace_all(r"-\d+", "")
314318
.alias("Amplicon"),
@@ -332,7 +336,7 @@ def main() -> None:
332336
mutated_frames = resplice_primers(dedup_partitioned)
333337

334338
if len(mutated_frames) == 0:
335-
shutil.copy(args.input_bed, f"{args.output_prefix}.bed")
339+
shutil.copy(args.bed_file, f"{args.output_prefix}.bed")
336340
return
337341

338342
final_df = finalize_primer_pairings(mutated_frames)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ dev-dependencies = [
101101
"jupyter>=0.6.4",
102102
"just>=0.8.162",
103103
"mamba>=0.11.3",
104-
"marimo[sql]>=0.8.14",
104+
"marimo[sql]>=0.9.10",
105105
"pip>=24.2",
106106
"pre-commit>=3.8.0",
107107
"pytest>=8.3.3",

0 commit comments

Comments
 (0)