main.nf 3.19 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
Venkat Malladi's avatar
Venkat Malladi committed
7
params.bcl = "$baseDir/../test_data/*.tar.gz"
Gervaise Henry's avatar
Gervaise Henry committed
8
params.designFile = "$baseDir/../test_data/design.csv"
9
params.outDir = "$baseDir/output"
Gervaise Henry's avatar
Gervaise Henry committed
10
params.references = "$baseDir/../docs/references.md"
Gervaise Henry's avatar
Gervaise Henry committed
11
12
13
14
15

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

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

process checkDesignFile {
Gervaise Henry's avatar
Gervaise Henry committed
23
24
  tag "${bcl.baseName}"
  publishDir "$outDir/misc/${task.process}/${bcl.baseName}", mode: 'copy'
Gervaise Henry's avatar
Gervaise Henry committed
25
26
27

  input:

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

  output:

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

  script:

  """
37
38
  hostname
  ulimit -a
Venkat Malladi's avatar
Venkat Malladi committed
39
  module load python/3.6.1-2-anaconda
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'
Gervaise Henry's avatar
Gervaise Henry committed
48
49
50
51
52
53
54
55
56
57
58
59

  input:

  file tar from tarList

  output:

  file("*") into bclPaths

  script:

  """
60
61
  hostname
  ulimit -a
62
63
64
65
66
67
  name=`echo ${tar} | rev | cut -f1 -d '.' | rev`;
  if [ "\${name}" == "gz" ];
  then   module load pigz/2.4;
  tar -xvf $tar -I pigz;
  else tar -xvf ${tar};
  fi;
Gervaise Henry's avatar
Gervaise Henry committed
68
69
70
71
72
  """
}

process mkfastq {
  tag "${bcl.baseName}"
73
  queue '128GB,256GB,256GBv1,384GB'
74
  publishDir "$outDir/${task.process}", mode: 'copy'
Gervaise Henry's avatar
Gervaise Henry committed
75
76
77
78
79
80
81
82

  input:

  val bcl from bclPaths
  file designPaths

  output:

83
84
  file("**/outs/fastq_path/**/*") into mkfastqPaths
  file("**/outs/**/*.fastq.gz") into fastqPaths
85
  file("**/outs/fastq_path/Stats/Stats.json") into bqcPaths
86
  file("version*.txt") into versionPaths_mkfastq
Gervaise Henry's avatar
Gervaise Henry committed
87
88
89
90

  script:

  """
91
92
93
94
  hostname
  ulimit -a
  module load cellranger/3.0.2
  module load bcl2fastq/2.19.1
95
  sh $baseDir/scripts/versions_mkfastq.sh
96
  cellranger mkfastq --id="${bcl.baseName}" --run=$bcl --csv=$designPaths -r \$SLURM_CPUS_ON_NODE  -p \$SLURM_CPUS_ON_NODE  -w \$SLURM_CPUS_ON_NODE 
Gervaise Henry's avatar
Gervaise Henry committed
97
98
  """
}
Gervaise Henry's avatar
Gervaise Henry committed
99

100
101

process fastqc {
Gervaise Henry's avatar
Gervaise Henry committed
102
  tag "${bcl.baseName}"
103
  queue 'super'
Gervaise Henry's avatar
Gervaise Henry committed
104
  publishDir "$outDir/misc/${task.process}/${bcl.baseName}", mode: 'copy'
105
106

  input:
107
  file fastqPaths
108
109
110
111

  output:

  file("*fastqc.*") into fqcPaths
112
  file("version*.txt") into versionPaths_fastqc
113
114
115
116
117
118
119
120
121
122
123
124
125

  script:

  """
  hostname
  ulimit -a
  module load fastqc/0.11.5
  module load parallel
  sh $baseDir/scripts/fastqc.sh
  """
}


126
process versions {
Gervaise Henry's avatar
Gervaise Henry committed
127
128
  tag "${bcl.baseName}"
  publishDir "$outDir/misc/${task.process}/${bcl.baseName}", mode: 'copy'
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150

  input:

  file versionPaths_mkfastq
  file versionPaths_fastqc

  output:

  file("*.yaml") into yamlPaths

  script:

  """
  hostname
  ulimit -a
  module load python/3.6.1-2-anaconda
  echo $workflow.nextflow.version > version_nextflow.txt
  python3 $baseDir/scripts/generate_versions.py -f version_*.txt -o versions
  """
}


Gervaise Henry's avatar
Gervaise Henry committed
151
process multiqc {
Gervaise Henry's avatar
Gervaise Henry committed
152
  tag "${bcl.baseName}"
Gervaise Henry's avatar
Gervaise Henry committed
153
  queue 'super'
Gervaise Henry's avatar
Gervaise Henry committed
154
155
156
157
  publishDir "$outDir/${task.process}", mode: 'copy'

  input:

158
159
  file bqcPaths
  file fqcPaths
160
  file yamlPaths
Gervaise Henry's avatar
Gervaise Henry committed
161
162
163

  output:

164
  file("*") into mqcPaths
Gervaise Henry's avatar
Gervaise Henry committed
165
166
167
168
169
170
171

  script:

  """
  hostname
  ulimit -a
  module load multiqc/1.7
Gervaise Henry's avatar
Gervaise Henry committed
172
  multiqc . -c $baseDir/scripts/.multiqc_config.yaml 
Gervaise Henry's avatar
Gervaise Henry committed
173
174
  """
}