Skip to content

Commit

Permalink
Made gtf input optional for star/genomegenerate (nf-core#4627)
Browse files Browse the repository at this point in the history
  • Loading branch information
GallVp authored and lrauschning committed Jan 17, 2024
1 parent 9f8cc1a commit 00e1ad1
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 36 deletions.
4 changes: 3 additions & 1 deletion modules/nf-core/star/genomegenerate/environment.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: star_genomegenerate

channels:
- conda-forge
- bioconda
- defaults

dependencies:
- bioconda::star=2.7.10a
- bioconda::samtools=1.18
- bioconda::star=2.7.10a
- conda-forge::gawk=5.1.0
83 changes: 53 additions & 30 deletions modules/nf-core/star/genomegenerate/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ process STAR_GENOMEGENERATE {
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def args_list = args.tokenize()
def memory = task.memory ? "--limitGenomeGenerateRAM ${task.memory.toBytes() - 100000000}" : ''
def args = task.ext.args ?: ''
def args_list = args.tokenize()
def memory = task.memory ? "--limitGenomeGenerateRAM ${task.memory.toBytes() - 100000000}" : ''
def include_gtf = gtf ? "--sjdbGTFfile $gtf" : ''
if (args_list.contains('--genomeSAindexNbases')) {
"""
mkdir star
STAR \\
--runMode genomeGenerate \\
--genomeDir star/ \\
--genomeFastaFiles $fasta \\
--sjdbGTFfile $gtf \\
$include_gtf \\
--runThreadN $task.cpus \\
$memory \\
$args
Expand All @@ -51,7 +52,7 @@ process STAR_GENOMEGENERATE {
--runMode genomeGenerate \\
--genomeDir star/ \\
--genomeFastaFiles $fasta \\
--sjdbGTFfile $gtf \\
$include_gtf \\
--runThreadN $task.cpus \\
--genomeSAindexNbases \$NUM_BASES \\
$memory \\
Expand All @@ -67,30 +68,52 @@ process STAR_GENOMEGENERATE {
}

stub:
"""
mkdir star
touch star/Genome
touch star/Log.out
touch star/SA
touch star/SAindex
touch star/chrLength.txt
touch star/chrName.txt
touch star/chrNameLength.txt
touch star/chrStart.txt
touch star/exonGeTrInfo.tab
touch star/exonInfo.tab
touch star/geneInfo.tab
touch star/genomeParameters.txt
touch star/sjdbInfo.txt
touch star/sjdbList.fromGTF.out.tab
touch star/sjdbList.out.tab
touch star/transcriptInfo.tab
if (gtf) {
"""
mkdir star
touch star/Genome
touch star/Log.out
touch star/SA
touch star/SAindex
touch star/chrLength.txt
touch star/chrName.txt
touch star/chrNameLength.txt
touch star/chrStart.txt
touch star/exonGeTrInfo.tab
touch star/exonInfo.tab
touch star/geneInfo.tab
touch star/genomeParameters.txt
touch star/sjdbInfo.txt
touch star/sjdbList.fromGTF.out.tab
touch star/sjdbList.out.tab
touch star/transcriptInfo.tab
cat <<-END_VERSIONS > versions.yml
"${task.process}":
star: \$(STAR --version | sed -e "s/STAR_//g")
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
END_VERSIONS
"""
cat <<-END_VERSIONS > versions.yml
"${task.process}":
star: \$(STAR --version | sed -e "s/STAR_//g")
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
END_VERSIONS
"""
} else {
"""
mkdir star
touch star/Genome
touch star/Log.out
touch star/SA
touch star/SAindex
touch star/chrLength.txt
touch star/chrName.txt
touch star/chrNameLength.txt
touch star/chrStart.txt
touch star/genomeParameters.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
star: \$(STAR --version | sed -e "s/STAR_//g")
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
END_VERSIONS
"""
}
}
81 changes: 80 additions & 1 deletion modules/nf-core/star/genomegenerate/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,86 @@ nextflow_process {
then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.index[0][1]).name).match("index") },
{ assert snapshot(file(process.out.index[0][1]).listFiles().collect { it.getName() }.sort().toString()).match("index_with_gtf") },
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("homo_sapiens-stub") {

options '-stub'

when {
process {
"""
input[0] = Channel.of([
[ id:'test_fasta' ],
[file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)]
])
input[1] = Channel.of([
[ id:'test_gtf' ],
[file(params.test_data['homo_sapiens']['genome']['genome_gtf'], checkIfExists: true)]
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.index[0][1]).listFiles().collect { it.getName() }.sort().toString()).match("index_with_gtf") },
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("homo_sapiens-without_gtf") {

when {
process {
"""
input[0] = Channel.of([
[ id:'test_fasta' ],
[file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)]
])
input[1] = Channel.of([ [], [] ])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.index[0][1]).listFiles().collect { it.getName() }.sort().toString()).match("index_without_gtf") },
{ assert snapshot(process.out.versions).match("versions") }
)
}

}

test("homo_sapiens-without_gtf-stub") {

options '-stub'

when {
process {
"""
input[0] = Channel.of([
[ id:'test_fasta' ],
[file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)]
])
input[1] = Channel.of([ [], [] ])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(file(process.out.index[0][1]).listFiles().collect { it.getName() }.sort().toString()).match("index_without_gtf") },
{ assert snapshot(process.out.versions).match("versions") }
)
}
Expand Down
14 changes: 10 additions & 4 deletions modules/nf-core/star/genomegenerate/tests/main.nf.test.snap

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

0 comments on commit 00e1ad1

Please sign in to comment.