Skip to content

Commit 37b4b6e

Browse files
authored
Merge pull request #130 from icgc-argo-workflows/seq-data-to-lane-fastq@0.2.0
[release]
2 parents edd1ba4 + 17bbbba commit 37b4b6e

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

seq-data-to-lane-fastq/main.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
/* this block is auto-generated based on info from pkg.json where */
2525
/* changes can be made if needed, do NOT modify this block manually */
2626
nextflow.enable.dsl = 2
27-
version = '0.1.0' // package version
27+
version = '0.2.0'
2828

2929
container = [
3030
'ghcr.io': 'ghcr.io/icgc-argo-workflows/dna-seq-processing-tools.seq-data-to-lane-fastq'

seq-data-to-lane-fastq/main.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ def bunzip2(fq_pair):
180180

181181
return bunzipped
182182

183+
def get_new_filename(fastq_old, rg_id_fn, r1_r2, outdir):
184+
if fastq_old.endswith('fq') or fastq_old.endswith('fastq'):
185+
fastq_new = os.path.join(os.getcwd(), outdir, f'{rg_id_fn}_{r1_r2}.fq')
186+
elif fastq_old.endswith('fq.gz') or fastq_old.endswith('fastq.gz'):
187+
fastq_new = os.path.join(os.getcwd(), outdir, f'{rg_id_fn}_{r1_r2}.fq.gz')
188+
else:
189+
sys.exit("Unsupported file format: %s." % fastq_old)
190+
191+
return fastq_new
192+
193+
183194

184195
def main():
185196
"""
@@ -228,14 +239,16 @@ def main():
228239
fq_pair = filename_to_file(fp, args.seq_files)
229240
fastq_pair = bunzip2(fq_pair)
230241
rg = filepair_map_to_readgroup[fp]['read_groups'][0]
231-
file_r1_new = os.path.join(os.getcwd(), args.outdir, os.path.basename(fastq_pair[0]))
242+
rg_id = rg['submitter_read_group_id']
243+
rg_id_fn = readgroup_id_to_fname(rg_id, '', study_id, donor_id, sample_id)
244+
file_r1_new = get_new_filename(fastq_pair[0], rg_id_fn, "R1", args.outdir)
232245
os.symlink(os.path.abspath(fastq_pair[0]), file_r1_new)
233246
if fastq_pair[1]:
234-
file_r2_new = os.path.join(os.getcwd(), args.outdir, os.path.basename(fastq_pair[1]))
235-
os.symlink(os.path.abspath(fastq_pair[0]), file_r2_new)
247+
file_r2_new = get_new_filename(fastq_pair[1], rg_id_fn, "R2", args.outdir)
248+
os.symlink(os.path.abspath(fastq_pair[1]), file_r2_new)
236249
else:
237250
file_r2_new = 'No_File'
238-
rgs_file_pair_map[rg['submitter_read_group_id']] = {
251+
rgs_file_pair_map[rg_id] = {
239252
'file_r1': file_r1_new,
240253
'file_r2': file_r2_new
241254
}

seq-data-to-lane-fastq/pkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "seq-data-to-lane-fastq",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "convert input reads to lane level fastq",
55
"main": "main.nf",
66
"deprecated": false,

seq-data-to-lane-fastq/tests/checker.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/* this block is auto-generated based on info from pkg.json where */
3030
/* changes can be made if needed, do NOT modify this block manually */
3131
nextflow.enable.dsl = 2
32-
version = '0.1.0' // package version
32+
version = '0.2.0'
3333

3434
container = [
3535
'ghcr.io': 'ghcr.io/icgc-argo-workflows/dna-seq-processing-tools.seq-data-to-lane-fastq'

0 commit comments

Comments
 (0)