Skip to content

Commit

Permalink
remove compress input
Browse files Browse the repository at this point in the history
  • Loading branch information
mirpedrol committed Jul 5, 2024
1 parent 2844bf1 commit 9a2ca2e
Show file tree
Hide file tree
Showing 29 changed files with 85 additions and 400 deletions.
10 changes: 4 additions & 6 deletions modules/class-modules/clustalo/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,17 @@ process CLUSTALO_ALIGN {
input:
tuple val(meta) , path(fasta)
tuple val(meta2), path(tree)
val(compress)

output:
tuple val(meta), path("*.aln{.gz,}"), emit: alignment
path "versions.yml" , emit: versions
tuple val(meta), path("*.aln.gz"), emit: alignment
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def write_output = compress ? "--force -o >(pigz -cp ${task.cpus} > ${prefix}.aln.gz)" : "> ${prefix}.aln"
// using >() is necessary to preserve the return value,
// so nextflow knows to display an error when it failed
// the --force -o is necessary, as clustalo expands the commandline input,
Expand All @@ -33,7 +31,7 @@ process CLUSTALO_ALIGN {
-i ${fasta} \
--threads=${task.cpus} \
$args \
$write_output
--force -o >(pigz -cp ${task.cpus} > ${prefix}.aln.gz)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -46,7 +44,7 @@ process CLUSTALO_ALIGN {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.aln${compress ? '.gz' : ''}
touch ${prefix}.aln.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
9 changes: 2 additions & 7 deletions modules/class-modules/clustalo/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,17 @@ input:
type: file
description: Input guide tree in Newick format
pattern: "*.{dnd}"
- - compress:
type: boolean
description: Flag representing whether the output MSA should be compressed.
Set to true to enable/false to disable compression. Compression is done using
pigz, and is multithreaded.
output:
- alignment:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test']`
- "*.aln{.gz,}":
- "*.aln.gz":
type: file
description: Alignment file, in gzipped fasta format
pattern: "*.aln{.gz,}"
pattern: "*.aln.gz"
ontologies:
- edam: http://edamontology.org/format_1984
- versions:
Expand Down
29 changes: 2 additions & 27 deletions modules/class-modules/clustalo/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,8 @@ nextflow_process {
tag "clustalo/align"
tag "clustalo/guidetree"

test("sarscov2 - contigs-fasta - uncompressed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = [[:],[]]
input[2] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.alignment).match("alignment - uncompressed")},
{ assert snapshot(process.out.versions).match("versions0") }
)
}

}

test("sarscov2 - contigs-fasta - compressed") {
test("sarscov2 - contigs-fasta") {

when {
process {
Expand All @@ -44,15 +21,14 @@ nextflow_process {
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = [[:],[]]
input[2] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.alignment).match("alignment - compressed")},
{ assert snapshot(process.out.alignment).match("alignment ")},
{ assert snapshot(process.out.versions).match("versions1") }
)
}
Expand Down Expand Up @@ -82,7 +58,6 @@ nextflow_process {
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = CLUSTALO_GUIDETREE.out.tree.collect{ meta, tree -> tree }.map{ tree -> [[ id: 'test_summary'], tree]}
input[2] = true
"""
}
}
Expand Down
12 changes: 5 additions & 7 deletions modules/class-modules/famsa/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,25 @@ process FAMSA_ALIGN {
input:
tuple val(meta) , path(fasta)
tuple val(meta2), path(tree)
val(compress)

output:
tuple val(meta), path("*.aln{.gz,}"), emit: alignment
path "versions.yml" , emit: versions
tuple val(meta), path("*.aln.gz"), emit: alignment
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def compress_args = compress ? '-gz' : ''
def prefix = task.ext.prefix ?: "${meta.id}"
def options_tree = tree ? "-gt import $tree" : ""
"""
famsa $options_tree \\
$compress_args \\
-gz # compress output \\
$args \\
-t ${task.cpus} \\
${fasta} \\
${prefix}.aln${compress ? '.gz':''}
${prefix}.aln$.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -43,7 +41,7 @@ process FAMSA_ALIGN {
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.aln${compress ? '.gz' : ''}
touch ${prefix}.aln.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
12 changes: 3 additions & 9 deletions modules/class-modules/famsa/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@ input:
type: file
description: Input guide tree in Newick format
pattern: "*.{dnd}"
- - compress:
type: boolean
description: Flag representing whether the output MSA should be compressed.
Set to true to enable/false to disable compression. Compression is handled
by passing '-gz' to FAMSA along with any other options specified in task.ext.args.
output:
- alignment:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test']`
- "*.aln{.gz,}":
- "*.aln.gz":
type: file
description: Alignment file, in FASTA format. May be gzipped or uncompressed,
depending on if compress is set to true or false
pattern: "*.aln{.gz,}"
description: Alignment file, in FASTA format.
pattern: "*.aln.gz"
ontologies:
- edam: http://edamontology.org/format_1984
- versions:
Expand Down
29 changes: 2 additions & 27 deletions modules/class-modules/famsa/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,8 @@ nextflow_process {
tag "famsa/align"
tag "famsa/guidetree"

test("sarscov2 - fasta - uncompressed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = [[:],[]]
input[2] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.alignment).match("alignment_uncompressed")},
{ assert snapshot(process.out.versions).match("versions0") }
)
}

}

test("sarscov2 - fasta - compressed") {
test("sarscov2 - fasta") {

when {
process {
Expand All @@ -43,15 +20,14 @@ nextflow_process {
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = [[:],[]]
input[2] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out.alignment).match("alignment_compressed")},
{ assert snapshot(process.out.alignment).match("alignment")},
{ assert snapshot(process.out.versions).match("versions1") }
)
}
Expand Down Expand Up @@ -80,7 +56,6 @@ nextflow_process {
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = FAMSA_GUIDETREE.out.tree.collect{ meta, tree -> tree }.map{ tree -> [[ id: 'test_summary'], tree]}
input[2] = true
"""
}
}
Expand Down
10 changes: 4 additions & 6 deletions modules/class-modules/kalign/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ process KALIGN_ALIGN {

input:
tuple val(meta), path(fasta)
val(compress)

output:
tuple val(meta), path("*.aln{.gz,}"), emit: alignment
path "versions.yml" , emit: versions
tuple val(meta), path("*.aln.gz"), emit: alignment
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def write_output = compress ? ">(pigz -cp ${task.cpus} > ${prefix}.aln.gz)" : "${prefix}.aln"
"""
unpigz -cdf $fasta | \\
kalign \\
$args \\
-o ${write_output}
-o >(pigz -cp ${task.cpus} > ${prefix}.aln.gz)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -39,7 +37,7 @@ process KALIGN_ALIGN {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.aln${compress ? '.gz' : ''}
touch ${prefix}.aln.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
12 changes: 3 additions & 9 deletions modules/class-modules/kalign/align/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,17 @@ input:
pattern: "*.{fa,fasta}{.gz,}"
ontologies:
- edam: http://edamontology.org/format_1929
- - compress:
type: boolean
description: Flag representing whether the output MSA should be compressed.
Set to true to enable/false to disable compression. Compression is done using
pigz, and is multithreaded.
output:
- alignment:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test']`
- "*.aln{.gz,}":
- "*.aln.gz":
type: file
description: Alignment file. May be gzipped or uncompressed, depending on if
`compress` is set to `true` or `false`.
pattern: "*.{aln}{.gz,}"
description: Alignment file.
pattern: "*.aln.gz"
ontologies:
- edam: http://edamontology.org/format_1984
- versions:
Expand Down
25 changes: 2 additions & 23 deletions modules/class-modules/kalign/align/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,23 @@ nextflow_process {
tag "kalign"
tag "kalign/align"

test("sarscov2 - fasta - uncompressed") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = false
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match("SARS-CoV-2 scaffolds fasta - uncompressed")},
)
}
}

test("sarscov2 - fasta - compressed") {
test("sarscov2 - fasta") {

when {
process {
"""
input[0] = [ [ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['contigs_fasta'], checkIfExists: true)
]
input[1] = true
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match("SARS-CoV-2 scaffolds fasta - compressed")},
{ assert snapshot(process.out).match("SARS-CoV-2 scaffolds fasta")},
)
}
}
Expand Down
10 changes: 4 additions & 6 deletions modules/class-modules/learnmsa/align/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ process LEARNMSA_ALIGN {

input:
tuple val(meta), path(fasta)
val(compress)

output:
tuple val(meta), path("*.aln{.gz,}"), emit: alignment
path "versions.yml" , emit: versions
tuple val(meta), path("*.aln.gz"), emit: alignment
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def write_output = compress ? ">(pigz -cp ${task.cpus} > ${prefix}.aln.gz)" : "${prefix}.aln"
"""
learnMSA \\
$args \\
-i <(unpigz -cdf $fasta) \\
-o $write_output
-o >(pigz -cp ${task.cpus} > ${prefix}.aln.gz)
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand All @@ -39,7 +37,7 @@ process LEARNMSA_ALIGN {
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.aln${compress ? '.gz' : ''}
touch ${prefix}.aln.gz
cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
Loading

0 comments on commit 9a2ca2e

Please sign in to comment.