Merge remote-tracking branch 'upstream/master' into bedtools_getfasta

This commit is contained in:
JoseEspinosa 2021-02-09 18:23:24 +01:00
commit 68b85d9191
6 changed files with 211 additions and 7 deletions

18
.github/filters.yml vendored
View file

@ -4,27 +4,27 @@ bandage_image:
bcftools_bgzip: bcftools_bgzip:
- software/bcftools/bgzip/** - software/bcftools/bgzip/**
- tests/software/bcftools/bgzip** - tests/software/bcftools/bgzip/**
bcftools_consensus: bcftools_consensus:
- software/bcftools/consensus/** - software/bcftools/consensus/**
- tests/software/bcftools/consensus** - tests/software/bcftools/consensus/**
bcftools_filter: bcftools_filter:
- software/bcftools/filter/** - software/bcftools/filter/**
- tests/software/bcftools/filter** - tests/software/bcftools/filter/**
bcftools_isec: bcftools_isec:
- software/bcftools/isec/** - software/bcftools/isec/**
- tests/software/bcftools/isec** - tests/software/bcftools/isec/**
bcftools_stats: bcftools_stats:
- software/bcftools/stats/** - software/bcftools/stats/**
- tests/software/bcftools/stats** - tests/software/bcftools/stats/**
bcftools_tabix: bcftools_tabix:
- software/bcftools/tabix/** - software/bcftools/tabix/**
- tests/software/bcftools/tabix** - tests/software/bcftools/tabix/**
bedtools_complement: bedtools_complement:
- software/bedtools/complement/** - software/bedtools/complement/**
@ -60,7 +60,11 @@ bedtools_sort:
blast_makeblastdb: blast_makeblastdb:
- software/blast/makeblastdb/** - software/blast/makeblastdb/**
- tests/software/blast/makeblastdb** - tests/software/blast/makeblastdb/**
blast_blastn:
- software/blast/blastn/**
- tests/software/blast/blastn/**
bowtie: bowtie:
- software/bowtie/build/** - software/bowtie/build/**

View file

@ -0,0 +1,60 @@
/*
* -----------------------------------------------------
* Utility functions used in nf-core DSL2 module files
* -----------------------------------------------------
*/
/*
* Extract name of software tool from process name using $task.process
*/
def getSoftwareName(task_process) {
return task_process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()
}
/*
* Function to initialise default values and to generate a Groovy Map of available options for nf-core modules
*/
def initOptions(Map args) {
def Map options = [:]
options.args = args.args ?: ''
options.args2 = args.args2 ?: ''
options.publish_by_id = args.publish_by_id ?: false
options.publish_dir = args.publish_dir ?: ''
options.publish_files = args.publish_files
options.suffix = args.suffix ?: ''
return options
}
/*
* Tidy up and join elements of a list to return a path string
*/
def getPathFromList(path_list) {
def paths = path_list.findAll { item -> !item?.trim().isEmpty() } // Remove empty entries
paths = paths.collect { it.trim().replaceAll("^[/]+|[/]+\$", '') } // Trim whitespace and trailing slashes
return paths.join('/')
}
/*
* Function to save/publish module results
*/
def saveFiles(Map args) {
if (!args.filename.endsWith('.version.txt')) {
def ioptions = initOptions(args.options)
def path_list = [ ioptions.publish_dir ?: args.publish_dir ]
if (ioptions.publish_by_id) {
path_list.add(args.publish_id)
}
if (ioptions.publish_files instanceof Map) {
for (ext in ioptions.publish_files) {
if (args.filename.endsWith(ext.key)) {
def ext_list = path_list.collect()
ext_list.add(ext.value)
return "${getPathFromList(ext_list)}/$args.filename"
}
}
} else if (ioptions.publish_files == null) {
return "${getPathFromList(path_list)}/$args.filename"
}
}
}

View file

@ -0,0 +1,42 @@
// Import generic module functions
include { initOptions; saveFiles; getSoftwareName } from './functions'
params.options = [:]
def options = initOptions(params.options)
process BLAST_BLASTN {
tag "$meta.id"
label 'process_medium'
publishDir "${params.outdir}",
mode: params.publish_dir_mode,
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), publish_id:meta.id) }
conda (params.enable_conda ? 'bioconda::blast=2.10.1' : null)
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
container 'https://depot.galaxyproject.org/singularity/blast:2.10.1--pl526he19e7b1_3'
} else {
container 'quay.io/biocontainers/blast:2.10.1--pl526he19e7b1_3'
}
input:
tuple val(meta), path(fasta)
path db
output:
tuple val(meta), path('*.blastn.txt'), emit: txt
path '*.version.txt' , emit: version
script:
def software = getSoftwareName(task.process)
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
"""
DB=`find -L ./ -name "*.ndb" | sed 's/.ndb//'`
blastn \\
-num_threads $task.cpus \\
-db \$DB \\
-query $fasta \\
$options.args \\
-out ${prefix}.blastn.txt
echo \$(blastn -version 2>&1) | sed 's/^.*blastn: //; s/ .*\$//' > ${software}.version.txt
"""
}

View file

@ -0,0 +1,61 @@
name: blast_blastn
description: Queries a BLAST DNA database
keywords:
- fasta
- blast
- blastn
- DNA sequence
tools:
- blast:
description: |
BLAST finds regions of similarity between biological sequences.
homepage: https://blast.ncbi.nlm.nih.gov/Blast.cgi
documentation: https://blast.ncbi.nlm.nih.gov/Blast.cgi?CMD=Web&PAGE_TYPE=Blastdocs
doi: 10.1016/S0022-2836(05)80360-2
params:
- outdir:
type: string
description: |
The pipeline's output directory. By default, the module will
output files into `$params.outdir/<SOFTWARE>`
- publish_dir_mode:
type: string
description: |
Value for the Nextflow `publishDir` mode parameter.
Available: symlink, rellink, link, copy, copyNoFollow, move.
- enable_conda:
type: boolean
description: |
Run the module with Conda using the software specified
via the `conda` directive
- singularity_pull_docker_container:
type: boolean
description: |
Instead of directly downloading Singularity images for use with Singularity,
force the workflow to pull and convert Docker containers instead.
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- fasta:
type: file
description: Input fasta file containing queries sequences
pattern: "*.{fa,fasta}"
- db:
type: directory
description: Directory containing blast database
pattern: "*"
output:
- txt:
type: file
description: File containing blastn hits
pattern: "*.{blastn.txt}"
- version:
type: file
description: File containing software version
pattern: "*.{version.txt}"
authors:
- "@joseespinosa"
- "@drpatelh"

View file

@ -0,0 +1,15 @@
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
include { BLAST_MAKEBLASTDB } from '../../../../software/blast/makeblastdb/main.nf' addParams( options: ['args': '-dbtype nucl'] )
include { BLAST_BLASTN } from '../../../../software/blast/blastn/main.nf' addParams( options: [:] )
workflow test_blast_blastn {
def input = []
input = [ file("${launchDir}/tests/data/fasta/E_coli/NC_010473.fa", checkIfExists: true) ]
BLAST_MAKEBLASTDB (input)
BLAST_BLASTN ([ [id:'test'], input ], BLAST_MAKEBLASTDB.out.db)
}

View file

@ -0,0 +1,22 @@
- name: blast_blastn
command: nextflow run ./tests/software/blast/blastn -entry test_blast_blastn -c tests/config/nextflow.config
tags:
- blast
- blast_blastn
files:
- path: output/blast/blast_db/NC_010473.fa
md5sum: ad277e6b3da5dcf9fccfcd3a55fcec8e
- path: output/blast/blast_db/NC_010473.fa.ndb
md5sum: 5fc66e1a2b3b38966eb40ed15642ba3e
- path: output/blast/blast_db/NC_010473.fa.nhr
md5sum: 41702062ff7cce21e0649864013fad73
- path: output/blast/blast_db/NC_010473.fa.nin
should_exist: true
- path: output/blast/blast_db/NC_010473.fa.not
md5sum: 1e53e9d08f1d23af0299cfa87478a7bb
- path: output/blast/blast_db/NC_010473.fa.nsq
md5sum: 8e2d0c3fc02a8c2c886bafb73bdd8a89
- path: output/blast/blast_db/NC_010473.fa.ntf
md5sum: 1f6027d443e67a98ad0edc2d39971b0c
- path: output/blast/test.blastn.txt
should_exist: true