Skip to content

Commit

Permalink
code polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Jul 15, 2020
1 parent ac503af commit a6168b1
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 60 deletions.
10 changes: 4 additions & 6 deletions modules/local/build_intervals.nf
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
process BUILD_INTERVALS {
tag "${fastaFai}"
tag "${fai}"

publishDir params.outdir, mode: params.publish_dir_mode,
saveAs: {params.save_reference ? "reference_genome/${it}" : null }

input:
path file(fastaFai)
path fai

output:
path file("${fastaFai.baseName}.bed")

//when: !(params.intervals) && !('annotate' in step) && !('controlfreec' in step)
path "${fai.baseName}.bed"

script:
"""
awk -v FS='\t' -v OFS='\t' '{ print \$1, \"0\", \$2 }' ${fastaFai} > ${fastaFai.baseName}.bed
awk -v FS='\t' -v OFS='\t' '{ print \$1, \"0\", \$2 }' ${fai} > ${fai.baseName}.bed
"""
}
9 changes: 4 additions & 5 deletions modules/local/create_intervals_bed.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include { hasExtension } from './functions'
include { has_extension } from './functions'

process CREATE_INTERVALS_BED {
tag "${intervals}"
Expand All @@ -7,13 +7,12 @@ process CREATE_INTERVALS_BED {
path intervals

output:
path ('*.bed')//mode flatten

path ('*.bed')

script:
// If the interval file is BED format, the fifth column is interpreted to
// contain runtime estimates, which is then used to combine short-running jobs
if (hasExtension(intervals, "bed"))
if (has_extension(intervals, "bed"))
"""
awk -vFS="\t" '{
t = \$5 # runtime estimate
Expand All @@ -33,7 +32,7 @@ process CREATE_INTERVALS_BED {
print \$0 > name
}' ${intervals}
"""
else if (hasExtension(intervals, "interval_list"))
else if (has_extension(intervals, "interval_list"))
"""
grep -v '^@' ${intervals} | awk -vFS="\t" '{
name = sprintf("%s_%d-%d", \$1, \$2, \$3);
Expand Down
2 changes: 1 addition & 1 deletion modules/local/gatk_dict.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process GATK_CREATE_SEQUENCE_DICTIONARY {
path fasta

output:
path ("${fasta.baseName}.dict")
path "${fasta.baseName}.dict"

script:
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/local/get_software_versions.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ process GET_SOFTWARE_VERSIONS {
}

output:
path 'software_versions_mqc.yaml', emit: yml
path "software_versions_mqc.yaml", emit: yml
path "software_versions.csv", emit: csv

script:
Expand Down
8 changes: 4 additions & 4 deletions modules/local/output_documentation.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ process OUTPUT_DOCUMENTATION {
publishDir "${params.outdir}/pipeline_info", mode: params.publish_dir_mode

input:
path output_docs
path images
path output_docs
path images

output:
path "results_description.html"
path "results_description.html"

script:
"""
markdown_to_html.py $output_docs -o results_description.html
markdown_to_html.py ${output_docs} -o results_description.html
"""
}
11 changes: 5 additions & 6 deletions modules/local/trim_galore.nf
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ process TRIM_GALORE {

publishDir "${params.outdir}/Reports/${idSample}/TrimGalore/${idSample}_${idRun}", mode: params.publish_dir_mode,
saveAs: {filename ->
if (filename.indexOf("_fastqc") > 0) "FastQC/$filename"
else if (filename.indexOf("trimming_report.txt") > 0) "logs/$filename"
if (filename.indexOf("_fastqc") > 0) "FastQC/${filename}"
else if (filename.indexOf("trimming_report.txt") > 0) "logs/${filename}"
else if (params.save_trimmed) filename
else null
}

input:
tuple val(idPatient), val(idSample), val(idRun), file("${idSample}_${idRun}_R1.fastq.gz"), file("${idSample}_${idRun}_R2.fastq.gz")
tuple val(idPatient), val(idSample), val(idRun), path("${idSample}_${idRun}_R1.fastq.gz"), path("${idSample}_${idRun}_R2.fastq.gz")

output:
path "*.{html,zip,txt}", emit: report
tuple idPatient, idSample, idRun, file("${idSample}_${idRun}_R1_val_1.fq.gz"), file("${idSample}_${idRun}_R2_val_2.fq.gz") , emit: trimmed_reads

path "*.{html,zip,txt}", emit: report
tuple idPatient, idSample, idRun, path("${idSample}_${idRun}_R1_val_1.fq.gz"), path("${idSample}_${idRun}_R2_val_2.fq.gz"), emit: trimmed_reads

script:
// Calculate number of --cores for TrimGalore based on value of task.cpus
Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/bwamem2_index.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process BWAMEM2_INDEX {
path fasta

output:
path("${fasta}.*")
path "${fasta}.*"

script:
"""
Expand Down
7 changes: 3 additions & 4 deletions modules/nf-core/fastqc.nf
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
process FASTQC {
label 'FastQC'
label 'FASTQC'
label 'cpus_2'

tag "${idPatient}-${idRun}"

publishDir "${params.outdir}/Reports/${idSample}/FastQC/${idSample}_${idRun}", mode: params.publish_dir_mode

input:
tuple val(idPatient), val(idSample), val(idRun), file("${idSample}_${idRun}_R1.fastq.gz"), file("${idSample}_${idRun}_R2.fastq.gz")
tuple val(idPatient), val(idSample), val(idRun), path("${idSample}_${idRun}_R1.fastq.gz"), path("${idSample}_${idRun}_R2.fastq.gz")

output:
path "*.{html,zip}"


script:
"""
fastqc -t 2 -q ${idSample}_${idRun}_R1.fastq.gz ${idSample}_${idRun}_R2.fastq.gz
Expand Down
4 changes: 2 additions & 2 deletions modules/nf-core/htslib_tabix.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ process HTSLIB_TABIX {
container 'quay.io/biocontainers/tabix:0.2.6--ha92aebf_0'

input:
path(vcf)
path vcf

output:
path("${vcf}.tbi")
path "${vcf}.tbi"

script:
"""
Expand Down
29 changes: 14 additions & 15 deletions modules/nf-core/multiqc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ process MULTIQC {
publishDir "${params.outdir}/multiqc", mode: params.publish_dir_mode

input:
path multiqc_config
path mqc_custom_config
// TODO nf-core: Add in log files from your new processes for MultiQC to find!
path fastqc
path trim_galore
path software_versions
val workflow_summary
path fastqc
path multiqc_config
path multiqc_custom_config
path software_versions
path trim_galore
val workflow_summary

output:
path "*multiqc_report.html"
path "*_data"
path "multiqc_plots"
path "*multiqc_report.html"
path "*_data"
path "multiqc_plots"

script:
rtitle = custom_runName ? "--title \"$custom_runName\"" : ''
rfilename = custom_runName ? "--filename " + custom_runName.replaceAll('\\W','_').replaceAll('_+','_') + "_multiqc_report" : ''
custom_config_file = params.multiqc_config ? "--config $mqc_custom_config" : ''
title = custom_runName ? "--title \"${custom_runName}\"" : ''
filename = custom_runName ? "--filename " + custom_runName.replaceAll('\\W','_').replaceAll('_+','_') + "_multiqc_report" : ''
custom_config_file = params.multiqc_config ? "--config ${multiqc_custom_config}" : ''
"""
echo '$workflow_summary' > workflow_summary_mqc.yaml
multiqc -f $rtitle $rfilename $custom_config_file .
echo '${workflow_summary}' > workflow_summary_mqc.yaml
multiqc -f ${title} ${filename} ${custom_config_file} .
"""
}
2 changes: 1 addition & 1 deletion modules/nf-core/samtools_faidx.nf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process SAMTOOLS_FAIDX {
path fasta

output:
path ("${fasta}.fai")
path "${fasta}.fai"

//when: !(params.fasta_fai) && params.fasta && !('annotate' in step)

Expand Down
26 changes: 12 additions & 14 deletions modules/subworkflows/build_indices.nf
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

// And then initialize channels based on params or indexes that were just built


include { HTSLIB_TABIX as HTSLIB_TABIX_DBSNP } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_GERMLINE_RESOURCE } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_KNOWN_INDELS } from '../nf-core/htslib_tabix'
include { HTSLIB_TABIX as HTSLIB_TABIX_PON } from '../nf-core/htslib_tabix'
include { BUILD_INTERVALS } from '../local/build_intervals.nf'
include { BWAMEM2_INDEX as BWAMEM2_INDEX } from '../nf-core/bwamem2_index.nf'
include { SAMTOOLS_FAIDX as SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'
include { GATK_CREATE_SEQUENCE_DICTIONARY as GATK_CREATE_SEQUENCE_DICTIONARY } from '../local/gatk_dict.nf'
include { BUILD_INTERVALS } from '../local/build_intervals.nf'

include {
HTSLIB_TABIX as HTSLIB_TABIX_DBSNP;
HTSLIB_TABIX as HTSLIB_TABIX_GERMLINE_RESOURCE;
HTSLIB_TABIX as HTSLIB_TABIX_KNOWN_INDELS;
HTSLIB_TABIX as HTSLIB_TABIX_PON;
} from '../nf-core/htslib_tabix'
include { SAMTOOLS_FAIDX as SAMTOOLS_FAIDX } from '../nf-core/samtools_faidx.nf'

workflow BUILD_INDICES{
take:
Expand Down Expand Up @@ -49,19 +49,17 @@ workflow BUILD_INDICES{
if (!(params.pon_index) && params.pon && ('tnscope' in tools || 'mutect2' in tools))
HTSLIB_TABIX_PON(ch_pon)

if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step)){
ch_fai = params.fasta_fai ? Channel.value(file(params.fasta_fai)) : SAMTOOLS_FAIDX.out
ch_fai.dump(tag: 'ch_fai')
BUILD_INTERVALS(ch_fai)
if (!(params.intervals) && !('annotate' in step) && !('controlfreec' in step)) {
BUILD_INTERVALS(SAMTOOLS_FAIDX.out)
}

emit:
bwa_built = BWAMEM2_INDEX.out
dbsnp_tbi = HTSLIB_TABIX_DBSNP.out
dictBuilt = GATK_CREATE_SEQUENCE_DICTIONARY.out
fai_built = SAMTOOLS_FAIDX.out
dbsnp_tbi = HTSLIB_TABIX_DBSNP.out
germline_resource_tbi = HTSLIB_TABIX_GERMLINE_RESOURCE.out
intervalBuilt = BUILD_INTERVALS.out
known_indels_tbi = HTSLIB_TABIX_KNOWN_INDELS.out
pon_tbi = HTSLIB_TABIX_PON.out
intervalBuilt = BUILD_INTERVALS.out
}

0 comments on commit a6168b1

Please sign in to comment.