1 | /** |
---|
2 | * 888 888 888 888 8888888888 8888888b. 8888888888 |
---|
3 | * 888 o 888 888 888 888 888 Y88b 888 |
---|
4 | * 888 d8b 888 888 888 888 888 888 888 |
---|
5 | * 888 d888b 888 8888888888 8888888 888 d88P 8888888 |
---|
6 | * 888d88888b888 888 888 888 8888888P" 888 |
---|
7 | * 88888P Y88888 888 888 888 888 T88b 888 |
---|
8 | * 8888P Y8888 888 888 888 888 T88b 888 |
---|
9 | * 888P Y888 888 888 8888888888 888 T88b 8888888888 |
---|
10 | * |
---|
11 | * 8888888 .d8888b. 88888888888 888 888 8888888888 |
---|
12 | * 888 d88P Y88b 888 888 888 888 |
---|
13 | * 888 Y88b. 888 888 888 888 |
---|
14 | * 888 "Y888b. 888 8888888888 8888888 |
---|
15 | * 888 "Y88b. 888 888 888 888 |
---|
16 | * 888 "888 888 888 888 888 |
---|
17 | * 888 Y88b d88P 888 888 888 888 |
---|
18 | * 8888888 "Y8888P" 888 888 888 8888888888 |
---|
19 | * |
---|
20 | * 888888 d8888 888 888 d8888 8888888b. .d88888b. .d8888b. |
---|
21 | * "88b d88888 888 888 d88888 888 "Y88b d88P" "Y88b d88P Y88b |
---|
22 | * 888 d88P888 888 888 d88P888 888 888 888 888 888 888 |
---|
23 | * 888 d88P 888 Y88b d88P d88P 888 888 888 888 888 888 |
---|
24 | * 888 d88P 888 Y88b d88P d88P 888 888 888 888 888 888 |
---|
25 | * 888 d88P 888 Y88o88P d88P 888 888 888 888 888 888 888 |
---|
26 | * 88P d8888888888 Y888P d8888888888 888 .d88P Y88b. .d88P Y88b d88P |
---|
27 | * 888 d88P 888 Y8P d88P 888 8888888P" "Y88888P" "Y8888P" |
---|
28 | * .d88P |
---|
29 | * .d88P" |
---|
30 | * 888P" |
---|
31 | * |
---|
32 | * .d8888b. 888 .d8888b. 888 .d8888b. 888 |
---|
33 | * d88P Y88b 888 d88P Y88b 888 d88P Y88b 888 |
---|
34 | * .d88P 888 .d88P 888 .d88P 888 |
---|
35 | * .d88P" 888 .d88P" 888 .d88P" 888 |
---|
36 | * 888" 888 888" 888 888" 888 |
---|
37 | * 888 Y8P 888 Y8P 888 Y8P |
---|
38 | * " " " |
---|
39 | * 888 888 888 888 888 888 |
---|
40 | * |
---|
41 | * |
---|
42 | * TODO: add PROPER class and method documentation, just like have |
---|
43 | * agreed upon hundreds of times!!!! |
---|
44 | */ |
---|
45 | |
---|
46 | import dbnp.studycapturing.* |
---|
47 | import dbnp.data.Term |
---|
48 | |
---|
49 | class LoadController { |
---|
50 | |
---|
51 | String path; |
---|
52 | String delim; |
---|
53 | static Map att_list = new HashMap<String, ArrayList>(); |
---|
54 | |
---|
55 | def index = {} |
---|
56 | |
---|
57 | def get_string(ArrayList tmp_list) { |
---|
58 | String value = tmp_list[1]; |
---|
59 | for (a in 2..tmp_list.size()-1){ |
---|
60 | value = value + " , " +tmp_list[a]; |
---|
61 | } |
---|
62 | return value; |
---|
63 | } |
---|
64 | |
---|
65 | def load = { |
---|
66 | |
---|
67 | //ArrayList attributes = new ArrayList(); |
---|
68 | |
---|
69 | render("Loading ...<br>"); |
---|
70 | |
---|
71 | InputStream inputStream = request.getFile("uploadfile").inputStream; |
---|
72 | BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream)); |
---|
73 | |
---|
74 | def study = new Study(); |
---|
75 | def person = new Person(); |
---|
76 | //def protocol = new dbnp.transcriptomics.magetab.idf.MAGEProtocol(); |
---|
77 | def publication = Publication(); |
---|
78 | //def normalization = new dbnp.transcriptomics.magetab.sdrf.Normalization(); |
---|
79 | //def termSource = new dbnp.transcriptomics.magetab.adf.Termsource(); |
---|
80 | //def comment = new dbnp.transcriptomics.magetab.idf.Comment(); |
---|
81 | //def experimentalInfo = new dbnp.transcriptomics.magetab.idf.ExperimentalInfo(); |
---|
82 | //def factor = new dbnp.transcriptomics.magetab.idf.Factor(); |
---|
83 | |
---|
84 | //ArrayList rows = new ArrayList(); |
---|
85 | |
---|
86 | // TODO: remap to dbnp studycapturing data model + extra template fields for MIAMI studies |
---|
87 | |
---|
88 | for (i in fileReader.readLines()){ |
---|
89 | //render(i); |
---|
90 | String line = i.toString() ; |
---|
91 | ArrayList tmp_list = new ArrayList(); |
---|
92 | def parsedTab = line.split("\t"); |
---|
93 | |
---|
94 | for (j in parsedTab) { |
---|
95 | tmp_list.add(j); |
---|
96 | } |
---|
97 | |
---|
98 | if (tmp_list.size() > 1){ |
---|
99 | if (tmp_list[0]=="Investigation Title"){ |
---|
100 | investigationDesign.title = tmp_list[1]; |
---|
101 | } |
---|
102 | else if (tmp_list[0]=="Comment[AEMIAMESCORE]") { |
---|
103 | comment.aemiameScore = tmp_list[1]; |
---|
104 | } |
---|
105 | else if (tmp_list[0]=="Comment[SecondaryAccession]") { |
---|
106 | comment.secondaryAccession = tmp_list[1]; |
---|
107 | } |
---|
108 | else if (tmp_list[0]=="Comment[ArrayExpressReleaseDate]") { |
---|
109 | comment.arrayExpressReleaseDate = tmp_list[1]; |
---|
110 | } |
---|
111 | else if (tmp_list[0]=="Comment[ArrayExpressAccession]") { |
---|
112 | comment.arrayExpressAccession = tmp_list[1]; |
---|
113 | } |
---|
114 | else if (tmp_list[0]=="Comment[MAGETAB TimeStamp_Version]") { |
---|
115 | comment.timestamp_version = tmp_list[1]; |
---|
116 | } |
---|
117 | else if (tmp_list[0]=="Experimental Design") { |
---|
118 | String design = tmp_list[1]; |
---|
119 | for (a in 2..tmp_list.size()-1){ |
---|
120 | design = design + " , " +tmp_list[a]; |
---|
121 | } |
---|
122 | experimentalInfo.design = design; |
---|
123 | } |
---|
124 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
125 | String value = get_string(tmp_list); |
---|
126 | experimentalInfo.design_term_source_ref = value; |
---|
127 | //render("value : " + value ); |
---|
128 | println("value : "+value); |
---|
129 | } |
---|
130 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
131 | String factor_name = tmp_list[1]; |
---|
132 | for (a in 2..tmp_list.size()-1){ |
---|
133 | factor_name = factor_name + " , " +tmp_list[a]; |
---|
134 | } |
---|
135 | factor.name = factor_name; |
---|
136 | } |
---|
137 | //else if (tmp_list[0]=="Experimental Factor Type") { |
---|
138 | // String factor_type = tmp_list[1]; |
---|
139 | // for (a in 2..tmp_list.size()-1){ |
---|
140 | // factor_type = factor_type + " , " +tmp_list[a]; |
---|
141 | // } |
---|
142 | // factor.type = factor_type; |
---|
143 | //} |
---|
144 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
145 | String exp_ref = tmp_list[1]; |
---|
146 | for (a in 2..tmp_list.size()-1){ |
---|
147 | exp_ref = exp_ref + " , " +tmp_list[a]; |
---|
148 | } |
---|
149 | experimentalInfo.factor_term_source_ref = exp_ref; |
---|
150 | } |
---|
151 | else if (tmp_list[0]=="Person Last Name") { |
---|
152 | String last_name = tmp_list[1]; |
---|
153 | for (a in 2..tmp_list.size()-1){ |
---|
154 | last_name = last_name + " , " +tmp_list[a]; |
---|
155 | } |
---|
156 | person.lastName = last_name; |
---|
157 | } |
---|
158 | else if (tmp_list[0]=="Person First Name") { |
---|
159 | String first_name = tmp_list[1]; |
---|
160 | for (a in 2..tmp_list.size()-1){ |
---|
161 | first_name = first_name + " , " +tmp_list[a]; |
---|
162 | } |
---|
163 | person.firstName = first_name; |
---|
164 | } |
---|
165 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
166 | String mid_initials = tmp_list[1]; |
---|
167 | for (a in 2..tmp_list.size()-1){ |
---|
168 | mid_initials = mid_initials + " , " +tmp_list[a]; |
---|
169 | } |
---|
170 | person.midInitials = mid_initials; |
---|
171 | } |
---|
172 | else if (tmp_list[0]=="Person Email") { |
---|
173 | String pemail = tmp_list[1]; |
---|
174 | for (a in 2..tmp_list.size()-1){ |
---|
175 | pemail = pemail + " , " +tmp_list[a]; |
---|
176 | } |
---|
177 | person.email = pemail; |
---|
178 | } |
---|
179 | else if (tmp_list[0]=="Person Phone") { |
---|
180 | String pphone = tmp_list[1]; |
---|
181 | for (a in 2..tmp_list.size()-1){ |
---|
182 | pphone = pphone + " , " +tmp_list[a]; |
---|
183 | } |
---|
184 | person.phone = pphone; |
---|
185 | } |
---|
186 | else if (tmp_list[0]=="Person Fax") { |
---|
187 | String pfax = tmp_list[1]; |
---|
188 | for (a in 2..tmp_list.size()-1){ |
---|
189 | pfax = pfax + " , " +tmp_list[a]; |
---|
190 | } |
---|
191 | person.fax = pfax; |
---|
192 | } |
---|
193 | else if (tmp_list[0]=="Person Address") { |
---|
194 | String paddress = tmp_list[1]; |
---|
195 | for (a in 2..tmp_list.size()-1){ |
---|
196 | paddress = paddress + " , " +tmp_list[a]; |
---|
197 | } |
---|
198 | person.address = paddress; |
---|
199 | } |
---|
200 | else if (tmp_list[0]=="Person Affiliation") { |
---|
201 | String paffiliation = tmp_list[1]; |
---|
202 | for (a in 2..tmp_list.size()-1){ |
---|
203 | paffiliation = paffiliation + " , " +tmp_list[a]; |
---|
204 | } |
---|
205 | person.affiliation = paffiliation; |
---|
206 | } |
---|
207 | else if (tmp_list[0]=="Person Roles") { |
---|
208 | String proles = tmp_list[1]; |
---|
209 | for (a in 2..tmp_list.size()-1){ |
---|
210 | proles = proles + " , " +tmp_list[a]; |
---|
211 | } |
---|
212 | person.roles = proles; |
---|
213 | } |
---|
214 | else if (tmp_list[0]=="Person Roles Term Source REF") { |
---|
215 | person.roles_ref = tmp_list[1]; |
---|
216 | } |
---|
217 | else if (tmp_list[0]=="Quality Control Type") { |
---|
218 | |
---|
219 | } |
---|
220 | else if (tmp_list[0]=="Quality Control Term Source REF") { |
---|
221 | |
---|
222 | } |
---|
223 | else if (tmp_list[0]=="Replicate Type") { |
---|
224 | |
---|
225 | } |
---|
226 | else if (tmp_list[0]=="Replicate Term Source REF") { |
---|
227 | |
---|
228 | } |
---|
229 | else if (tmp_list[0]=="Normalization Type") { |
---|
230 | normalization.type = tmp_list[1]; |
---|
231 | } |
---|
232 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
233 | normalization.term_source_ref = tmp_list[1]; |
---|
234 | } |
---|
235 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
236 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
237 | } |
---|
238 | else if (tmp_list[0]=="Public Release Date") { |
---|
239 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
240 | } |
---|
241 | else if (tmp_list[0]=="PubMed ID") { |
---|
242 | publication.pubMedID = tmp_list[1]; |
---|
243 | } |
---|
244 | else if (tmp_list[0]=="Publication DOI") { |
---|
245 | String doi = tmp_list[1]; |
---|
246 | for (a in 2..tmp_list.size()-1){ |
---|
247 | doi = doi + " , " +tmp_list[a]; |
---|
248 | } |
---|
249 | publication.DOI = doi; |
---|
250 | } |
---|
251 | else if (tmp_list[0]=="Publication Author List") { |
---|
252 | publication.authors_list = tmp_list[1]; |
---|
253 | } |
---|
254 | else if (tmp_list[0]=="Publication Title") { |
---|
255 | String pubTitle = tmp_list[1]; |
---|
256 | for (a in 2..tmp_list.size()-1){ |
---|
257 | pubTitle = pubTitle + " , " +tmp_list[a]; |
---|
258 | } |
---|
259 | publication.title = pubTitle; |
---|
260 | } |
---|
261 | else if (tmp_list[0]=="Publication Status") { |
---|
262 | def status = new Term(); |
---|
263 | status.text = tmp_list[1]; |
---|
264 | status.save(); |
---|
265 | publication.status = status; |
---|
266 | } |
---|
267 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
268 | publication.status_term_source_ref = tmp_list[1]; |
---|
269 | } |
---|
270 | else if (tmp_list[0]=="Experiment Description") { |
---|
271 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
272 | } |
---|
273 | else if (tmp_list[0]=="Protocol Name") { |
---|
274 | String protocol_name = tmp_list[1]; |
---|
275 | for (a in 2..tmp_list.size()-1){ |
---|
276 | protocol_name = protocol_name + " , " +tmp_list[a]; |
---|
277 | } |
---|
278 | protocol.name = protocol_name; |
---|
279 | } |
---|
280 | //todo list of type |
---|
281 | else if (tmp_list[0]=="Protocol Type") { |
---|
282 | def type = new Term(); |
---|
283 | for (j in 1..tmp_list.size()){ |
---|
284 | type.text = tmp_list[j]; |
---|
285 | type.save(); |
---|
286 | } |
---|
287 | protocol.type = type; |
---|
288 | } |
---|
289 | else if (tmp_list[0]=="Protocol Description") { |
---|
290 | String protocol_description = tmp_list[1]; |
---|
291 | for (a in 2..tmp_list.size()-1){ |
---|
292 | protocol_description = protocol_description + " , " +tmp_list[a]; |
---|
293 | } |
---|
294 | protocol.description = protocol_description; |
---|
295 | } |
---|
296 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
297 | String protocol_parameters = tmp_list[1]; |
---|
298 | for (a in 2..tmp_list.size()-1){ |
---|
299 | protocol_parameters = protocol_parameters + " , " +tmp_list[a]; |
---|
300 | } |
---|
301 | protocol.parameters = protocol_parameters; |
---|
302 | } |
---|
303 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
304 | String phardware = tmp_list[1]; |
---|
305 | for (a in 2..tmp_list.size()-1){ |
---|
306 | phardware = phardware + " , " +tmp_list[a]; |
---|
307 | } |
---|
308 | protocol.hardware = phardware; |
---|
309 | } |
---|
310 | else if (tmp_list[0]=="Protocol Software") { |
---|
311 | String psoftware = tmp_list[1]; |
---|
312 | for (a in 2..tmp_list.size()-1){ |
---|
313 | psoftware = psoftware + " , " +tmp_list[a]; |
---|
314 | } |
---|
315 | protocol.software = psoftware; |
---|
316 | } |
---|
317 | else if (tmp_list[0]=="Protocol Contact") { |
---|
318 | String pcontact = tmp_list[1]; |
---|
319 | for (a in 2..tmp_list.size()-1){ |
---|
320 | pcontact = pcontact + " , " +tmp_list[a]; |
---|
321 | } |
---|
322 | protocol.contact = pcontact; |
---|
323 | } |
---|
324 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
325 | protocol.term_source_ref = tmp_list[1]; |
---|
326 | } |
---|
327 | else if (tmp_list[0]=="SDRF File") { |
---|
328 | String sdrf = tmp_list[1]; |
---|
329 | for (a in 2..tmp_list.size()-1){ |
---|
330 | sdrf = sdrf + " , " +tmp_list[a]; |
---|
331 | } |
---|
332 | investigationDesign.sdrf_file = sdrf; |
---|
333 | } |
---|
334 | else if (tmp_list[0]=="Term Source Name") { |
---|
335 | //termSource.name = tmp_list[1]; |
---|
336 | } |
---|
337 | else if (tmp_list[0]=="Term Source File") { |
---|
338 | //termSource.file = tmp_list[1]; |
---|
339 | } |
---|
340 | else if (tmp_list[0]=="Term Source Version") { |
---|
341 | //termSource.version = tmp_list[1]; |
---|
342 | } |
---|
343 | } |
---|
344 | |
---|
345 | person.save(); |
---|
346 | protocol.save(); |
---|
347 | publication.save(); |
---|
348 | normalization.save(); |
---|
349 | investigationDesign.save(); |
---|
350 | comment.save(); |
---|
351 | experimentalInfo.save(); |
---|
352 | //factor.save(); |
---|
353 | //termSource.save(); |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | |
---|