main.nf 3.13 KB
Newer Older
Gervaise Henry's avatar
Gervaise Henry committed
1
2
3
4
5
6
#!/usr/bin/env nextflow

// Path to an input file, or a pattern for multiple inputs
// Note - $baseDir is the location of this workflow file main.nf

// Define Input variables
7
params.name = "run"
Venkat Malladi's avatar
Venkat Malladi committed
8
params.bcl = "$baseDir/../test_data/*.tar.gz"
Gervaise Henry's avatar
Gervaise Henry committed
9
params.designFile = "$baseDir/../test_data/design.csv"
10
params.outDir = "$baseDir/output"
Gervaise Henry's avatar
Gervaise Henry committed
11
12
13
14
15

// Define List of Files
tarList = Channel.fromPath( params.bcl )

// Define regular variables
Gervaise Henry's avatar
Gervaise Henry committed
16
name = params.name
17
18
19
20
designLocation = Channel
  .fromPath(params.designFile)
  .ifEmpty { exit 1, "design file not found: ${params.designFile}" }
outDir = params.outDir
Gervaise Henry's avatar
Gervaise Henry committed
21
22

process checkDesignFile {
Gervaise Henry's avatar
Gervaise Henry committed
23
24
  tag "$name"
  publishDir "$outDir/misc/${task.process}/$name", mode: 'copy'
25
  module 'python/3.6.1-2-anaconda'
Gervaise Henry's avatar
Gervaise Henry committed
26
27
28

  input:

29
  file designLocation
Gervaise Henry's avatar
Gervaise Henry committed
30
31
32

  output:

33
  file("design.checked.csv") into designPaths
Gervaise Henry's avatar
Gervaise Henry committed
34
35
36
37

  script:

  """
38
39
  hostname
  ulimit -a
40
  python3 "$baseDir/scripts/check_design.py" -d "$designLocation"
Gervaise Henry's avatar
Gervaise Henry committed
41
42
43
44
45
46
  """
}


process untarBCL {
  tag "$tar"
47
  publishDir "$outDir/${task.process}", mode: 'copy'
48
  module 'pigz/2.4'
Gervaise Henry's avatar
Gervaise Henry committed
49
50
51
52
53
54
55

  input:

  file tar from tarList

  output:

56
  file("*") into bclPaths mode flatten
Gervaise Henry's avatar
Gervaise Henry committed
57
58
59
60

  script:

  """
61
62
  hostname
  ulimit -a
Jeremy Mathews's avatar
Jeremy Mathews committed
63
  bash "$baseDir/scripts/untarBCL.sh" -t "$tar"
Gervaise Henry's avatar
Gervaise Henry committed
64
65
66
67
68
  """
}

process mkfastq {
  tag "${bcl.baseName}"
69
  queue '128GB,256GB,256GBv1,384GB'
Gervaise Henry's avatar
Fix    
Gervaise Henry committed
70
  publishDir "$outDir/${task.process}", mode: 'copy', pattern: "{*/outs/**/*.fastq.gz}"
71
  module 'cellranger/3.0.2:bcl2fastq/2.19.1'
Gervaise Henry's avatar
Gervaise Henry committed
72
73
74

  input:

75
76
  each bcl from bclPaths.collect()
  file design from designPaths
Gervaise Henry's avatar
Gervaise Henry committed
77
78
79

  output:

80
  file("**/outs/**/*.fastq.gz") into fastqPaths
81
  file("**/outs/fastq_path/Stats/Stats.json") into bqcPaths
82
  val "${bcl.baseName}" into bclName
Gervaise Henry's avatar
Gervaise Henry committed
83
84
85
86

  script:

  """
87
  hostname
88
  ulimit -a  
89
  cellranger mkfastq --id="${bcl.baseName}" --run="$bcl" --csv=$design -r \$SLURM_CPUS_ON_NODE  -p \$SLURM_CPUS_ON_NODE  -w \$SLURM_CPUS_ON_NODE 
Gervaise Henry's avatar
Gervaise Henry committed
90
91
  """
}
Gervaise Henry's avatar
Gervaise Henry committed
92

93
process fastqc {
94
  tag "$bclName"
95
  queue 'super'
Gervaise Henry's avatar
Gervaise Henry committed
96
  publishDir "$outDir/misc/${task.process}/$name/$bclName", mode: 'copy', pattern: "{*fastqc.zip}"
Gervaise Henry's avatar
Fix    
Gervaise Henry committed
97
  module 'fastqc/0.11.5:parallel'
98
99

  input:
100
  file fastqPaths
Gervaise Henry's avatar
Gervaise Henry committed
101
  val bclName
102
103
104

  output:

105
  file("*fastqc.zip") into fqcPaths
106
107
108
109
110
111

  script:

  """
  hostname
  ulimit -a
112
  find *.fastq.gz -exec mv {} $bclName.{} \\;
113
  bash "$baseDir/scripts/fastqc.sh"
114
  
115
116
117
118
  """
}


119
process versions {
Gervaise Henry's avatar
Gervaise Henry committed
120
121
  tag "$name"
  publishDir "$outDir/misc/${task.process}/$name", mode: 'copy'
122
  module 'python/3.6.1-2-anaconda:cellranger/3.0.2:bcl2fastq/2.19.1:fastqc/0.11.5'
123
124
125
126
127
128
129
130
131
132
133
134
135

  input:

  output:

  file("*.yaml") into yamlPaths

  script:

  """
  hostname
  ulimit -a
  echo $workflow.nextflow.version > version_nextflow.txt
136
137
138
  bash "$baseDir/scripts/versions_mkfastq.sh"
  bash "$baseDir/scripts/versions_fastqc.sh"
  python3 "$baseDir/scripts/generate_versions.py" -f version_*.txt -o versions
139
140
141
  """
}

Gervaise Henry's avatar
Gervaise Henry committed
142
process multiqc {
Gervaise Henry's avatar
Gervaise Henry committed
143
  tag "$name"
Gervaise Henry's avatar
Gervaise Henry committed
144
  queue 'super'
145
  publishDir "$outDir/${task.process}/$name", mode: 'copy', pattern: "{multiqc*}"
146
  module 'multiqc/1.7'
Gervaise Henry's avatar
Gervaise Henry committed
147
148
149

  input:

150
  file bqc name "bqc/?/*" from bqcPaths.collect()
151
  file fqc name "fqc/*" from fqcPaths.collect()
152
  file yamlPaths
Gervaise Henry's avatar
Gervaise Henry committed
153
154
155

  output:

156
  file("*") into mqcPaths
Gervaise Henry's avatar
Gervaise Henry committed
157
158
159
160
161
162

  script:

  """
  hostname
  ulimit -a
163
  multiqc . -c "$baseDir/conf/multiqc_config.yaml"
Gervaise Henry's avatar
Gervaise Henry committed
164
165
  """
}