-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
128 lines (107 loc) · 4.59 KB
/
Copy pathmain.nf
File metadata and controls
128 lines (107 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
import RuntimeSupport
import SamplesheetParser
import WorkflowSupport
final String resolvedOutdir = RuntimeSupport.resolveProjectPath(projectDir.toString(), params.outdir ?: 'results')
final String resolvedCoreScriptsDir = RuntimeSupport.resolveProjectPath(projectDir.toString(), params.core_scripts_dir ?: 'scripts/core_runtime')
final Map<String, String> deprecatedCliParams = [
runtime_env_prefix : 'runtime.env_prefix',
runtime_tmpdir : 'runtime.tmpdir',
ligation_barcode_whitelist : 'references.ligation_barcode_whitelist',
rna_ref_base_dir : 'references.rna_ref_dir',
rna_align_species : 'references.species',
rna_ref_dir : 'references.rna_ref_dir',
dna_ref_dir : 'references.dna_ref_dir',
dna_bwa_reference : 'the inferred prefix from references.dna_ref_dir',
dna_blacklist_bed : 'references.dna_blacklist_bed',
dna_chrom_sizes : 'references.dna_chrom_sizes',
dna_effective_genome_size : 'references.dna_effective_genome_size',
]
deprecatedCliParams.each { paramName, replacement ->
if( params.containsKey(paramName) && params[paramName]?.toString()?.trim() ) {
error "Deprecated parameter --${paramName} is no longer supported. Configure ${replacement} in the samplesheet instead."
}
}
if( !params.samplesheet ) {
error "Missing required parameter: --samplesheet"
}
Map samplesheetContract = null
try {
samplesheetContract = SamplesheetParser.parseContract(
params.samplesheet as String,
[
outdir : resolvedOutdir,
barcode_defaults: params.barcode_defaults,
]
)
}
catch( IllegalArgumentException e ) {
error e.message
}
final Map runtimeConfig = samplesheetContract['runtime'] as Map
final Map referenceConfig = samplesheetContract['references'] as Map
final Map modalityConfig = samplesheetContract['modalities'] as Map
final Map runtimeParams = [
runtime_env_prefix: runtimeConfig['env_prefix'],
runtime_tmpdir : runtimeConfig['tmpdir'],
]
final List<Map> sampleRows = samplesheetContract['samples'] as List<Map>
// The runtime contract is enforced once up front so every downstream task sees
// the same validated toolchain and the same pinned Codon/Seq preflight result.
def runCodonSeqPreflight(final Map runtimeParams) {
final File preflight = new File(projectDir.toString(), 'bin/check_codon_seq_host.sh')
final String codonBin = RuntimeSupport.runtimeToolPath(runtimeParams, 'codon')
final String codonHome = RuntimeSupport.runtimeCodonHome(runtimeParams)
if( !preflight.exists() ) {
throw new IllegalStateException(
"Global pinned Codon/Seq preflight failed. Missing required preflight script: ${preflight}"
)
}
final ProcessBuilder processBuilder = new ProcessBuilder('bash', preflight.toString())
.directory(projectDir.toFile())
.redirectErrorStream(true)
final Map<String, String> env = processBuilder.environment()
if( codonBin ) {
env.put('CODON_BIN', codonBin)
}
if( codonHome ) {
env.put('CODON_HOME', codonHome)
}
final Process process = processBuilder.start()
final String output = process.inputStream.getText('UTF-8').trim()
final int exitCode = process.waitFor()
if( exitCode != 0 ) {
final String detail = output ? "\n${output}" : ''
throw new IllegalStateException(
"Global pinned Codon/Seq preflight failed. Every pipeline run requires codon 0.16.3 and Seq 0.11.3.${detail}"
)
}
return output
}
log.warn """
================================================================================
TrESFlow runtime TMPDIR resolved for this run:
${runtimeParams.runtime_tmpdir}
This directory can become very large on production FASTQ/BAM runs. Monitor free
space on the filesystem that backs this path.
================================================================================
""".stripIndent().trim()
RuntimeSupport.validateRuntimeContract(runtimeParams)
RuntimeSupport.validateConfiguredDirectory('core scripts dir', resolvedCoreScriptsDir)
final String codonPreflightOutput = runCodonSeqPreflight(runtimeParams)
WorkflowSupport.validateReferenceContract(
referenceConfig,
modalityConfig,
sampleRows
)
RuntimeSupport.writeRuntimeContract(
resolvedOutdir,
RuntimeSupport.configuredRuntimeTools(runtimeParams),
codonPreflightOutput,
RuntimeSupport.runtimeContext(runtimeParams)
)
include { TRESEQ } from './workflows/treseq'
workflow {
TRESEQ(sampleRows)
}