-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcount.nf
134 lines (107 loc) · 4.07 KB
/
count.nf
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
129
130
131
132
133
134
#!/usr/bin/env nextflow
// Enable DSL 2 syntax
nextflow.enable.dsl = 2
// Import the process used to identify samples from the FASTQ files in a folder
include { sample_list; parse_samplesheet } from './modules/general'
// Define the process used to run cellranger count
process cellranger_count {
// Load the appropriate dependencies
label "cellranger"
// Copy all output files to the folder specified by the user with --output
publishDir "${params.output}/", mode: 'copy', overwrite: true
input:
// Run the process once per sample
val sample
// Stage the FASTQ folder (by symlink) in the working directory
path "FASTQ_DIR"
// Stage the reference transcriptome (by symlink) in the working directory
path "REF"
output:
// Capture any created files in the output directory
path "*"
script:
// Run the code defined in templates/count.sh
template "count.sh"
}
// Define the process used to run cellranger count from the samplesheet inputs
process cellranger_count_samplesheet {
// Load the appropriate dependencies
label "cellranger"
// Copy all output files to the folder specified by the user with --output
publishDir "${params.output}/", mode: 'copy', overwrite: true
input:
// Run the process once per sample
tuple val(sample), path("FASTQ_DIR/${sample}_S1_L00*_R1_001.fastq.gz"), path("FASTQ_DIR/${sample}_S1_L00*_R2_001.fastq.gz")
// Stage the reference transcriptome (by symlink) in the working directory
path "REF"
output:
// Capture any created files in the output directory
path "*"
script:
// Run the code defined in templates/count.sh
template "count.sh"
}
workflow {
log.info"""
Parameters:
output: ${params.output}
fastq_dir: ${params.fastq_dir}
samplesheet: ${params.samplesheet}
transcriptome_dir: ${params.transcriptome_dir}
include_introns: ${params.include_introns}
dryrun: ${params.dryrun}
cellranger_version: ${params.cellranger_version}
"""
// Check that the user specified the output parameter
if("${params.output}" == "false"){
error "Parameter 'output' must be specified"
}
// Check that the user specified the fastq_dir parameter
if("${params.fastq_dir}" == "false" && "${params.samplesheet}" == "false"){
error "Either 'fastq_dir' or 'samplesheet' must be specified"
}
// Check that the user specified the fastq_dir parameter
if("${params.fastq_dir}" != "false" && "${params.samplesheet}" != "false"){
error "Either 'fastq_dir' or 'samplesheet' must be specified, but not both."
}
// Check that the user specified the transcriptome_dir parameter
if("${params.transcriptome_dir}" == "false"){
error "Parameter 'transcriptome_dir' must be specified"
}
// Point to the reference transcriptome
ref_dir = file(
"${params.transcriptome_dir}",
checkIfExists: true,
type: "dir",
glob: false
)
if("${params.fastq_dir}" != "false"){
// If the user provided a folder of files to process (or the fastq_dir)
// Get the sample list either from the sample_whitelist or the fastq_dir
sample_list()
// Point to the FASTQ directory
fastq_dir = file(
"${params.fastq_dir}",
checkIfExists: true,
type: "dir",
glob: false
)
// If the user has not set the `dryrun` parameter
if("${params.dryrun}" == "false"){
// Analyze each sample independently
cellranger_count(sample_list.out, fastq_dir, ref_dir)
}else{
// Log the samples which have been detected
sample_list.out
.view {
"Sample: ${it}"
}
}
} else {
// If the user provided a samplesheet
parse_samplesheet()
parse_samplesheet.out.view()
// Analyze each sample independently
cellranger_count_samplesheet(parse_samplesheet.out, ref_dir)
}
}