-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.nf
174 lines (156 loc) · 3.56 KB
/
main.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#! /usr/bin/env nextflow
params.config = false
params.term = false
process PUBMED_ID {
executor 'local'
maxForks 1
input: val(term)
output: path("${term}_pm.ids")
script:
"""
#! /usr/bin/env bash
pubmed_ids.sh ${term} > ${term}_pm.ids
sleep 11
[ -s ${term}_pm.ids ] || exit 1
"""
}
process PUBMED_XML {
maxForks 1
input: path(term_pmids)
output: path("${term_pmids.simpleName}.xml")
script:
"""
#! /usr/bin/env bash
pubmed_xml.sh ${term_pmids} > ${term_pmids.simpleName}.xml
sleep 13
[ -s ${term_pmids.simpleName}.xml ] || exit 1
"""
}
process AUTHOR_PM {
input: path(term_xml)
output: path("${term_xml.simpleName}_authors.tsv")
script:
"""
#! /usr/bin/env bash
authorlist_pm.pl ${term_xml} > ${term_xml.simpleName}_authors.tsv
"""
}
process PAPER_PM {
input: path(term_xml)
output: path("${term_xml.simpleName}_papers.tsv")
script:
"""
#! /usr/bin/env bash
paperlist_pm.pl ${term_xml} > ${term_xml.simpleName}_papers.tsv
"""
}
process PUBMED_QC {
input: path(term_xml)
output: path("${term_xml.simpleName}_qc.html")
script:
"""
#! /usr/bin/env bash
TERM=`echo ${term_xml.simpleName} | sed 's/_pm//' | sed 's/+/ /g'`
pubmed_text_analyzer2.pl "\$TERM" ${term_xml} > ${term_xml.simpleName}_qc.html
"""
}
process PUBMED_PLOT {
input: path(papers_tsv)
output: path("${papers_tsv.simpleName}.png")
script:
"""
#! /usr/bin/env bash
mkBarchart.R ${papers_tsv} ${papers_tsv.simpleName}.png
"""
}
process PMC_ID {
maxForks 1
input: val(term)
output: path("${term}_pmc.ids")
script:
"""
#! /usr/bin/env bash
pmc_ids.sh ${term} > ${term}_pmc.ids
sleep 17
[ -s ${term}_pmc.ids ] || exit 1
"""
}
process PMC_XML {
maxForks 1
input: path(term_pmcids)
output: path("${term_pmcids.simpleName}.xml")
script:
"""
#! /usr/bin/env bash
pmc_xml.sh ${term_pmcids} > ${term_pmcids.simpleName}.xml
sleep 19
[ -s ${term_pmcids.simpleName}.xml ] || exit 1
"""
}
process PMC_AUTHOR_PAPER {
input: path(term_xml)
output: tuple path("${term_xml.simpleName}_authors.tsv"), path("${term_xml.simpleName}_papers.tsv")
script:
"""
#! /usr/bin/env bash
TERM=`echo ${term_xml.simpleName} | sed 's/_pmc//'`
bothlist_pmc.pl \$TERM ${term_xml.simpleName}_papers.tsv ${term_xml.simpleName}_authors.tsv ${term_xml}
"""
}
process PMC_QC {
input: path(term_xml)
output: path("${term_xml.simpleName}_qc.html")
script:
"""
#! /usr/bin/env bash
TERM=`echo ${term_xml.simpleName} | sed 's/_pmc//'`
pubmed_fulltext_analyzer_v4.pl "\$TERM" ${term_xml} > ${term_xml.simpleName}_qc.html
"""
}
process PM_GEL_CODE {
input: val(terms)
output: path("pubmed.gel")
script:
"""
echo $terms | sed 's/\\[//g' | sed 's/\\]//g' | tr ' ' '\n' > config.txt
generateGel.sh > pubmed.gel
"""
}
process PMC_GEL_CODE {
input: val(terms)
output: path("pmc.gel")
script:
"""
echo $terms | sed 's/\\[//g' | sed 's/\\]//g' | tr ' ' '\n' > config.txt
generatePMCGel.sh > pmc.gel
"""
}
workflow {
if (params.term) {
term_ch = Channel.from(params.term)
| view { "=== $it" }
} else {
term_ch = Channel.fromPath("$params.config", checkIfExists: true)
| splitCsv(header: false)
| map { it -> it[0]}
| view { "=== $it" }
}
/* PubMed */
term_ch
| PUBMED_ID
| PUBMED_XML
| ( AUTHOR_PM & PAPER_PM & PUBMED_QC )
/* PubMed Central */
term_ch
| PMC_ID
| PMC_XML
| ( PMC_AUTHOR_PAPER & PMC_QC )
PAPER_PM.out
| concat(PMC_AUTHOR_PAPER.out | map { n -> n.get(1)})
| PUBMED_PLOT
| view
term_ch
| collect
| view
| (PM_GEL_CODE & PMC_GEL_CODE)
}