Skip to content

Commit

Permalink
New module: instrain/compare (#3623)
Browse files Browse the repository at this point in the history
* Started instrain compare tests

* instrain compare

* Update modules/nf-core/instrain/compare/main.nf

* Update modules/nf-core/instrain/compare/main.nf

* Update modules/nf-core/instrain/compare/main.nf

* Updated test.yml and added stub

* Update modules/nf-core/instrain/compare/main.nf

Co-authored-by: Nicolas Vannieuwkerke <[email protected]>

* Update meta.yml to include meta2

* Updated test.yml output files

* Changed md5 to content for several test.yml files

* changed content to contains

* Added another contains option in test.yml

* shortened contains string to pass prettier check

---------

Co-authored-by: Margot Lavitt <[email protected]>
Co-authored-by: Nicolas Vannieuwkerke <[email protected]>
  • Loading branch information
3 people authored Jul 19, 2023
1 parent 8c029dd commit 7f39bf3
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 0 deletions.
57 changes: 57 additions & 0 deletions modules/nf-core/instrain/compare/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
process INSTRAIN_COMPARE {
tag "$meta.id"
label 'process_high'

conda "bioconda::instrain=1.6.1"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/instrain:1.6.1--pyhdfd78af_0':
'biocontainers/instrain:1.6.1--pyhdfd78af_0' }"

input:
tuple val(meta), path(profiles)
tuple val(meta2), path(bams)
path stb_file

output:
tuple val(meta), path("*.IS_compare") , emit: compare
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 stb_args = stb_file ? "-s ${stb_file}": ''
"""
inStrain \\
compare \\
-i $profiles \\
-o ${prefix}.IS_compare \\
--processes $task.cpus \\
--bams $bams \\
$args
cat <<-END_VERSIONS > versions.yml
"${task.process}":
instrain: \$(echo \$(inStrain compare --version 2>&1) | awk 'NF{ print \$NF }')
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def stb_args = stb_file ? "-s ${stb_file}": ''
"""
mkdir -p ${prefix}.IS_compare/output
touch ${prefix}.IS_compare/output/${prefix}.IS_compare_pooled_SNV_info.tsv
touch ${prefix}.IS_compare/output/${prefix}.IS_compare_comparisonsTable.tsv
touch ${prefix}.IS_compare/output/${prefix}.IS_compare_pooled_SNV_data.tsv
touch ${prefix}.IS_compare/output/${prefix}.IS_compare_pooled_SNV_data_keys.tsv
cat <<-END_VERSIONS > versions.yml
"${task.process}":
instrain: \$(echo \$(inStrain compare --version 2>&1) | awk 'NF{ print \$NF }')
END_VERSIONS
"""
}
59 changes: 59 additions & 0 deletions modules/nf-core/instrain/compare/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: "instrain_compare"
description: Strain-level comparisons across multiple inStrain profiles
keywords:
- instrain
- compare
- align
- diversity
- coverage
tools:
- "instrain":
description: "Calculation of strain-level metrics"
homepage: https://github.com/MrOlm/instrain
documentation: https://instrain.readthedocs.io/en/latest/
tool_dev_url: https://github.com/MrOlm/instrain
doi: 10.1038/s41587-020-00797-0
licence: "['MIT']"

input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- meta2:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- profiles:
type: directory
description: InStrain profile folders
pattern: "*.IS/"
- bams:
type: file
description: Path to .bam files that were profiled
pattern: "*.{bam,sam}"
- stb_file:
type: file
description: Path to .stb (scaffold to bin) file that was profiled
pattern: "*.stb"

output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'test', single_end:false ]`
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- compare:
type: directory
description: inStrain compare folders
pattern: "*.IS_compare/"

authors:
- "@margotl9"
- "@CarsonJM"
4 changes: 4 additions & 0 deletions tests/config/pytest_modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1929,6 +1929,10 @@ ilastik/pixelclassification:
- modules/nf-core/ilastik/pixelclassification/**
- tests/modules/nf-core/ilastik/pixelclassification/**

instrain/compare:
- modules/nf-core/instrain/compare/**
- tests/modules/nf-core/instrain/compare/**

instrain/profile:
- modules/nf-core/instrain/profile/**
- tests/modules/nf-core/instrain/profile/**
Expand Down
22 changes: 22 additions & 0 deletions tests/modules/nf-core/instrain/compare/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { INSTRAIN_COMPARE } from '../../../../../modules/nf-core/instrain/compare/main.nf'
include { INSTRAIN_PROFILE } from '../../../../../modules/nf-core/instrain/profile/main.nf'

workflow test_instrain_compare {

input = Channel.of(
[[ id:'test1', single_end:true ], file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true)],
[[ id:'test2', single_end:true ], file(params.test_data['homo_sapiens']['illumina']['test2_paired_end_sorted_bam'], checkIfExists: true)]
)
genome_fasta = file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true)

INSTRAIN_PROFILE ( input , genome_fasta , [] , [] )
instrain_profiles = INSTRAIN_PROFILE.out.profile.map{ [[id:"test"], it[1]] }.groupTuple()
input_bams = input.map{ [[id:"test"], it[1]] }.groupTuple()

INSTRAIN_COMPARE ( instrain_profiles , input_bams , [] )

}
5 changes: 5 additions & 0 deletions tests/modules/nf-core/instrain/compare/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
process {

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

}
27 changes: 27 additions & 0 deletions tests/modules/nf-core/instrain/compare/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
- name: instrain compare test_instrain_compare
command: nextflow run ./tests/modules/nf-core/instrain/compare -entry test_instrain_compare -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/instrain/compare/nextflow.config
tags:
- instrain
- instrain/compare
files:
- path: output/instrain/test.IS_compare/output/test.IS_compare_comparisonsTable.tsv
contains: ["test2.paired_end.sorted.bam 0.9516129032258064 944 0.0235994100147496 40001 0 0 1.0 1.0"]
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_data.tsv
contains: ["0 1981 119 0 0 24"]
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_data_keys.tsv
contains: ["paired_end.sorted.bam chr22"]
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_info.tsv
md5sum: 7ed4894afbc4f1abd8692c4a65003a27
- path: output/instrain/versions.yml

- name: instrain compare test_instrain_compare_stub
command: nextflow run ./tests/modules/nf-core/instrain/compare -entry test_instrain_compare -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/instrain/compare/nextflow.config -stub-run
tags:
- instrain
- instrain/compare
files:
- path: output/instrain/test.IS_compare/output/test.IS_compare_comparisonsTable.tsv
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_data.tsv
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_data_keys.tsv
- path: output/instrain/test.IS_compare/output/test.IS_compare_pooled_SNV_info.tsv
- path: output/instrain/versions.yml

0 comments on commit 7f39bf3

Please sign in to comment.