@@ -252,7 +252,11 @@ def resplice_primers(dedup_partitioned: list[pl.DataFrame]) -> list[pl.DataFrame
252
252
return mutated_frames
253
253
254
254
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 :
256
260
"""
257
261
`finalize_primer_pairings()` removes any spikeins with possible pairings
258
262
that could not be determined.
@@ -271,12 +275,12 @@ def finalize_primer_pairings(mutated_frames: list[pl.DataFrame]) -> pl.DataFrame
271
275
fwd_keepers = [
272
276
primer
273
277
for primer in df .select ("NAME" ).to_series ().to_list ()
274
- if "_LEFT" in primer
278
+ if fwd_suffix in primer
275
279
]
276
280
rev_keepers = [
277
281
primer
278
282
for primer in df .select ("NAME" ).to_series ().to_list ()
279
- if "_RIGHT" in primer
283
+ if rev_suffix in primer
280
284
]
281
285
if len (fwd_keepers ) > 0 and len (rev_keepers ) > 0 :
282
286
final_frames .append (df )
@@ -293,7 +297,7 @@ def main() -> None:
293
297
294
298
partitioned_bed = (
295
299
pl .read_csv (
296
- args .input_bed ,
300
+ args .bed_file ,
297
301
separator = "\t " ,
298
302
has_header = False ,
299
303
new_columns = [
@@ -308,7 +312,7 @@ def main() -> None:
308
312
.with_columns (pl .col ("NAME" ).alias ("ORIG_NAME" ))
309
313
.with_columns (
310
314
pl .col ("NAME" )
311
- .str .replace_all (args .fwd_suffix , "" )
315
+ .str .replace_all (args .fwd_prefix , "" )
312
316
.str .replace_all (args .rev_suffix , "" )
313
317
.str .replace_all (r"-\d+" , "" )
314
318
.alias ("Amplicon" ),
@@ -332,7 +336,7 @@ def main() -> None:
332
336
mutated_frames = resplice_primers (dedup_partitioned )
333
337
334
338
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" )
336
340
return
337
341
338
342
final_df = finalize_primer_pairings (mutated_frames )
0 commit comments