2020-09-10 15:45:11 +00:00
|
|
|
// Import generic module functions
|
2021-09-27 08:41:24 +00:00
|
|
|
include { initOptions; saveFiles; getSoftwareName; getProcessName } from './functions'
|
2020-09-10 15:45:11 +00:00
|
|
|
|
2020-10-14 17:29:50 +00:00
|
|
|
params.options = [:]
|
2021-03-15 12:16:43 +00:00
|
|
|
options = initOptions(params.options)
|
2020-10-14 17:29:50 +00:00
|
|
|
|
2020-09-10 15:45:11 +00:00
|
|
|
process STAR_GENOMEGENERATE {
|
|
|
|
tag "$fasta"
|
|
|
|
label 'process_high'
|
|
|
|
publishDir "${params.outdir}",
|
|
|
|
mode: params.publish_dir_mode,
|
2021-04-10 19:49:09 +00:00
|
|
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:'index', meta:[:], publish_by_meta:[]) }
|
2020-09-10 15:45:11 +00:00
|
|
|
|
2020-10-14 17:29:50 +00:00
|
|
|
// Note: 2.7X indices incompatible with AWS iGenomes.
|
2021-07-21 12:30:52 +00:00
|
|
|
conda (params.enable_conda ? "bioconda::star=2.7.9a bioconda::samtools=1.13 conda-forge::gawk=5.1.0" : null)
|
2020-12-13 23:41:53 +00:00
|
|
|
if (workflow.containerEngine == 'singularity' && !params.singularity_pull_docker_container) {
|
2021-07-21 12:30:52 +00:00
|
|
|
container "https://depot.galaxyproject.org/singularity/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:a7908dfb0485a80ca94e4d17b0ac991532e4e989-0"
|
2020-12-13 23:41:53 +00:00
|
|
|
} else {
|
2021-07-21 12:30:52 +00:00
|
|
|
container "quay.io/biocontainers/mulled-v2-1fa26d1ce03c295fe2fdcf85831a92fbcbd7e8c2:a7908dfb0485a80ca94e4d17b0ac991532e4e989-0"
|
2020-12-13 23:41:53 +00:00
|
|
|
}
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
path fasta
|
|
|
|
path gtf
|
|
|
|
|
|
|
|
output:
|
|
|
|
path "star" , emit: index
|
2021-10-01 13:04:56 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2020-09-10 15:45:11 +00:00
|
|
|
|
|
|
|
script:
|
2021-04-16 07:56:47 +00:00
|
|
|
def memory = task.memory ? "--limitGenomeGenerateRAM ${task.memory.toBytes() - 100000000}" : ''
|
|
|
|
def args = options.args.tokenize()
|
|
|
|
if (args.contains('--genomeSAindexNbases')) {
|
|
|
|
"""
|
|
|
|
mkdir star
|
|
|
|
STAR \\
|
|
|
|
--runMode genomeGenerate \\
|
|
|
|
--genomeDir star/ \\
|
|
|
|
--genomeFastaFiles $fasta \\
|
|
|
|
--sjdbGTFfile $gtf \\
|
|
|
|
--runThreadN $task.cpus \\
|
|
|
|
$memory \\
|
|
|
|
$options.args
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
|
|
|
${getSoftwareName(task.process)}: \$(STAR --version | sed -e "s/STAR_//g")
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-04-16 07:56:47 +00:00
|
|
|
"""
|
|
|
|
} else {
|
|
|
|
"""
|
|
|
|
samtools faidx $fasta
|
|
|
|
NUM_BASES=`gawk '{sum = sum + \$2}END{if ((log(sum)/log(2))/2 - 1 > 14) {printf "%.0f", 14} else {printf "%.0f", (log(sum)/log(2))/2 - 1}}' ${fasta}.fai`
|
|
|
|
|
|
|
|
mkdir star
|
|
|
|
STAR \\
|
|
|
|
--runMode genomeGenerate \\
|
|
|
|
--genomeDir star/ \\
|
|
|
|
--genomeFastaFiles $fasta \\
|
|
|
|
--sjdbGTFfile $gtf \\
|
|
|
|
--runThreadN $task.cpus \\
|
|
|
|
--genomeSAindexNbases \$NUM_BASES \\
|
|
|
|
$memory \\
|
|
|
|
$options.args
|
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
${getProcessName(task.process)}:
|
|
|
|
${getSoftwareName(task.process)}: \$(STAR --version | sed -e "s/STAR_//g")
|
2021-09-28 13:37:47 +00:00
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
gawk: \$(echo \$(gawk --version 2>&1) | sed 's/^.*GNU Awk //; s/, .*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-04-16 07:56:47 +00:00
|
|
|
"""
|
|
|
|
}
|
2020-09-10 15:45:11 +00:00
|
|
|
}
|