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