INNER CODE UNIT · Python
read_write_fq
nf-core/eager · bin/extract_map_reads.py:92
def read_write_fq(fq_in, fq_out, mapped_reads, mode, write_mode, proc):
"""
Read and write fastq file with mapped reads removed
Args:
fq_in(str): path to input fastq file
fq_out(str): path to output fastq file
mapped_reads(set): set of mapped reads name (str)
mode(str): read removal mode (remove or replace)
write_mode(str): write mode (w or wb)
proc(int): number of parallel processes
merged(bool): True if bam file was created from merged fastq files
"""
if write_mode == "w":
cm = open(fq_out, write_mode)
elif write_mode == "wb":
cm = xopen(fq_out, mode=write_mode, threads=proc)
with pysam.FastxFile(fq_in) as fh:
with cm as fh_out: