Newer
Older
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
nextflow.enable.dsl=2
include {
fastp
} from './nf_modules/fastp/main'
workflow csv_parsing {
if (params.csv_path.size() > 0) {
log.info "loading local csv files"
Channel
.fromPath(params.csv_path, checkIfExists: true)
.ifEmpty { error
log.error """
=============================================================
WARNING! No csv input file precised.
Use '--csv_path <file.csv>'
Or '--help' for more informations
=============================================================
"""
}
.splitCsv(header: true, sep: ";", strip: true)
.flatMap{
it -> [
[(it.IP + it.WCE).md5(), "IP", "w", file(it.IP)],
[(it.IP + it.WCE).md5(), "WCE", "w", file(it.WCE)]
]
}
.map{ it ->
if (it[1] instanceof List){
it
} else {
[it[0], [it[1]], it[2], it[3], [it[4]]]
}
}
.map{
it ->
if (it[1].size() == 2){ // if data are paired_end
[
"index": it[0],
"group": ref_order(it),
"ip": it[2],
"type": it[3],
"id": read_order(it)[0],
"file": read_order(it)
]
} else {
[
"index": it[0],
"group": it[1].simpleName,
"ip": it[2],
"type": it[3],
"id": it[4].simpleName,
"file": [it[4].simpleName, it[4]]
]
}
}
.set{input_csv}
} else {
log.info "loading remotes SRA csv files"
Channel
.fromPath(params.csv_sra, checkIfExists: true)
.ifEmpty { error
log.error """
=============================================================
WARNING! No csv input file precised.
Use '--csv_path <file.csv>' or
Use '--csv_SRA <file.csv>'
Or '--help' for more informations
=============================================================
"""
}
.splitCsv(header: true, sep: ";", strip: true)
.flatMap{
it -> [
[[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], t.IP_w, "IP", "w", it.IP_w],
[[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "WCE", "w", it.WCE_w],
[[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "IP", "m", it.IP_m],
[[it.IP_w + it.WCE_w + it.IP_m + it.WCE_m], it.IP_w, "WCE", "m", it.WCE_m]
]
}
.map{
it ->
if (it[1].size() == 2){ // if data are paired_end
[
"index": (
it[0][0][0].simpleName +
it[0][0][1].simpleName +
it[0][0][2].simpleName +
it[0][0][3].simpleName
).md5(),
"group": it[1][0].simpleName,
"ip": it[2],
"type": it[3],
"id": it[4][0].simpleName[0..-4],
"file": [it[4][0].simpleName[0..-4], it[4]]
]
} else {
[
"index": (
it[0][0].simpleName +
it[0][1].simpleName +
it[0][2].simpleName +
it[0][3].simpleName
).md5(),
"group": it[1].simpleName,
"ip": it[2],
"type": it[3],
"id": it[4].simpleName,
"file": [it[4].simpleName, it[4]]
]
}
}
.set{input_csv}
}
emit:
input_csv
}
workflow {
}