add samtools/bamtocram modules (#1561)

* add new samtools/bamtocram module

* fix md5sum

* remove md5sum

* Update modules/samtools/bamtocram/main.nf

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>

Co-authored-by: James A. Fellows Yates <jfy133@gmail.com>
This commit is contained in:
Maxime U. Garcia 2022-04-25 14:32:49 +02:00 committed by GitHub
parent 378fa5fbb4
commit 569e07f0af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 122 additions and 0 deletions

View file

@ -0,0 +1,35 @@
//There is a -L option to only output alignments in interval, might be an option for exons/panel data?
process SAMTOOLS_BAMTOCRAM {
tag "$meta.id"
label 'process_medium'
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), path(index)
path fasta
path fai
output:
tuple val(meta), path("*.cram"), path("*.crai"), emit: cram_crai
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}"
"""
samtools view --threads ${task.cpus} --reference ${fasta} -C $args $input > ${prefix}.cram
samtools index -@${task.cpus} ${prefix}.cram
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,52 @@
name: samtools_bamtocram
description: filter/convert and then index CRAM file
keywords:
- view
- index
- bam
- cram
tools:
- samtools:
description: |
SAMtools is a set of utilities for interacting with and post-processing
short DNA sequence read alignments in the SAM, BAM and CRAM formats, written by Heng Li.
These files are generated as output by short read aligners like BWA.
homepage: http://www.htslib.org/
documentation: hhttp://www.htslib.org/doc/samtools.html
doi: 10.1093/bioinformatics/btp352
licence: ["MIT"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- input:
type: file
description: BAM/SAM file
pattern: "*.{bam,sam}"
- index:
type: file
description: BAM/SAM index file
pattern: "*.{bai,sai}"
- fasta:
type: file
description: Reference file to create the CRAM file
pattern: "*.{fasta,fa}"
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- cram_crai:
type: file
description: filtered/converted CRAM file + index
pattern: "*{.cram,.crai}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@FriederikeHanssen"
- "@maxulysse"

View file

@ -1595,6 +1595,10 @@ samtools/bam2fq:
- modules/samtools/bam2fq/** - modules/samtools/bam2fq/**
- tests/modules/samtools/bam2fq/** - tests/modules/samtools/bam2fq/**
samtools/bamtocram:
- modules/samtools/bamtocram/**
- tests/modules/samtools/bamtocram/**
samtools/collatefastq: samtools/collatefastq:
- modules/samtools/collatefastq/** - modules/samtools/collatefastq/**
- tests/modules/samtools/collatefastq/** - tests/modules/samtools/collatefastq/**

View file

@ -0,0 +1,17 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { SAMTOOLS_BAMTOCRAM } from '../../../../modules/samtools/bamtocram/main.nf'
workflow test_samtools_bamtocram {
input = [ [ id:'test', single_end:false ], // meta map
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true),
file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true)]
fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true)
fai = file(params.test_data['sarscov2']['genome']['genome_fasta_fai'], checkIfExists: true)
SAMTOOLS_BAMTOCRAM ( input, fasta, fai )
}

View file

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

View file

@ -0,0 +1,9 @@
- name: samtools bamtocram test_samtools_bamtocram
command: nextflow run ./tests/modules/samtools/bamtocram -entry test_samtools_bamtocram -c ./tests/config/nextflow.config -c ./tests/modules/samtools/bamtocram/nextflow.config
tags:
- samtools/bamtocram
- samtools
files:
- path: output/samtools/test.cram
- path: output/samtools/test.cram.crai
- path: output/samtools/versions.yml