main.nf 2.33 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
11
12
13
14

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

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

process checkDesignFile {

22
  publishDir "$outDir/${task.process}", mode: 'copy'
Gervaise Henry's avatar
Gervaise Henry committed
23
24
25

  input:

26
  file designLocation
Gervaise Henry's avatar
Gervaise Henry committed
27
28
29

  output:

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

  script:

  """
35
36
  hostname
  ulimit -a
Venkat Malladi's avatar
Venkat Malladi committed
37
  module load python/3.6.1-2-anaconda
38
  python3 $baseDir/scripts/check_design.py -d $designLocation
Gervaise Henry's avatar
Gervaise Henry committed
39
40
41
42
43
44
45
  """
}


process untarBCL {
  tag "$tar"

46
  publishDir "$outDir/${task.process}", mode: 'copy'
Gervaise Henry's avatar
Gervaise Henry committed
47
48
49
50
51
52
53
54
55
56
57
58

  input:

  file tar from tarList

  output:

  file("*") into bclPaths

  script:

  """
59
60
  hostname
  ulimit -a
61
62
63
64
65
66
  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
67
68
69
70
71
  """
}

process mkfastq {
  tag "${bcl.baseName}"
72
  queue '128GB,256GB,256GBv1,384GB'
73

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
Gervaise Henry's avatar
Gervaise Henry committed
86
87
88
89

  script:

  """
90
91
92
93
  hostname
  ulimit -a
  module load cellranger/3.0.2
  module load bcl2fastq/2.19.1
94
  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
95
96
  """
}
Gervaise Henry's avatar
Gervaise Henry committed
97

98
99
100
101
102

process fastqc {
  publishDir "$outDir/${task.process}", mode: 'copy'

  input:
103
  file fastqPaths
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

  output:

  file("*fastqc.*") into fqcPaths

  script:

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


Gervaise Henry's avatar
Gervaise Henry committed
121
122
123
124
125
process multiqc {
  publishDir "$outDir/${task.process}", mode: 'copy'

  input:

126
127
  file bqcPaths
  file fqcPaths
Gervaise Henry's avatar
Gervaise Henry committed
128
129
130

  output:

131
  file("*") into mqcPaths
Gervaise Henry's avatar
Gervaise Henry committed
132
133
134
135
136
137
138

  script:

  """
  hostname
  ulimit -a
  module load multiqc/1.7
139
  multiqc .
Gervaise Henry's avatar
Gervaise Henry committed
140
141
  """
}