Skip to content

Commit 7a21c1b

Browse files
authored
Merge pull request #197 from maxibor/dev
Fix of #189
2 parents 0b4fe32 + 5ccf605 commit 7a21c1b

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

bin/extract_map_reads.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ def _get_args():
1919
parser.add_argument('bam_file', help="path to bam file")
2020
parser.add_argument('fwd', help='path to forward fastq file')
2121
parser.add_argument(
22-
'-2',
22+
'-rev',
2323
dest="rev",
2424
default=None,
25-
help="path to forward fastq file")
25+
help="path to reverse fastq file")
2626
parser.add_argument(
2727
'-of',
2828
dest="out_fwd",
@@ -163,8 +163,8 @@ def write_fq(fq_dict, fname, mode):
163163
"""
164164
Write to fastq file
165165
INPUT:
166-
- fq_dict(dict) dictionary with unmapped read names as keys, seq and quality as values
167-
in a list
166+
- fq_dict(dict) dictionary with unmapped read names as keys,
167+
unmapped/mapped (u|m), seq, and quality as values in a list
168168
- fname(string) Path to output fastq file
169169
- mode(string) strip (remove read) or replace (replace read sequence) by Ns
170170
"""
@@ -218,6 +218,11 @@ def write_fq(fq_dict, fname, mode):
218218
f.write(f"{i}\n")
219219

220220

221+
def check_strip_mode(mode):
222+
if mode.lower() not in ['replace', 'strip']:
223+
print(f"Mode must be {' or '.join(mode)}")
224+
225+
221226
if __name__ == "__main__":
222227
BAM, IN_FWD, IN_REV, OUT_FWD, OUT_REV, MODE, PROC = _get_args()
223228

main.nf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,14 @@ process strip_input_fastq {
947947
out_fwd = bam.baseName+'.stripped.fq.gz'
948948
"""
949949
samtools index $bam
950-
extract_map_reads.py $bam ${fq[0]} -of $out_fwd -p ${task.cpus}
950+
extract_map_reads.py $bam ${fq[0]} -m ${params.strip_mode} -of $out_fwd -p ${task.cpus}
951951
"""
952952
} else {
953953
out_fwd = bam.baseName+'.stripped.fwd.fq.gz'
954954
out_rev = bam.baseName+'.stripped.rev.fq.gz'
955955
"""
956956
samtools index $bam
957-
extract_map_reads.py $bam ${fq[0]} -2 ${fq[0]} -of $out_fwd -or $out_rev -p ${task.cpus}
957+
extract_map_reads.py $bam ${fq[0]} -rev ${fq[1]} -m ${params.strip_mode} -of $out_fwd -or $out_rev -p ${task.cpus}
958958
"""
959959
}
960960

0 commit comments

Comments
 (0)