Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@ script:
# Test running with BWA Mem
- nextflow run ${TRAVIS_BUILD_DIR} -profile test,docker --pairedEnd --bwamem --bwa_index results/reference_genome/bwa_index/bwa_index/
# Test with zipped reference input
- nextflow run ${TRAVIS_BUILD_DIR} -profile test,docker --pairedEnd --fasta 'https://raw.githubusercontent.com/nf-core/test-datasets/eager2/reference/Test.fasta.gz'
- nextflow run ${TRAVIS_BUILD_DIR} -profile test,docker --pairedEnd --fasta 'https://raw.githubusercontent.com/nf-core/test-datasets/eager2/reference/Test.fasta.gz'
# Run the basic pipeline with the bam input profile
- nextflow run ${TRAVIS_BUILD_DIR} -profile testbam,docker --bam
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

### `Added`
* [#127](https://github.com/nf-core/eager/pull/127) - Added a second testcase for testing the pipeline properly
* [#129](https://github.com/nf-core/eager/pull/129) - Support BAM files as [input format](https://github.com/nf-core/eager/issues/41)

### `Fixed`
* [#128](https://github.com/nf-core/eager/issues/128) - Fixed reference genome handling errors
Expand Down
5 changes: 4 additions & 1 deletion conf/base.config
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ process {
//errorStrategy = 'ignore'
}


withName:convertBam {
cpus = { check_max(8 * task.attempt, 'cpus') }
}

withName:bwa {
memory = { check_max( 16.GB * task.attempt, 'memory' ) }
cpus = { check_max(8 * task.attempt, 'cpus') }
Expand Down
22 changes: 22 additions & 0 deletions conf/testbam.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* -------------------------------------------------
* Nextflow config file for running tests
* -------------------------------------------------
* Defines bundled input files and everything required
* to run a fast and simple test. Use as follows:
* nextflow run nf-core/eager -profile test, docker (or singularity, or conda)
*/

params {
max_cpus = 2
max_memory = 6.GB
max_time = 48.h
genome = "Custom"
//Input data
readPaths = [
'https://github.com/nf-core/test-datasets/raw/eager2/testdata/Mammoth/bam/test1.bam',
'https://github.com/nf-core/test-datasets/raw/eager2/testdata/Mammoth/bam/test2.bam'
]
// Genome references
fasta = 'https://raw.githubusercontent.com/nf-core/test-datasets/eager2/reference/Mammoth_MT_Krause.fasta'
}
106 changes: 79 additions & 27 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def helpMessage() {
-profile Hardware config to use (e.g. standard, docker, singularity, conda, aws). Ask your system admin if unsure, or check documentatoin.
--singleEnd Specifies that the input is single end reads (required if not pairedEnd)
--pairedEnd Specifies that the input is paired end reads (required if not singleend)
--bam Specifies that the input is in BAM format
--fasta Path to Fasta reference (required if not iGenome reference)
--genome Name of iGenomes reference (required if not fasta reference)

Expand Down Expand Up @@ -259,9 +260,9 @@ if( params.bwa_index && (params.aligner == 'bwa' | params.bwamem)){
}

//Validate that either pairedEnd or singleEnd has been specified by the user!
if( params.singleEnd || params.pairedEnd ){
if( params.singleEnd || params.pairedEnd || params.bam){
} else {
exit 1, "Please specify either --singleEnd or --pairedEnd to execute the pipeline!"
exit 1, "Please specify either --singleEnd, --pairedEnd to execute the pipeline on FastQ files and --bam for previously processed BAM files!"
}


Expand All @@ -285,34 +286,56 @@ if( !(workflow.runName ==~ /[a-z]+_[a-z]+/) ){
* Dump can be used for debugging purposes, e.g. using the -dump-channels operator on run
*/

if(params.readPaths){
if(params.singleEnd){
if( params.readPaths ){
if( params.singleEnd && !params.bam) {
Channel
.from(params.readPaths)
.map { row -> [ row[0], [file(row[1][0])]] }
.ifEmpty { exit 1, "params.readPaths was empty - no input files supplied" }
.dump(tag:'input')
.from( params.readPaths )
.map { row -> [ row[0], [ file( row[1][0] ) ] ] }
.ifEmpty { exit 1, "params.readPaths or params.bams was empty - no input files supplied!" }
.into { ch_read_files_clip; ch_read_files_fastqc; ch_read_files_complexity_filtering }

} else {
ch_bam_to_fastq_convert = Channel.empty()
} else if (!params.bam){
Channel
.from(params.readPaths)
.map { row -> [ row[0], [file(row[1][0]), file(row[1][1])]] }
.ifEmpty { exit 1, "params.readPaths was empty - no input files supplied" }
.dump(tag:'input')
.from( params.readPaths )
.map { row -> [ row[0], [ file( row[1][0] ), file( row[1][1] ) ] ] }
.ifEmpty { exit 1, "params.readPaths or params.bams was empty - no input files supplied!" }
.into { ch_read_files_clip; ch_read_files_fastqc; ch_read_files_complexity_filtering }

ch_bam_to_fastq_convert = Channel.empty()
} else {
Channel
.from( params.readPaths )
.map { row -> [ file( row ) ] }
.ifEmpty { exit 1, "params.readPaths or params.bams was empty - no input files supplied!" }
.dump()
.into { ch_bam_to_fastq_convert }

//Set up clean channels
ch_read_files_fastqc = Channel.empty()
ch_read_files_complexity_filtering = Channel.empty()
ch_read_files_clip = Channel.empty()
}
} else {
Channel
} else if (!params.bam){
Channel
.fromFilePairs( params.reads, size: params.singleEnd ? 1 : 2 )
.ifEmpty { exit 1, "Cannot find any reads matching: ${params.reads}\nNB: Path needs to be enclosed in quotes!\nNB: Path requires at least one * wildcard!\nIf this is single-end data, please specify --singleEnd on the command line." }
.dump(tag:'input')
.ifEmpty { exit 1, "Cannot find any reads matching: ${params.reads}\nNB: Path needs" +
"to be enclosed in quotes!\nNB: Path requires at least one * wildcard!\nIf this is single-end data, please specify --singleEnd on the command line." }
.into { ch_read_files_clip; ch_read_files_fastqc; ch_read_files_complexity_filtering }

}

ch_bam_to_fastq_convert = Channel.empty()
} else {
Channel
.fromPath( params.reads )
.map { row -> [ file( row ) ] }
.ifEmpty { exit 1, "Cannot find any bam file matching: ${params.reads}\nNB: Path needs" +
"to be enclosed in quotes!\n" }
.dump() //For debugging purposes
.into { ch_bam_to_fastq_convert }

//Set up clean channels
ch_read_files_fastqc = Channel.empty()
ch_read_files_complexity_filtering = Channel.empty()
ch_read_files_clip = Channel.empty()

}

// Header log info
log.info "========================================="
Expand Down Expand Up @@ -461,6 +484,30 @@ process makeSeqDict {
"""
}

/*
* Convert BAM to FastQ if BAM input is specified instead of FastQ file(s)
*
*/

process convertBam {
tag "$bam"

when: params.bam

input:
file bam from ch_bam_to_fastq_convert

output:
set val("${base}"), file("*.fastq.gz") into (ch_read_files_converted_fastqc, ch_read_files_converted_fastp)
file("*.fastq.gz") into (ch_read_files_converted_mapping_bwa, ch_read_files_converted_mapping_cm, ch_read_files_converted_mapping_bwamem)

script:
base = "${bam.baseName}"
"""
samtools fastq -tn ${bam} | pigz -p ${task.cpus} > ${base}.fastq.gz
"""
}



/*
Expand All @@ -472,7 +519,7 @@ process fastqc {
saveAs: {filename -> filename.indexOf(".zip") > 0 ? "zips/$filename" : "$filename"}

input:
set val(name), file(reads) from ch_read_files_fastqc
set val(name), file(reads) from ch_read_files_fastqc.mix(ch_read_files_converted_fastqc)

output:
file "*_fastqc.{zip,html}" into ch_fastqc_results
Expand All @@ -496,7 +543,7 @@ process fastp {
when: params.complexity_filter

input:
set val(name), file(reads) from ch_read_files_complexity_filtering
set val(name), file(reads) from ch_read_files_complexity_filtering.mix(ch_read_files_converted_fastp)

output:
set val(name), file("*pG.fq.gz") into ch_clipped_reads_complexity_filtered
Expand Down Expand Up @@ -524,6 +571,8 @@ process adapter_removal {
tag "$name"
publishDir "${params.outdir}/read_merging", mode: 'copy'

when: !params.bam

input:
set val(name), file(reads) from ( params.complexity_filter ? ch_clipped_reads_complexity_filtered : ch_read_files_clip )

Expand Down Expand Up @@ -561,6 +610,8 @@ process fastqc_after_clipping {
publishDir "${params.outdir}/FastQC/after_clipping", mode: 'copy',
saveAs: {filename -> filename.indexOf(".zip") > 0 ? "zips/$filename" : "$filename"}

when: !params.bam

input:
file(reads) from ch_clipped_reads_for_fastqc

Expand All @@ -584,9 +635,10 @@ process bwa {
when: !params.circularmapper && !params.bwamem

input:
file(reads) from ch_clipped_reads
file(reads) from ch_clipped_reads.mix(ch_read_files_converted_mapping_bwa)
file index from ch_bwa_index.first()


output:
file "*.sorted.bam" into ch_mapped_reads_idxstats,ch_mapped_reads_filter,ch_mapped_reads_preseq, ch_mapped_reads_damageprofiler
file "*.bai" into ch_bam_index_for_damageprofiler
Expand Down Expand Up @@ -638,7 +690,7 @@ process circularmapper{
when: params.circularmapper

input:
file reads from ch_clipped_reads_circularmapper
file reads from ch_clipped_reads_circularmapper.mix(ch_read_files_converted_mapping_cm)
file index from ch_circularmapper_indices.first()

output:
Expand Down Expand Up @@ -666,7 +718,7 @@ process bwamem {
when: params.bwamem && !params.circularmapper

input:
file(reads) from ch_clipped_reads_bwamem
file(reads) from ch_clipped_reads_bwamem.mix(ch_read_files_converted_mapping_bwamem)
file index from ch_bwa_index_bwamem.first()

output:
Expand Down
2 changes: 2 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ params {
outdir = './results'
tracedir = "${params.outdir}/pipeline_info"
readPaths = false
bam = false

//More defaults
complexity_filter = false
Expand Down Expand Up @@ -54,6 +55,7 @@ profiles {
singularity.enabled = true
}
test { includeConfig 'conf/test.config' }
testbam { includeConfig 'conf/testbam.config' }
}

// Load igenomes.config if required
Expand Down