Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pinin4fjords committed Jul 11, 2023
1 parent d5c67a7 commit a955751
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 35 deletions.
9 changes: 4 additions & 5 deletions modules/nf-core/simpleaf/index/main.nf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
process SIMPLEAF_INDEX {
tag "$transcript_gtf"
tag "$genome_fasta $transcript_fasta"
label 'process_high'

conda "bioconda::simpleaf=0.14.1"
Expand All @@ -9,12 +9,12 @@ process SIMPLEAF_INDEX {

input:
path genome_fasta
path genome_gtf
path transcript_fasta
path transcript_gtf

output:
path "salmon/index" , emit: index
path "salmon/ref/t2g_3col.tsv" , emit: transcript_tsv
path "salmon/ref/t2g_3col.tsv" , emit: transcript_tsv, optional: true
path "salmon" , emit: salmon
path "versions.yml" , emit: versions

Expand All @@ -23,7 +23,7 @@ process SIMPLEAF_INDEX {

script:
def args = task.ext.args ?: ''
def seq_inputs = (params.transcript_fasta) ? "--refseq $transcript_fasta" : "--gtf $transcript_gtf"
def seq_inputs = (transcript_fasta) ? "--refseq $transcript_fasta" : "--gtf $genome_gtf --fasta $genome_fasta"
"""
# export required var
export ALEVIN_FRY_HOME=.
Expand All @@ -35,7 +35,6 @@ process SIMPLEAF_INDEX {
simpleaf \\
index \\
--threads $task.cpus \\
--fasta $genome_fasta \\
$seq_inputs \\
$args \\
-o salmon
Expand Down
31 changes: 12 additions & 19 deletions modules/nf-core/simpleaf/quant/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ process SIMPLEAF_QUANT {
// Input reads are expected to come as: [ meta, [ pair1_read1, pair1_read2, pair2_read1, pair2_read2 ] ]
// Input array for a sample is created in the same order reads appear in samplesheet as pairs from replicates are appended to array.
//
tuple val(meta), path(reads)
tuple val(meta), val(chemistry), path(reads)
path index
val resolution
path txp2gene
val chemistry
path whitelist

output:
Expand All @@ -30,20 +30,15 @@ process SIMPLEAF_QUANT {
def args_list = args.tokenize()
def prefix = task.ext.prefix ?: "${meta.id}"

//
// check if users are using one of the mutually excludable parameters:
// e.g -k,--knee | -e,--expect-cells | -f, --forced-cells
//
if (args_list.any { it in ['-k', '--knee', '-e', '--expect-cells', '-f', '--forced-cells']} || meta.expected_cells) {
unfiltered_command = ""
save_whitelist = ""
} else {
unfiltered_command = "-u whitelist.uncompressed.txt"
save_whitelist = "mv whitelist.uncompressed.txt ${prefix}_alevin_results/"
unfiltered_command = ""
if (whitelist) {
unfiltered_command = "-u <(gzip -dcf ${whitelist})"
}

// expected cells
def expect_cells = meta.expected_cells ? "--expect-cells $meta.expected_cells" : ''
t2g_command = ""
if (txp2gene) {
t2g_command = "-m $txp2gene"
}

// separate forward from reverse pairs
def (forward, reverse) = reads.collate(2).transpose()
Expand All @@ -55,20 +50,18 @@ process SIMPLEAF_QUANT {
simpleaf set-paths
# run simpleaf quant
gzip -dcf $whitelist > whitelist.uncompressed.txt
simpleaf quant \\
-1 ${forward.join( "," )} \\
-2 ${reverse.join( "," )} \\
-i ${index} \\
-c $chemistry \\
-r $resolution \\
-o ${prefix}_alevin_results \\
-m $txp2gene \\
-t $task.cpus \\
-c $chemistry \\
$expect_cells \\
$t2g_command \\
$unfiltered_command \\
$args
$save_whitelist
[[ ! -f ${prefix}_alevin_results/af_quant/all_freq.bin ]] && cp ${prefix}_alevin_results/af_quant/permit_freq.bin ${prefix}_alevin_results/af_quant/all_freq.bin
cat <<-END_VERSIONS > versions.yml
Expand Down
16 changes: 13 additions & 3 deletions tests/modules/nf-core/simpleaf/index/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,25 @@ nextflow.enable.dsl = 2

include { SIMPLEAF_INDEX } from '../../../../../modules/nf-core/simpleaf/index/main.nf'

workflow test_simpleaf_index {
workflow test_simpleaf_index_expanded {

genome_fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
transcriptome_fasta = file(params.test_data['homo_sapiens']['genome']['transcriptome_fasta'], checkIfExists: true)
gtf = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true)

SIMPLEAF_INDEX (
genome_fasta,
gtf,
[]
)
}

workflow test_simpleaf_index_direct {

transcriptome_fasta = file(params.test_data['homo_sapiens']['genome']['transcriptome_fasta'], checkIfExists: true)

SIMPLEAF_INDEX (
[],
[],
transcriptome_fasta,
gtf
)
}
42 changes: 35 additions & 7 deletions tests/modules/nf-core/simpleaf/quant/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,57 @@ include { SIMPLEAF_QUANT } from '../../../../../modules/nf-core/simpleaf/quant/m

workflow test_simpleaf_quant {

genome_fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
gtf = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true)

SIMPLEAF_INDEX (
genome_fasta,
gtf,
[]
)

input = [
[ id:'test_10x', single_end:false, strandedness:'auto' ], // meta map
'10xv3', // Chemistry
[
file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_1_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_2_gz'], checkIfExists: true)
]
]

genome_fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)
SIMPLEAF_QUANT (
input,
SIMPLEAF_INDEX.out.index,
'cr-like',
SIMPLEAF_INDEX.out.transcript_tsv,
[]
)
}

workflow test_simpleaf_quant_nogtf {

transcriptome_fasta = file(params.test_data['homo_sapiens']['genome']['transcriptome_fasta'], checkIfExists: true)
gtf = file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true)

SIMPLEAF_INDEX (
genome_fasta,
SIMPLEAF_INDEX (
[],
[],
transcriptome_fasta,
gtf
)

input = [
[ id:'test_10x', single_end:false, strandedness:'auto' ], // meta map
'10xv3', // Chemistry
[
file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_1_gz'], checkIfExists: true),
file(params.test_data['homo_sapiens']['10xgenomics']['cellranger']['test_10x_5k_cmvpos_tcells_gex1_fastq_2_gz'], checkIfExists: true)
]
]

SIMPLEAF_QUANT (
input,
SIMPLEAF_INDEX.out.index,
SIMPLEAF_INDEX.out.transcript_tsv,
'10xv3',
'cr-like',
[],
[]
)
}
8 changes: 7 additions & 1 deletion tests/modules/nf-core/simpleaf/quant/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ process {

publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" }

}
withName: 'test_simpleaf_quant:SIMPLEAF_QUANT' {
ext.args = { "--knee" }
}
withName: 'test_simpleaf_quant_nogtf:SIMPLEAF_QUANT' {
ext.args = { "--knee" }
}
}

0 comments on commit a955751

Please sign in to comment.