2020-12-17 23:50:24 +00:00
|
|
|
// Import generic module functions
|
|
|
|
include { initOptions; saveFiles; getSoftwareName } from './functions'
|
|
|
|
|
|
|
|
params.options = [:]
|
2021-03-15 12:16:43 +00:00
|
|
|
options = initOptions(params.options)
|
2020-12-17 23:50:24 +00:00
|
|
|
|
|
|
|
process STAR_ALIGN {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_high'
|
|
|
|
publishDir "${params.outdir}",
|
|
|
|
mode: params.publish_dir_mode,
|
2021-04-09 16:23:56 +00:00
|
|
|
saveAs: { filename -> saveFiles(filename:filename, options:params.options, publish_dir:getSoftwareName(task.process), meta:meta, publish_by_meta:['id']) }
|
2020-12-17 23:50:24 +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' : null)
|
2020-12-17 23:50:24 +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/star:2.7.9a--h9ee0642_0'
|
2020-12-17 23:50:24 +00:00
|
|
|
} else {
|
2021-07-21 12:30:52 +00:00
|
|
|
container 'quay.io/biocontainers/star:2.7.9a--h9ee0642_0'
|
2020-12-17 23:50:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(reads)
|
|
|
|
path index
|
|
|
|
path gtf
|
|
|
|
|
|
|
|
output:
|
2021-01-26 11:46:30 +00:00
|
|
|
tuple val(meta), path('*d.out.bam') , emit: bam
|
2021-01-25 08:02:03 +00:00
|
|
|
tuple val(meta), path('*Log.final.out') , emit: log_final
|
|
|
|
tuple val(meta), path('*Log.out') , emit: log_out
|
|
|
|
tuple val(meta), path('*Log.progress.out'), emit: log_progress
|
|
|
|
path '*.version.txt' , emit: version
|
2020-12-17 23:50:24 +00:00
|
|
|
|
2021-01-25 08:02:03 +00:00
|
|
|
tuple val(meta), path('*sortedByCoord.out.bam') , optional:true, emit: bam_sorted
|
|
|
|
tuple val(meta), path('*toTranscriptome.out.bam'), optional:true, emit: bam_transcript
|
2021-01-26 11:46:30 +00:00
|
|
|
tuple val(meta), path('*Aligned.unsort.out.bam') , optional:true, emit: bam_unsorted
|
2021-01-25 08:02:03 +00:00
|
|
|
tuple val(meta), path('*fastq.gz') , optional:true, emit: fastq
|
|
|
|
tuple val(meta), path('*.tab') , optional:true, emit: tab
|
2021-07-26 17:03:30 +00:00
|
|
|
tuple val(meta), path('*.out.junction') , optional:true, emit: junction
|
2020-12-17 23:50:24 +00:00
|
|
|
|
|
|
|
script:
|
2021-08-04 09:16:51 +00:00
|
|
|
def software = getSoftwareName(task.process)
|
|
|
|
def prefix = options.suffix ? "${meta.id}${options.suffix}" : "${meta.id}"
|
|
|
|
def ignore_gtf = params.star_ignore_sjdbgtf ? '' : "--sjdbGTFfile $gtf"
|
|
|
|
def seq_platform = params.seq_platform ? "'PL:$params.seq_platform'" : ""
|
|
|
|
def seq_center = params.seq_center ? "--outSAMattrRGline ID:$prefix 'CN:$params.seq_center' 'SM:$prefix' $seq_platform " : "--outSAMattrRGline ID:$prefix 'SM:$prefix' $seq_platform "
|
|
|
|
def out_sam_type = (options.args.contains('--outSAMtype')) ? '' : '--outSAMtype BAM Unsorted'
|
2021-01-25 13:09:03 +00:00
|
|
|
def mv_unsorted_bam = (options.args.contains('--outSAMtype BAM Unsorted SortedByCoordinate')) ? "mv ${prefix}.Aligned.out.bam ${prefix}.Aligned.unsort.out.bam" : ''
|
2020-12-17 23:50:24 +00:00
|
|
|
"""
|
|
|
|
STAR \\
|
|
|
|
--genomeDir $index \\
|
|
|
|
--readFilesIn $reads \\
|
|
|
|
--runThreadN $task.cpus \\
|
|
|
|
--outFileNamePrefix $prefix. \\
|
2021-01-25 13:09:03 +00:00
|
|
|
$out_sam_type \\
|
2020-12-17 23:50:24 +00:00
|
|
|
$ignore_gtf \\
|
|
|
|
$seq_center \\
|
|
|
|
$options.args
|
|
|
|
|
2021-01-26 11:46:30 +00:00
|
|
|
$mv_unsorted_bam
|
2021-01-25 13:09:03 +00:00
|
|
|
|
2020-12-17 23:50:24 +00:00
|
|
|
if [ -f ${prefix}.Unmapped.out.mate1 ]; then
|
|
|
|
mv ${prefix}.Unmapped.out.mate1 ${prefix}.unmapped_1.fastq
|
|
|
|
gzip ${prefix}.unmapped_1.fastq
|
|
|
|
fi
|
|
|
|
if [ -f ${prefix}.Unmapped.out.mate2 ]; then
|
|
|
|
mv ${prefix}.Unmapped.out.mate2 ${prefix}.unmapped_2.fastq
|
|
|
|
gzip ${prefix}.unmapped_2.fastq
|
|
|
|
fi
|
|
|
|
|
|
|
|
STAR --version | sed -e "s/STAR_//g" > ${software}.version.txt
|
|
|
|
"""
|
|
|
|
}
|