2020-12-17 18:50:24 -05:00
|
|
|
// Import generic module functions
|
|
|
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
|
|
|
|
|
|
|
params.options = [:]
|
2021-03-15 08:16:43 -04:00
|
|
|
options = initOptions(params.options)
|
2020-12-17 18:50:24 -05:00
|
|
|
|
|
|
|
def VERSION = '2.2.0'
|
|
|
|
|
|
|
|
process HISAT2_BUILD {
|
|
|
|
tag "$fasta"
|
2021-03-16 13:16:47 -04:00
|
|
|
label 'process_high'
|
2021-04-16 03:56:47 -04:00
|
|
|
label 'process_high_memory'
|
2020-12-17 18:50:24 -05:00
|
|
|
publishDir "${params.outdir}",
|
|
|
|
mode: params.publish_dir_mode,
|
2021-04-10 15:49:09 -04:00
|
|
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'index', meta:[:], publish_by_meta:[]) }
|
2020-12-17 18:50:24 -05:00
|
|
|
|
2021-07-28 04:10:44 -04:00
|
|
|
conda (params.enable_conda ? 'bioconda::hisat2=2.2.1' : null)
|
2020-12-17 18:50:24 -05:00
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
2021-07-28 04:10:44 -04:00
|
|
|
container "https://depot.galaxyproject.org/singularity/hisat2:2.2.1--h1b792b2_3"
|
2020-12-17 18:50:24 -05:00
|
|
|
} else {
|
2021-07-28 04:10:44 -04:00
|
|
|
container "quay.io/biocontainers/hisat2:2.2.1--h1b792b2_3"
|
2020-12-17 18:50:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
input:
|
|
|
|
path fasta
|
|
|
|
path gtf
|
|
|
|
path splicesites
|
|
|
|
|
|
|
|
output:
|
2021-04-16 03:56:47 -04:00
|
|
|
path "hisat2" , emit: index
|
2020-12-17 18:50:24 -05:00
|
|
|
path "*.version.txt", emit: version
|
|
|
|
|
|
|
|
script:
|
|
|
|
def avail_mem = 0
|
|
|
|
if (!task.memory) {
|
|
|
|
log.info "[HISAT2 index build] Available memory not known - defaulting to 0. Specify process memory requirements to change this."
|
|
|
|
} else {
|
|
|
|
log.info "[HISAT2 index build] Available memory: ${task.memory}"
|
|
|
|
avail_mem = task.memory.toGiga()
|
|
|
|
}
|
|
|
|
|
|
|
|
def ss = ''
|
|
|
|
def exon = ''
|
2021-04-16 03:56:47 -04:00
|
|
|
def extract_exons = ''
|
|
|
|
def hisat2_build_memory = params.hisat2_build_memory ? (params.hisat2_build_memory as nextflow.util.MemoryUnit).toGiga() : 0
|
|
|
|
if (avail_mem >= hisat2_build_memory) {
|
|
|
|
log.info "[HISAT2 index build] At least ${hisat2_build_memory} GB available, so using splice sites and exons to build HISAT2 index"
|
2020-12-17 18:50:24 -05:00
|
|
|
extract_exons = "hisat2_extract_exons.py $gtf > ${gtf.baseName}.exons.txt"
|
|
|
|
ss = "--ss $splicesites"
|
|
|
|
exon = "--exon ${gtf.baseName}.exons.txt"
|
|
|
|
} else {
|
2021-04-16 03:56:47 -04:00
|
|
|
log.info "[HISAT2 index build] Less than ${hisat2_build_memory} GB available, so NOT using splice sites and exons to build HISAT2 index."
|
|
|
|
log.info "[HISAT2 index build] Use --hisat2_build_memory [small number] to skip this check."
|
2020-12-17 18:50:24 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
def software = getSoftwareName(task.process)
|
|
|
|
"""
|
|
|
|
mkdir hisat2
|
|
|
|
$extract_exons
|
|
|
|
hisat2-build \\
|
|
|
|
-p $task.cpus \\
|
|
|
|
$ss \\
|
|
|
|
$exon \\
|
|
|
|
$options.args \\
|
|
|
|
$fasta \\
|
|
|
|
hisat2/${fasta.baseName}
|
|
|
|
|
|
|
|
echo $VERSION > ${software}.version.txt
|
|
|
|
"""
|
|
|
|
}
|