-
Notifications
You must be signed in to change notification settings - Fork 20
/
kallisto.nf
executable file
·144 lines (114 loc) · 3.67 KB
/
kallisto.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
135
136
137
138
139
140
141
/*
* Copyright (c) 2015-2018, Centre for Genomic Regulation (CRG) and the authors.
*
* This file is part of 'Kallisto-NF'.
*
* Kallisto-NF is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Kallisto-NF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Kallisto-NF. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Main Kallisto-NF pipeline script
*
* @authors
* Paolo Di Tommaso <[email protected]>
* Evan Floden <[email protected]>
*/
params.transcriptome = "$baseDir/tutorial/transcriptome/transcriptome.fa"
params.name = "RNA-Seq Abundance Analysis"
params.reads = "$baseDir/tutorial/reads/*.fastq"
params.fragment_len = '180'
params.fragment_sd = '20'
params.bootstrap = '100'
params.experiment = "$baseDir/tutorial/experiment/hiseq_info.txt"
params.output = "results/"
log.info "K A L L I S T O - N F ~ version 0.9"
log.info "====================================="
log.info "name : ${params.name}"
log.info "reads : ${params.reads}"
log.info "transcriptome : ${params.transcriptome}"
log.info "fragment length : ${params.fragment_len} nt"
log.info "fragment SD : ${params.fragment_sd} nt"
log.info "bootstraps : ${params.bootstrap}"
log.info "experimental design : ${params.experiment}"
log.info "output : ${params.output}"
log.info "\n"
/*
* Input parameters validation
*/
transcriptome_file = file(params.transcriptome)
exp_file = file(params.experiment)
/*
* validate input files
*/
if( !transcriptome_file.exists() ) exit 1, "Missing transcriptome file: ${transcriptome_file}"
if( !exp_file.exists() ) exit 1, "Missing experimental design file: ${exp_file}"
/*
* Create a channel for read files
*/
Channel
.fromFilePairs( params.reads, size: -1 )
.ifEmpty { error "Cannot find any reads matching: ${params.reads}" }
.set { read_files }
process index {
input:
file transcriptome_file
output:
file "transcriptome.index" into transcriptome_index
script:
//
// Kallisto tools mapper index
//
"""
kallisto index -i transcriptome.index ${transcriptome_file}
"""
}
process mapping {
tag "reads: $name"
input:
file index from transcriptome_index
set val(name), file(reads) from read_files
output:
file "kallisto_${name}" into kallisto_out_dirs
script:
//
// Kallisto tools mapper
//
def single = reads instanceof Path
if( !single ) {
"""
mkdir kallisto_${name}
kallisto quant -b ${params.bootstrap} -i ${index} -t ${task.cpus} -o kallisto_${name} ${reads}
"""
}
else {
"""
mkdir kallisto_${name}
kallisto quant --single -l ${params.fragment_len} -s ${params.fragment_sd} -b ${params.bootstrap} -i ${index} -t ${task.cpus} -o kallisto_${name} ${reads}
"""
}
}
process sleuth {
input:
file 'kallisto/*' from kallisto_out_dirs.collect()
file exp_file
output:
file 'sleuth_object.so'
file 'gene_table_results.txt'
script:
//
// Setup sleuth R dependancies and environment
//
"""
sleuth.R kallisto ${exp_file}
"""
}