Skip to content

Commit

Permalink
Updated fasta_ltrretriever_lai to fix [ meta, [] ] bug
Browse files Browse the repository at this point in the history
  • Loading branch information
GallVp committed May 2, 2024
1 parent 5660e89 commit 0cc8a8a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 43 deletions.
2 changes: 1 addition & 1 deletion modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"pfr": {
"fasta_ltrretriever_lai": {
"branch": "main",
"git_sha": "10b046eaac396f279c08e7e2bb067482ccd9c74e",
"git_sha": "8088445a270d324cb06e085f18790839c9684754",
"installed_by": ["subworkflows"]
},
"fastq_bwa_mem_samblaster": {
Expand Down
1 change: 1 addition & 0 deletions subworkflows/pfr/fasta_ltrretriever_lai/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ workflow FASTA_LTRRETRIEVER_LAI {
| join(
ch_monoploid_seqs ?: Channel.empty()
)
| filter { meta, tsv, seqs -> seqs } // Cater to channel: [ meta, tsv, [] ]
| map { meta, short_ids_tsv, monoploid_seqs ->
map_monoploid_seqs_to_new_ids(meta, short_ids_tsv, monoploid_seqs)
}
Expand Down
118 changes: 76 additions & 42 deletions subworkflows/pfr/fasta_ltrretriever_lai/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ nextflow_workflow {
tag "ltrretriever/lai"
tag "custom/restoregffids"

test("actinidia_chinensis-genome_21_fasta_gz") {

setup {
run("GUNZIP") {
script "../../../../modules/nf-core/gunzip"

process {
"""
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true)
]
"""
}
setup {
run("GUNZIP") {
script "../../../../modules/nf-core/gunzip"

process {
"""
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_1_fasta_gz'], checkIfExists: true)
]
"""
}
}
}

test("actinidia_chinensis-genome_1_fasta_gz") {

when {
workflow {
Expand All @@ -57,23 +57,43 @@ nextflow_workflow {
}
}

test("actinidia_chinensis-genome_21_fasta_gz-with_mono") {
test("actinidia_chinensis-genome_1_fasta_gz-with_mono") {

setup {
run("GUNZIP") {
script "../../../../modules/nf-core/gunzip"
when {
workflow {
"""
GUNZIP.out.gunzip.map { meta, fasta ->
def fa = new File('test.fa')
fa.write(fasta.text.replaceAll('>chr1', '>chr_xxxxxxxxxxxxxxx_1'))
process {
"""
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true)
]
"""
[ meta, fa.toPath() ]
}
| set { ch_fa }
def monoploid_seqs = new File('test.mono.seq.txt')
monoploid_seqs.write("chr_xxxxxxxxxxxxxxx_1")
input[0] = ch_fa
input[1] = Channel.of( [ [ id:'test' ], monoploid_seqs.toPath() ] )
input[2] = false
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert file(workflow.out.annotation_gff[0][1]).text.contains('Copia_LTR_retrotransposon') },
{ assert file(workflow.out.lai_log[0][1]).text.contains('Calculate LAI:') },
{ assert file(workflow.out.lai_log[0][1]).text.contains('Done!') },
{ assert Math.abs(Float.parseFloat(path(workflow.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 },
{ assert file(workflow.out.ltrlib[0][1]).text.contains('#LTR/Copia') }
)
}
}

test("actinidia_chinensis-genome_1_fasta_gz-with_empty_mono_channel") {

when {
workflow {
"""
Expand All @@ -85,11 +105,8 @@ nextflow_workflow {
}
| set { ch_fa }
def monoploid_seqs = new File('test.mono.seq.txt')
monoploid_seqs.write("chr_xxxxxxxxxxxxxxx_1")
input[0] = ch_fa
input[1] = Channel.of( [ [ id:'test' ], monoploid_seqs.toPath() ] )
input[1] = ch_fa.map { meta, fasta -> [ meta, [] ] }
input[2] = false
"""
}
Expand All @@ -107,25 +124,42 @@ nextflow_workflow {
}
}

test("actinidia_chinensis-genome_21_fasta_gz-without_lai") {
test("actinidia_chinensis-genome_1_fasta_gz-with_empty_mono") {

options '-stub'
when {
workflow {
"""
GUNZIP.out.gunzip.map { meta, fasta ->
def fa = new File('test.fa')
fa.write(fasta.text.replaceAll('>chr1', '>chr_xxxxxxxxxxxxxxx_1'))
setup {
run("GUNZIP") {
script "../../../../modules/nf-core/gunzip"

process {
"""
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true)
]
"""
[ meta, fa.toPath() ]
}
| set { ch_fa }
input[0] = ch_fa
input[1] = []
input[2] = false
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert file(workflow.out.annotation_gff[0][1]).text.contains('Copia_LTR_retrotransposon') },
{ assert file(workflow.out.lai_log[0][1]).text.contains('Calculate LAI:') },
{ assert file(workflow.out.lai_log[0][1]).text.contains('Done!') },
{ assert Math.abs(Float.parseFloat(path(workflow.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 },
{ assert file(workflow.out.ltrlib[0][1]).text.contains('#LTR/Copia') }
)
}
}

test("actinidia_chinensis-genome_1_fasta_gz-without_lai") {

options '-stub'

when {
workflow {
"""
Expand Down

0 comments on commit 0cc8a8a

Please sign in to comment.