main.nf 1.99 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
83

  input:

  val bcl from bclPaths
  file designPaths

  output:

  file("**/outs/fastq_path/**/*") into fastqPaths
Gervaise Henry's avatar
Gervaise Henry committed
84
  file("**/outs/fastq_path/Stats/Stats.json") into qc
Gervaise Henry's avatar
Gervaise Henry committed
85
86
87
88

  script:

  """
89
90
91
92
  hostname
  ulimit -a
  module load cellranger/3.0.2
  module load bcl2fastq/2.19.1
93
  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
94
95
  """
}
Gervaise Henry's avatar
Gervaise Henry committed
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

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

  input:

  file qc

  output:

  file("*") into qcPaths

  script:

  """
  hostname
  ulimit -a
  module load multiqc/1.7
  multiqc Stats.json
  """
}