Skip to content

Commit

Permalink
Merge pull request #50 from nf-core/dev
Browse files Browse the repository at this point in the history
PR for next release
  • Loading branch information
apeltzer committed Feb 4, 2019
2 parents 70684bb + e51c2f1 commit 18740c2
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 26 deletions.
19 changes: 12 additions & 7 deletions .travis.yml
Expand Up @@ -10,21 +10,26 @@ matrix:
fast_finish: true

before_install:
# PRs made to 'master' branch should always orginate from another repo or the 'dev' branch
# PRs to master are only ok if coming from dev branch
- '[ $TRAVIS_PULL_REQUEST = "false" ] || [ $TRAVIS_BRANCH != "master" ] || ([ $TRAVIS_PULL_REQUEST_SLUG = $TRAVIS_REPO_SLUG ] && [ $TRAVIS_PULL_REQUEST_BRANCH = "dev" ])'
- docker pull nfcore/hlatyping
- docker tag nfcore/hlatyping nfcore/hlatyping:1.1.3
# Pull the docker image first so the test doesn't wait for this
- docker pull nfcore/hlatyping:dev
- docker tag nfcore/hlatyping:dev nfcore/hlatyping:1.1.3

install:
# Install Nextflow
- mkdir /tmp/nextflow
- cd /tmp/nextflow
- mkdir /tmp/nextflow && cd /tmp/nextflow
- wget -qO- get.nextflow.io | bash
- sudo ln -s /tmp/nextflow/nextflow /usr/local/bin/nextflow
# Install nf-core/tools
- pip install nf-core==1.3
- pip install nf-core
# Install Conda
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
- bash Miniconda3-latest-Linux-x86_64.sh -b -f -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
# Reset
- cd ${TRAVIS_BUILD_DIR}
- mkdir -p ${TRAVIS_BUILD_DIR}/tests && cd ${TRAVIS_BUILD_DIR}/tests


env:
- NXF_VER='18.10.1' # Specify a minimum NF version that should be tested and work
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
@@ -1,7 +1,7 @@
## 1.1.3 - Patch release - 2018-12-12
## 1.1.3 - Patch release - 2019-02-04

- Multiple smaller bugfixes, cleaned up code basis

- [#48](https://github.com/nf-core/hlatyping/issues/48) - Utilizes RNA/DNA reference genome for remapping correctly

## 1.1.2 - Patch release - 2018-12-12

Expand Down
7 changes: 7 additions & 0 deletions conf/base.config
Expand Up @@ -26,6 +26,13 @@ process {
executor = 'local'
errorStrategy = { task.exitStatus in [143,137] ? 'retry' : 'ignore' }
}
withname:remap_to_hla{
cpus = { check_max( 4 * task.attempt, 'cpus' ) }
}
withname:pre_map_hla{
cpus = { check_max( 4 * task.attempt, 'cpus' ) }
}

}

params {
Expand Down
23 changes: 23 additions & 0 deletions conf/test_rna.config
@@ -0,0 +1,23 @@
/*
* -------------------------------------------------
* 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/hlatyping -profile test
*/

params {
max_cpus = 2
max_memory = 7.GB
max_time = 48.h
singleEnd = false
readPaths = [
['test_data', ['https://github.com/nf-core/test-datasets/raw/hlatyping/rna/CRC_81_N_1_fished.fastq.gz',
'https://github.com/nf-core/test-datasets/raw/hlatyping/rna/CRC_81_N_2_fished.fastq.gz']]
]
solver = 'glpk'
seqtype = 'rna'
bam = false
outdir = "results"
}
35 changes: 19 additions & 16 deletions main.nf
Expand Up @@ -27,7 +27,7 @@ def helpMessage() {
Mandatory arguments:
--reads Path to input data (must be surrounded with quotes)
--rna/--dna Use with RNA/DNA sequencing data.
--seqtype rna/dna Use with RNA/DNA sequencing data.
--outdir OUTDIR The output directory where the results will be saved
-profile Hardware config to use. docker / aws
Expand Down Expand Up @@ -69,7 +69,7 @@ ch_multiqc_config = Channel.fromPath(params.multiqc_config)

// Validate inputs
params.reads ?: params.readPaths ?: { log.error "No read data privided. Make sure you have used the '--reads' option."; exit 1 }()
params.seqtype ?: { log.error "No sequence type provided, you need to add '--dna/--rna.'"; exit 1 }()
(params.seqtype == 'rna' || params.seqtype == 'dna') ?: { log.error "No or incorrect sequence type provided, you need to add '--seqtype 'dna'' or '--seqtype 'rna''."; exit 1 }()
if( params.bam ) params.index ?: { log.error "For BAM option, you need to provide a path to the HLA reference index (yara; --index) "; exit 1 }()
params.outdir = params.outdir ?: { log.warn "No output directory provided. Will put the results into './results'"; return "./results" }()

Expand Down Expand Up @@ -109,13 +109,14 @@ summary['Run Name'] = custom_runName ?: workflow.runName
summary['Reads'] = params.readPaths? params.readPaths : params.reads
summary['Data Type'] = params.singleEnd ? 'Single-End' : 'Paired-End'
summary['File Type'] = params.bam ? 'BAM' : 'Other (fastq, fastq.gz, ...)'
summary['Index Location'] = params.index ?: { log.error "You did not provide any path to the mapper indices."; exit 1 }
summary['Seq Type'] = params.seqtype
summary['Index Location'] = params.base_index + params.seqtype
summary['IP solver'] = params.solver
summary['Enumerations'] = params.enumerations
summary['Beta'] = params.beta
summary['Prefix'] = params.prefix
summary['Max Memory'] = params.max_memory
summary['Max CP Us'] = params.max_cpus
summary['Max CPUs'] = params.max_cpus
summary['Max Time'] = params.max_time
summary['Output dir'] = params.outdir
summary['Working dir'] = workflow.workDir
Expand Down Expand Up @@ -207,21 +208,22 @@ if ( !params.bam ) { // FASTQ files processing
set val(pattern), "mapped_{1,2}.bam" into fished_reads

script:
full_index = params.base_index + params.seqtype
if (params.singleEnd)
"""
samtools bam2fq $bams > output_1.fastq
yara_mapper -e 3 -t ${params.max_cpus} -f bam ${params.index} output_1.fastq > output_1.bam
samtools view -h -F 4 -b1 output_1.bam > mapped_1.bam
yara_mapper -e 3 -t ${task.cpus} -f bam $full_index output_1.fastq > output_1.bam
samtools view -@ ${task.cpus} -h -F 4 -b1 output_1.bam > mapped_1.bam
"""
else
"""
samtools view -h -f 0x40 $bams > output_1.bam
samtools view -h -f 0x80 $bams > output_2.bam
samtools view -@ ${task.cpus} -h -f 0x40 $bams > output_1.bam
samtools view -@ ${task.cpus} -h -f 0x80 $bams > output_2.bam
samtools bam2fq output_1.bam > output_1.fastq
samtools bam2fq output_2.bam > output_2.fastq
yara_mapper -e 3 -t ${params.max_cpus} -f bam ${params.index} output_1.fastq output_2.fastq > output.bam
samtools view -h -F 4 -f 0x40 -b1 output.bam > mapped_1.bam
samtools view -h -F 4 -f 0x80 -b1 output.bam > mapped_2.bam
yara_mapper -e 3 -t ${task.cpus} -f bam $full_index output_1.fastq output_2.fastq > output.bam
samtools view -@ ${task.cpus} -h -F 4 -f 0x40 -b1 output.bam > mapped_1.bam
samtools view -@ ${task.cpus} -h -F 4 -f 0x80 -b1 output.bam > mapped_2.bam
"""

}
Expand Down Expand Up @@ -271,16 +273,17 @@ process pre_map_hla {
set val(pattern), "mapped_{1,2}.bam" into fished_reads

script:
full_index = params.base_index + params.seqtype
if (params.singleEnd)
"""
yara_mapper -e 3 -t ${params.max_cpus} -f bam ${params.index} $reads > output_1.bam
samtools view -h -F 4 -b1 output_1.bam > mapped_1.bam
yara_mapper -e 3 -t ${task.cpus} -f bam $full_index $reads > output_1.bam
samtools view -@ ${task.cpus} -h -F 4 -b1 output_1.bam > mapped_1.bam
"""
else
"""
yara_mapper -e 3 -t ${params.max_cpus} -f bam ${params.index} $reads > output.bam
samtools view -h -F 4 -f 0x40 -b1 output.bam > mapped_1.bam
samtools view -h -F 4 -f 0x80 -b1 output.bam > mapped_2.bam
yara_mapper -e 3 -t ${task.cpus} -f bam $full_index $reads > output.bam
samtools view -@ ${task.cpus} -h -F 4 -f 0x40 -b1 output.bam > mapped_1.bam
samtools view -@ ${task.cpus} -h -F 4 -f 0x80 -b1 output.bam > mapped_2.bam
"""

}
Expand Down
5 changes: 4 additions & 1 deletion nextflow.config
Expand Up @@ -27,6 +27,9 @@ params {
enumerations = 1
beta = 0.009
prefix = 'hla_run'
//use this to combine accordingly for dna/rna samples
base_index = "$baseDir/data/indices/yara/hla_reference_"
//Simple default case
index = "$baseDir/data/indices/yara/hla_reference_dna"

igenomesIgnore = false
Expand All @@ -50,10 +53,10 @@ profiles {
}
singularity {
singularity.enabled = true
process.container = {"shub://${params.container.replace('nfcore', 'nf-core')}"}
}
test { includeConfig 'conf/test.config' }
test_fastq { includeConfig 'conf/test_fastq.config'}
test_rna { includeConfig 'conf/test_rna.config'}
}

// Load igenomes.config if required
Expand Down

0 comments on commit 18740c2

Please sign in to comment.