-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from CCBR/champagne-qc-fixes
Refactor with fixes from Champagne QC
- Loading branch information
Showing
14 changed files
with
299 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
process CUSTOM_COUNTFASTQ { | ||
tag { meta.id } | ||
label 'process_single' | ||
|
||
container 'nciccbr/ccbr_ubuntu_base_20.04:v6.1' | ||
|
||
input: | ||
tuple val(meta), path(fastq) | ||
|
||
output: | ||
tuple val(meta), path("*.txt"), emit: count | ||
path('versions.yml'), emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
template 'count-fastq.py' | ||
|
||
stub: | ||
""" | ||
count=-1 | ||
echo \$count > ${meta.id}.count.txt | ||
touch versions.yml | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: custom_countfastq | ||
description: | | ||
Count reads in a fastq file | ||
keywords: | ||
- fastq | ||
- biopython | ||
- python | ||
tools: | ||
- Biopython: | ||
description: | | ||
Python tools for computational molecular biology | ||
homepage: https://biopython.org/ | ||
tool_dev_url: https://github.com/biopython/biopython | ||
doi: 10.1093/bioinformatics/btp163 | ||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- fastq: | ||
type: file | ||
description: fastq file | ||
pattern: "*.{fastq.gz}" | ||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- count: | ||
type: file | ||
description: Plain text file containing the number of reads in the fastq files | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
authors: | ||
- "@kelly-sovacool" | ||
maintainers: | ||
- "@kelly-sovacool" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
import Bio.SeqIO | ||
import gzip | ||
import platform | ||
|
||
|
||
def main(): | ||
count = 0 | ||
for fastq_filename in "${fastq}".split(): | ||
with gzip.open(fastq_filename, "rt") as file_handle: | ||
n_seqs = sum(1 for rec in Bio.SeqIO.parse(file_handle, "fastq")) | ||
count += n_seqs | ||
with open("${meta.id}.count.txt", "w") as out_file: | ||
out_file.write(str(count)) | ||
return count | ||
|
||
|
||
def write_versions(): | ||
with open("versions.yml", "w") as outfile: | ||
outfile.write('"${task.process}":\\n') | ||
outfile.write(f' Python: "{platform.python_version()}"\\n') | ||
outfile.write(f' Biopython: "{Bio.__version__}"\\n') | ||
|
||
|
||
if __name__ == "__main__": | ||
write_versions() | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
process SAMTOOLS_FLAGSTAT { | ||
tag "$meta.id" | ||
label 'process_single' | ||
|
||
conda "bioconda::samtools=1.17" | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/samtools:1.17--h00cdaf9_0' : | ||
'biocontainers/samtools:1.17--h00cdaf9_0' }" | ||
|
||
input: | ||
tuple val(meta), path(bam), path(bai) | ||
|
||
output: | ||
tuple val(meta), path("*.flagstat"), emit: flagstat | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args = task.ext.args ?: '' | ||
def prefix = task.ext.prefix ?: "${bam.baseName}" | ||
""" | ||
samtools \\ | ||
flagstat \\ | ||
--threads ${task.cpus} \\ | ||
$bam \\ | ||
> ${prefix}.flagstat | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
touch ${prefix}.flagstat | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//') | ||
END_VERSIONS | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: samtools_flagstat | ||
description: Counts the number of alignments in a BAM/CRAM/SAM file for each FLAG type | ||
keywords: | ||
- stats | ||
- mapping | ||
- counts | ||
- bam | ||
- sam | ||
- cram | ||
tools: | ||
- samtools: | ||
description: | | ||
SAMtools is a set of utilities for interacting with and post-processing | ||
short DNA sequence read alignments in the SAM, BAM and CRAM formats, written by Heng Li. | ||
These files are generated as output by short read aligners like BWA. | ||
homepage: http://www.htslib.org/ | ||
documentation: http://www.htslib.org/doc/samtools.html | ||
doi: 10.1093/bioinformatics/btp352 | ||
licence: ["MIT"] | ||
input: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- bam: | ||
type: file | ||
description: BAM/CRAM/SAM file | ||
pattern: "*.{bam,cram,sam}" | ||
- bai: | ||
type: file | ||
description: Index for BAM/CRAM/SAM file | ||
pattern: "*.{bai,crai,sai}" | ||
output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing sample information | ||
e.g. [ id:'test', single_end:false ] | ||
- flagstat: | ||
type: file | ||
description: File containing samtools flagstat output | ||
pattern: "*.{flagstat}" | ||
- versions: | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
authors: | ||
- "@drpatelh" | ||
maintainers: | ||
- "@drpatelh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env nextflow | ||
|
||
nextflow.enable.dsl = 2 | ||
|
||
include { CUSTOM_COUNTFASTQ } from '../../../../../modules/CCBR/custom/countfastq/main.nf' | ||
|
||
workflow test_countfastq_single { | ||
input = [ [ id:'test', single_end:true ], // meta map | ||
[ file(params.test_data['test_1_fastq_gz'], checkIfExists: true) ] | ||
] | ||
CUSTOM_COUNTFASTQ( input ) | ||
} | ||
|
||
workflow test_countfastq_paired { | ||
input = [ [ id:'test', single_end:false ], // meta map | ||
[ file(params.test_data['test_1_fastq_gz'], checkIfExists: true), | ||
file(params.test_data['test_2_fastq_gz'], checkIfExists: true) ] | ||
] | ||
|
||
CUSTOM_COUNTFASTQ ( input ) | ||
} | ||
|
||
workflow test_countfastq_blank { | ||
input = [ [ id:'test', single_end:true ], // meta map | ||
[ file(params.test_data['test_blank_fastq_gz'], checkIfExists: true) ] | ||
] | ||
CUSTOM_COUNTFASTQ( input ) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
process { | ||
publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } | ||
} | ||
|
||
includeConfig '../../../../config/test_data_CCBR.config' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
- name: custom countfastq test_countfastq_single | ||
command: nextflow run ./tests/modules/CCBR/custom/countfastq -entry test_countfastq_single -c ./tests/config/nextflow.config | ||
tags: | ||
- custom | ||
- custom/countfastq | ||
files: | ||
- path: output/custom/test.count.txt | ||
md5sum: f899139df5e1059396431415e770c6dd | ||
contains: | ||
- "100" | ||
- path: output/custom/versions.yml | ||
|
||
- name: custom countfastq test_countfastq_paired | ||
command: nextflow run ./tests/modules/CCBR/custom/countfastq -entry test_countfastq_paired -c ./tests/config/nextflow.config | ||
tags: | ||
- custom | ||
- custom/countfastq | ||
files: | ||
- path: output/custom/test.count.txt | ||
md5sum: 3644a684f98ea8fe223c713b77189a77 | ||
contains: | ||
- "200" | ||
- path: output/custom/versions.yml | ||
|
||
- name: custom countfastq test_countfastq_blank | ||
command: nextflow run ./tests/modules/CCBR/custom/countfastq -entry test_countfastq_blank -c ./tests/config/nextflow.config | ||
tags: | ||
- custom | ||
- custom/countfastq | ||
files: | ||
- path: output/custom/test.count.txt | ||
md5sum: cfcd208495d565ef66e7dff9f98764da | ||
contains: | ||
- "0" | ||
- path: output/custom/versions.yml | ||
|
||
- name: custom countfastq test_countfastq_single stub | ||
command: nextflow run ./tests/modules/CCBR/custom/countfastq -entry test_countfastq_single -c ./tests/config/nextflow.config -stub | ||
tags: | ||
- custom | ||
- custom/countfastq | ||
files: | ||
- path: output/custom/test.count.txt | ||
- path: output/custom/versions.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters