Skip to content

Feature/count reads #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
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
19 changes: 16 additions & 3 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,23 @@ process {
]
}

withName: COUNT_READS {
publishDir = [
[
path: { "${params.outdir}/count_reads/${meta.id}" },
mode: params.publish_dir_mode,
]
]
}




withName: COUNT_READS_AFTER_TRIMMING {
publishDir = [
[
path: { "${params.outdir}/count_reads_after_trimming/${meta.id}" },
mode: params.publish_dir_mode,
]
]
}

withName: FASTQC {
ext.args = '--quiet'
Expand Down
39 changes: 39 additions & 0 deletions modules/local/count_reads.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
process COUNT_READS {
tag "$meta.id"
label 'process_medium'

container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'nfcore/dualrnaseq:dev' :
'nfcore/dualrnaseq:dev' }"

input:
tuple val(meta), path(reads)

output:
tuple val(meta), path('*.txt'), emit: read_counts

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"

if (reads instanceof Path || reads.size() == 1) {
// Code to process a single file
"""
count_1=\$((\$(zcat ${reads[0]} | wc -l) / 4))
echo "${reads[0].baseName}\t\$count_1" > ${reads[0].baseName}_counts.txt
"""
} else if (reads instanceof Path || reads.size() == 2) {
// Code to process two files
"""
count_1=\$((\$(zcat ${reads[0]} | wc -l) / 4))
count_2=\$((\$(zcat ${reads[1]} | wc -l) / 4))
echo "${reads[0].baseName}\t\$count_1" > ${reads[0].baseName}_counts.txt
echo "${reads[1].baseName}\t\$count_2" > ${reads[1].baseName}_counts.txt
"""
} else {
"""
echo "Error: Input 'reads' should contain either one or two files."
exit 1
"""
}
}
6 changes: 3 additions & 3 deletions modules/nf-core/fastqc/main.nf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions workflows/dualrnaseq.nf
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ include { SALMON_ALIGNMENT_BASED } from '../subworkflows/local/salmon_alignment_
//
// MODULE: Installed directly from nf-core/modules
//
include { FASTQC } from '../modules/nf-core/fastqc/main'
include { FASTQC as FASTQC_AFTER_TRIMMING } from '../modules/nf-core/fastqc/main'
include { CUTADAPT } from '../modules/nf-core/cutadapt/main'
include { MULTIQC } from '../modules/nf-core/multiqc/main'
include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/custom/dumpsoftwareversions/main'
include { COUNT_READS } from '../modules/local/count_reads'
include { COUNT_READS as COUNT_READS_AFTER_TRIMMING } from '../modules/local/count_reads'
include { FASTQC } from '../modules/nf-core/fastqc/main'
include { FASTQC as FASTQC_AFTER_TRIMMING } from '../modules/nf-core/fastqc/main'
include { CUTADAPT } from '../modules/nf-core/cutadapt/main'
include { MULTIQC } from '../modules/nf-core/multiqc/main'
include { CUSTOM_DUMPSOFTWAREVERSIONS } from '../modules/nf-core/custom/dumpsoftwareversions/main'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -99,12 +101,17 @@ workflow DUALRNASEQ {
)
ch_versions = ch_versions.mix(INPUT_CHECK.out.versions)

COUNT_READS (
INPUT_CHECK.out.reads
)

ch_count_reads_merged = Channel.fromPath( "${params.outdir}/count_reads/*" ).collectFile(name: 'count_reads_merged.txt').view()

if (!(params.skip_tools && params.skip_tools.split(',').contains('fastqc'))) {
FASTQC(INPUT_CHECK.out.reads)
ch_versions = ch_versions.mix(FASTQC.out.versions.first())
}

ch_reads = INPUT_CHECK.out.reads
if (!(params.skip_tools && params.skip_tools.split(',').contains('cutadapt'))) {
CUTADAPT(INPUT_CHECK.out.reads)
ch_reads = CUTADAPT.out.reads
Expand All @@ -114,6 +121,8 @@ workflow DUALRNASEQ {
if (!(params.skip_tools && (params.skip_tools.split(',').contains('fastqc') || params.skip_tools.split(',').contains('cutadapt')))) {
FASTQC_AFTER_TRIMMING(ch_reads)
ch_versions = ch_versions.mix(FASTQC_AFTER_TRIMMING.out.versions.first())
COUNT_READS_AFTER_TRIMMING (INPUT_CHECK.out.reads)
ch_count_reads_merged = Channel.fromPath( "${params.outdir}/count_reads/*" ).collectFile(name: 'count_reads_after_trimming_merged.txt').view()
}


Expand Down