Skip to content

Commit

Permalink
Fixing shortreads id getter
Browse files Browse the repository at this point in the history
  • Loading branch information
fmalmeida committed Aug 18, 2020
1 parent 3f3649e commit f7feef3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 34 deletions.
47 changes: 24 additions & 23 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -321,32 +321,32 @@ workflow pacbio_bas_nf {
nanopack(pacbio_bam2fastq.out[0].flatten(), threads)
}

workflow paired_shortreads_nf {
workflow shortreads_nf {
take:
reads
preads
sreads
threads
main:
fastqc(reads, threads)
trimgalore(reads, threads)
if (params.lighter_execute && params.flash_execute) {
lighter(trimgalore.out[0], threads)
flash(lighter.out[0], threads)
} else if (params.lighter_execute && !params.flash_execute) {
lighter(trimgalore.out[0], threads)
} else if (!params.lighter_execute && params.flash_execute) {
flash(trimgalore.out[0], threads)
fastqc(preads, sreads, threads)
trimgalore(preads, sreads, threads)

// Paired
if (params.shortreads_type == 'paired') {
if (params.lighter_execute && params.flash_execute) {
lighter(trimgalore.out[0], threads)
flash(lighter.out[0], threads)
} else if (params.lighter_execute && !params.flash_execute) {
lighter(trimgalore.out[0], threads)
} else if (!params.lighter_execute && params.flash_execute) {
flash(trimgalore.out[0], threads)
}
}
}

workflow single_shortreads_nf {
take:
reads
threads
main:
fastqc(reads, threads)
trimgalore(reads, threads)
if (params.lighter_execute) {
lighter(trimgalore.out[1].flatten(), threads)
// Single
if (params.shortreads_type == 'paired') {
if (params.lighter_execute) {
lighter(trimgalore.out[1].flatten(), threads)
}
}
}

Expand Down Expand Up @@ -387,14 +387,15 @@ workflow {
* User has short paired end reads
*/
if (params.shortreads && params.shortreads_type == 'paired') {
paired_shortreads_nf(Channel.fromFilePairs(params.shortreads, flat: true, size: 2), params.threads)
shortreads_nf(Channel.fromFilePairs(params.shortreads, flat: true, size: 2),
Channel.value(''), params.threads)
}

/*
* User has short single end reads
*/
if (params.shortreads && params.shortreads_type == 'single') {
single_shortreads_nf(Channel.fromPath(params.shortreads), params.threads)
shortreads_nf(Channel.value(['', '', '']), Channel.fromPath(params.shortreads), params.threads)
}
}

Expand Down
14 changes: 9 additions & 5 deletions modules/fastqc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@ process fastqc {
tag "Evaluating short reads with FastQC"

input:
file reads
tuple val(id), file(read1), file(read2)
file(sreads)
val threads

output:
file "fastqc_${id}/*_fastqc.{zip,html}"

script:

if (params.shortreads_type == 'paired') {
id = (reads[1].getBaseName() - "_1")
param = "-q ${reads[1]} ${reads[2]}"
param = "-q ${read1} ${read2}"
}
else if (params.shortreads_type == 'single') {
param = "-q ${reads}"
id = reads.getBaseName()
param = "-q ${sreads}"
id = sreads.getBaseName()
}

"""
mkdir fastqc_${id} ;
fastqc -t $threads -o fastqc_${id} $param
Expand Down
13 changes: 7 additions & 6 deletions modules/trimgalore.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ process trimgalore {
else null
}
container 'fmalmeida/ngs-preprocess'
tag "Executing TrimGalore with paired end reads."
tag "Executing TrimGalore"

input:
file reads
file threads
tuple val(id), file(read1), file(read2)
file(sreads)
val threads

output:
tuple val('trimgalore'), file("${id}_1.fq.gz"), file("${id}_2.fq.gz") optional true
file "*.fq.gz" optional true
Expand All @@ -27,12 +29,11 @@ process trimgalore {
tpc_r2 = params.three_prime_clip_r2 > 0 ? "--three_prime_clip_r2 ${params.three_prime_clip_r2}" : ''

if (params.shortreads_type == 'paired') {
id = (reads[1].getBaseName() - "_1")
param = "--paired $c_r1 $c_r2 $tpc_r1 $tpc_r2 ${reads[1]} ${reads[2]}"
param = "--paired $c_r1 $c_r2 $tpc_r1 $tpc_r2 ${read1} ${read2}"
rename = "mv *_val_1.fq.gz ${id}_1.fq.gz ; mv *_val_2.fq.gz ${id}_2.fq.gz"
}
else if (params.shortreads_type == 'single') {
param = "$c_r1 $tpc_r1 ${reads}"
param = "$c_r1 $tpc_r1 ${sreads}"
id = reads.getBaseName()
rename = ''
}
Expand Down

0 comments on commit f7feef3

Please sign in to comment.