Skip to content

Commit

Permalink
Added a draft for LAI (nf-core#4771)
Browse files Browse the repository at this point in the history
* Added a draft for LAI

* Added tests with larger local data

* Added ltrharvest to lai test

* Updated tests for lai

* Removed unnecessary args
  • Loading branch information
GallVp authored Feb 25, 2024
1 parent 53a9794 commit 26c8a95
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 0 deletions.
9 changes: 9 additions & 0 deletions modules/nf-core/ltrretriever/lai/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json
name: "ltrretriever_lai"
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- "bioconda::LTR_retriever=2.9.9"
71 changes: 71 additions & 0 deletions modules/nf-core/ltrretriever/lai/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
process LTRRETRIEVER_LAI {
tag "$meta.id"
label 'process_medium'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ltr_retriever:2.9.9--hdfd78af_0':
'biocontainers/ltr_retriever:2.9.9--hdfd78af_0' }"

input:
tuple val(meta), path(fasta)
path pass_list
path annotation_out
path monoploid_seqs

output:
tuple val(meta), path("*.LAI.log") , emit: log
tuple val(meta), path("*.LAI.out") , emit: lai_out , optional: true
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 monoploid_param = monoploid_seqs ? "-mono $monoploid_seqs" : ''
def lai_output_name = monoploid_seqs ? "${annotation_out}.${monoploid_seqs}.out.LAI" : "${annotation_out}.LAI"
def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
"""
LAI \\
-genome $fasta \\
-intact $pass_list \\
-all $annotation_out \\
-t $task.cpus \\
$monoploid_param \\
$args \\
> >(tee "${prefix}.LAI.log") \\
|| echo "LAI failed! See ${prefix}.LAI.log"
mv \\
$lai_output_name \\
"${prefix}.LAI.out" \\
|| echo "LAI failed to estimate assembly index. See ${prefix}.LAI.log"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
lai: $VERSION
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def monoploid_param = monoploid_seqs ? "-mono $monoploid_seqs" : ''
def lai_output_name = monoploid_seqs ? "${annotation_out}.${monoploid_seqs}.out.LAI" : "${annotation_out}.LAI"
def VERSION = 'beta3.2' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions.
"""
touch "${prefix}.LAI.log"
touch "$lai_output_name"
mv \\
$lai_output_name \\
"${prefix}.LAI.out"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
lai: $VERSION
END_VERSIONS
"""
}
70 changes: 70 additions & 0 deletions modules/nf-core/ltrretriever/lai/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json
name: "ltrretriever_lai"
description: |
Estimates the mean LTR sequence identity in the genome. The input genome fasta should
have short alphanumeric IDs without comments
keywords:
- genomics
- annotation
- repeat
- long terminal retrotransposon
- retrotransposon
- stats
- qc
tools:
- "lai":
description: Assessing genome assembly quality using the LTR Assembly Index (LAI)
homepage: "https://github.com/oushujun/LTR_retriever"
documentation: "https://github.com/oushujun/LTR_retriever"
tool_dev_url: "https://github.com/oushujun/LTR_retriever"
doi: "10.1093/nar/gky730"
licence: ["GPL v3"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1' ]`
- fasta:
type: file
description: The genome file that is used to generate everything
pattern: "*.{fsa,fa,fasta}"
- pass_list:
type: file
description: A list of intact LTR-RTs generated by LTR_retriever
pattern: "*.pass.list"
- annotation_out:
type: file
description: RepeatMasker annotation of all LTR sequences in the genome
pattern: "*.out"
- monoploid_seqs:
type: file
description: |
This parameter is mainly for ployploid genomes. User provides a list of
sequence names that represent a monoploid (1x). LAI will be calculated only
on these sequences if provided.
pattern: "*.txt"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- log:
type: file
description: Log from LAI
pattern: "*.LAI.log"
- lai_out:
type: file
description: |
Output file from LAI if LAI is able to estimate the index from the inputs
pattern: "*.LAI.out"
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
authors:
- "@GallVp"
maintainers:
- "@GallVp"
166 changes: 166 additions & 0 deletions modules/nf-core/ltrretriever/lai/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
nextflow_process {

name "Test Process LTRRETRIEVER_LAI"
script "../main.nf"
process "LTRRETRIEVER_LAI"
config "./nextflow.config"

tag "modules"
tag "modules_nfcore"
tag "gunzip"
tag "ltrretriever"
tag "ltrretriever/ltrretriever"
tag "ltrretriever/lai"
tag "ltrharvest"
tag "ltrfinder"
tag "cat/cat"

test("actinidia_chinensis-genome_21_fasta_gz-success") {

setup {

run("GUNZIP") {
script "../../../gunzip"

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

run("LTRHARVEST") {
script "../../../ltrharvest"

process {
"""
input[0] = GUNZIP.out.gunzip
"""
}
}

run("LTRFINDER") {
script "../../../ltrfinder"

process {
"""
input[0] = GUNZIP.out.gunzip
"""
}
}

run("CAT_CAT") {
script "../../../cat/cat"

process {
"""
input[0] = LTRHARVEST.out.scn.mix(LTRFINDER.out.scn).groupTuple()
"""
}
}

run("LTRRETRIEVER_LTRRETRIEVER") {
script "../../ltrretriever"

process {
"""
input[0] = GUNZIP.out.gunzip
input[1] = CAT_CAT.out.file_out.map { meta, tabout -> tabout }
input[2] = []
input[3] = []
input[4] = []
"""
}
}
}

when {
process {
"""
input[0] = GUNZIP.out.gunzip
input[1] = LTRRETRIEVER_LTRRETRIEVER.out.pass_list.map { meta, pass_list -> pass_list }
input[2] = LTRRETRIEVER_LTRRETRIEVER.out.annotation_out.map { meta, annotation_out -> annotation_out }
input[3] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert path(process.out.log[0][1]).text.contains("Dependency checking: Passed!") },
{ assert path(process.out.log[0][1]).text.contains("Calculate LAI:") },
{ assert path(process.out.log[0][1]).text.contains("Done!") },
{ assert path(process.out.log[0][1]).text.contains("Result file:") },
{ assert Math.abs(Float.parseFloat(path(process.out.lai_out[0][1]).text.split("\n")[1].split("\t")[6]) - 31.29) <= 1.0 }
)
}

}

test("stub") {

options '-stub'

when {
process {
"""
def pass_list = new File('test.pass.list')
def out_file = new File('test.out')
def monoploid_seqs = new File('some_seqs.list.txt')
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true)
]
input[1] = pass_list.toPath()
input[2] = out_file.toPath()
input[3] = []
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

test("stub_with_monoploid_seqs") {

options '-stub'

when {
process {
"""
def pass_list = new File('test.pass.list')
def out_file = new File('test.out')
def monoploid_seqs = new File('some_seqs.list.txt')
input[0] = [
[ id:'test' ],
file(params.test_data['actinidia_chinensis']['genome']['genome_21_fasta_gz'], checkIfExists: true)
]
input[1] = pass_list.toPath()
input[2] = out_file.toPath()
input[3] = monoploid_seqs.toPath()
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}

}

}
Loading

0 comments on commit 26c8a95

Please sign in to comment.