samtools fasta module (#2128)

This commit is contained in:
Priyanka Surana 2022-09-29 08:10:44 +01:00 committed by GitHub
parent b3e322064e
commit 504028346b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 117 additions and 0 deletions

View file

@ -0,0 +1,37 @@
process SAMTOOLS_FASTA {
tag "$meta.id"
label 'process_low'
conda (params.enable_conda ? "bioconda::samtools=1.15.1" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/samtools:1.15.1--h1170115_0':
'quay.io/biocontainers/samtools:1.15.1--h1170115_0' }"
input:
tuple val(meta), path(input)
output:
tuple val(meta), path("*.fasta.gz"), emit: fasta
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 endedness = meta.single_end ? "-0 ${prefix}.fasta.gz" : "-1 ${prefix}_1.fasta.gz -2 ${prefix}_2.fasta.gz"
"""
samtools \\
fasta \\
$args \\
--threads ${task.cpus-1} \\
$endedness \\
$input
cat <<-END_VERSIONS > versions.yml
"${task.process}":
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ))
END_VERSIONS
"""
}

View file

@ -0,0 +1,46 @@
name: "samtools_fasta"
description: Converts a SAM/BAM/CRAM file to FASTA
keywords:
- bam
- sam
- cram
- fasta
tools:
- "samtools":
description: "Tools for dealing with SAM, BAM and CRAM files"
homepage: "http://www.htslib.org"
documentation: "https://www.htslib.org/doc/samtools-fasta.html"
tool_dev_url: "https://github.com/samtools/samtools"
doi: "10.1093/bioinformatics/btp352"
licence: "['MIT']"
input:
# Only when we have meta
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- input:
type: file
description: BAM/CRAM/SAM file
pattern: "*.{bam,cram,sam}"
output:
#Only when we have meta
- 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"
- fasta:
type: file
description: compressed FASTA file
pattern: "*.fasta.gz"
authors:
- "@priyanka-surana"

View file

@ -2103,6 +2103,10 @@ samtools/faidx:
- modules/samtools/faidx/** - modules/samtools/faidx/**
- tests/modules/samtools/faidx/** - tests/modules/samtools/faidx/**
samtools/fasta:
- modules/samtools/fasta/**
- tests/modules/samtools/fasta/**
samtools/fastq: samtools/fastq:
- modules/samtools/fastq/** - modules/samtools/fastq/**
- tests/modules/samtools/fastq/** - tests/modules/samtools/fastq/**

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { SAMTOOLS_FASTA } from '../../../../modules/samtools/fasta/main.nf'
workflow test_samtools_fasta {
input = [
[ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)
]
SAMTOOLS_FASTA ( input )
}

View file

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

View file

@ -0,0 +1,10 @@
- name: samtools fasta test_samtools_fasta
command: nextflow run ./tests/modules/samtools/fasta -entry test_samtools_fasta -c ./tests/config/nextflow.config -c ./tests/modules/samtools/fasta/nextflow.config
tags:
- samtools
- samtools/fasta
files:
- path: output/samtools/test_1.fasta.gz
md5sum: 3abd682290bc7c75f1ce2b80db995237
- path: output/samtools/test_2.fasta.gz
md5sum: 6ada09ce66f68b8732985e14aac1bf1f