[63] | 1 | /** |
---|
| 2 | * |
---|
| 3 | * @author ademcan |
---|
| 4 | */ |
---|
[184] | 5 | |
---|
| 6 | import dbnp.studycapturing.* |
---|
| 7 | import dbnp.data.Term |
---|
| 8 | |
---|
[63] | 9 | class LoadController { |
---|
| 10 | |
---|
| 11 | String path; |
---|
| 12 | String delim; |
---|
| 13 | static Map att_list = new HashMap<String, ArrayList>(); |
---|
| 14 | |
---|
| 15 | def index = {} |
---|
| 16 | |
---|
[72] | 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 | |
---|
[63] | 25 | def load = { |
---|
| 26 | |
---|
[70] | 27 | //ArrayList attributes = new ArrayList(); |
---|
[63] | 28 | |
---|
[72] | 29 | render("Loading ...<br>"); |
---|
[63] | 30 | |
---|
[65] | 31 | InputStream inputStream = request.getFile("uploadfile").inputStream; |
---|
| 32 | BufferedReader fileReader = new BufferedReader(new InputStreamReader(inputStream)); |
---|
[63] | 33 | |
---|
[184] | 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(); |
---|
[70] | 39 | //def termSource = new dbnp.transcriptomics.magetab.adf.Termsource(); |
---|
[184] | 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(); |
---|
[63] | 43 | |
---|
[70] | 44 | //ArrayList rows = new ArrayList(); |
---|
[63] | 45 | |
---|
[184] | 46 | // TODO: remap to dbnp studycapturing data model + extra template fields for MIAMI studies |
---|
| 47 | |
---|
[65] | 48 | for (i in fileReader.readLines()){ |
---|
[83] | 49 | //render(i); |
---|
[63] | 50 | String line = i.toString() ; |
---|
| 51 | ArrayList tmp_list = new ArrayList(); |
---|
[65] | 52 | def parsedTab = line.split("\t"); |
---|
[63] | 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"){ |
---|
[64] | 60 | investigationDesign.title = tmp_list[1]; |
---|
[63] | 61 | } |
---|
[64] | 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 | } |
---|
[63] | 77 | else if (tmp_list[0]=="Experimental Design") { |
---|
[64] | 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; |
---|
[63] | 83 | } |
---|
[64] | 84 | else if (tmp_list[0]=="Experimental Design Term Source REF") { |
---|
[72] | 85 | String value = get_string(tmp_list); |
---|
| 86 | experimentalInfo.design_term_source_ref = value; |
---|
[83] | 87 | //render("value : " + value ); |
---|
[72] | 88 | println("value : "+value); |
---|
[63] | 89 | } |
---|
| 90 | else if (tmp_list[0]=="Experimental Factor Name") { |
---|
[64] | 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 | } |
---|
[83] | 95 | factor.name = factor_name; |
---|
[63] | 96 | } |
---|
[83] | 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 | //} |
---|
[63] | 104 | else if (tmp_list[0]=="Experimental Factor Term Source REF") { |
---|
[72] | 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; |
---|
[63] | 110 | } |
---|
| 111 | else if (tmp_list[0]=="Person Last Name") { |
---|
[83] | 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; |
---|
[63] | 117 | } |
---|
| 118 | else if (tmp_list[0]=="Person First Name") { |
---|
[83] | 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; |
---|
[63] | 124 | } |
---|
| 125 | else if (tmp_list[0]=="Person Mid Initials") { |
---|
[83] | 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; |
---|
[63] | 131 | } |
---|
| 132 | else if (tmp_list[0]=="Person Email") { |
---|
[83] | 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; |
---|
[63] | 138 | } |
---|
| 139 | else if (tmp_list[0]=="Person Phone") { |
---|
[83] | 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; |
---|
[63] | 145 | } |
---|
| 146 | else if (tmp_list[0]=="Person Fax") { |
---|
[83] | 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; |
---|
[63] | 152 | } |
---|
| 153 | else if (tmp_list[0]=="Person Address") { |
---|
[83] | 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; |
---|
[63] | 159 | } |
---|
| 160 | else if (tmp_list[0]=="Person Affiliation") { |
---|
[83] | 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; |
---|
[63] | 166 | } |
---|
| 167 | else if (tmp_list[0]=="Person Roles") { |
---|
[83] | 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; |
---|
[63] | 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") { |
---|
[64] | 190 | normalization.type = tmp_list[1]; |
---|
[63] | 191 | } |
---|
| 192 | else if (tmp_list[0]=="Normalization Term Source REF") { |
---|
[64] | 193 | normalization.term_source_ref = tmp_list[1]; |
---|
[63] | 194 | } |
---|
| 195 | else if (tmp_list[0]=="Date Of Experiment") { |
---|
[64] | 196 | investigationDesign.dateOfExperiment = tmp_list[1]; |
---|
[63] | 197 | } |
---|
| 198 | else if (tmp_list[0]=="Public Release Date") { |
---|
[64] | 199 | investigationDesign.publicReleaseDate = tmp_list[1]; |
---|
[63] | 200 | } |
---|
| 201 | else if (tmp_list[0]=="PubMed ID") { |
---|
| 202 | publication.pubMedID = tmp_list[1]; |
---|
| 203 | } |
---|
| 204 | else if (tmp_list[0]=="Publication DOI") { |
---|
[83] | 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; |
---|
[63] | 210 | } |
---|
| 211 | else if (tmp_list[0]=="Publication Author List") { |
---|
[64] | 212 | publication.authors_list = tmp_list[1]; |
---|
[63] | 213 | } |
---|
| 214 | else if (tmp_list[0]=="Publication Title") { |
---|
[83] | 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; |
---|
[63] | 220 | } |
---|
| 221 | else if (tmp_list[0]=="Publication Status") { |
---|
[184] | 222 | def status = new Term(); |
---|
[64] | 223 | status.text = tmp_list[1]; |
---|
| 224 | status.save(); |
---|
| 225 | publication.status = status; |
---|
[63] | 226 | } |
---|
| 227 | else if (tmp_list[0]=="Publication Status Term Source REF") { |
---|
[64] | 228 | publication.status_term_source_ref = tmp_list[1]; |
---|
[63] | 229 | } |
---|
| 230 | else if (tmp_list[0]=="Experiment Description") { |
---|
[64] | 231 | investigationDesign.experimentDescription = tmp_list[1]; |
---|
[63] | 232 | } |
---|
| 233 | else if (tmp_list[0]=="Protocol Name") { |
---|
[72] | 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; |
---|
[63] | 239 | } |
---|
[72] | 240 | //todo list of type |
---|
[63] | 241 | else if (tmp_list[0]=="Protocol Type") { |
---|
[184] | 242 | def type = new Term(); |
---|
[64] | 243 | for (j in 1..tmp_list.size()){ |
---|
| 244 | type.text = tmp_list[j]; |
---|
| 245 | type.save(); |
---|
| 246 | } |
---|
| 247 | protocol.type = type; |
---|
[63] | 248 | } |
---|
| 249 | else if (tmp_list[0]=="Protocol Description") { |
---|
[72] | 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; |
---|
[63] | 255 | } |
---|
| 256 | else if (tmp_list[0]=="Protocol Parameters") { |
---|
[72] | 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; |
---|
[63] | 262 | } |
---|
| 263 | else if (tmp_list[0]=="Protocol Hardware") { |
---|
[83] | 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; |
---|
[63] | 269 | } |
---|
| 270 | else if (tmp_list[0]=="Protocol Software") { |
---|
[83] | 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; |
---|
[63] | 276 | } |
---|
| 277 | else if (tmp_list[0]=="Protocol Contact") { |
---|
[83] | 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; |
---|
[63] | 283 | } |
---|
| 284 | else if (tmp_list[0]=="Protocol Term Source REF") { |
---|
[64] | 285 | protocol.term_source_ref = tmp_list[1]; |
---|
[63] | 286 | } |
---|
| 287 | else if (tmp_list[0]=="SDRF File") { |
---|
[83] | 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; |
---|
[63] | 293 | } |
---|
| 294 | else if (tmp_list[0]=="Term Source Name") { |
---|
[64] | 295 | //termSource.name = tmp_list[1]; |
---|
[63] | 296 | } |
---|
| 297 | else if (tmp_list[0]=="Term Source File") { |
---|
[64] | 298 | //termSource.file = tmp_list[1]; |
---|
[63] | 299 | } |
---|
| 300 | else if (tmp_list[0]=="Term Source Version") { |
---|
[64] | 301 | //termSource.version = tmp_list[1]; |
---|
[63] | 302 | } |
---|
| 303 | } |
---|
| 304 | |
---|
| 305 | person.save(); |
---|
| 306 | protocol.save(); |
---|
| 307 | publication.save(); |
---|
[64] | 308 | normalization.save(); |
---|
| 309 | investigationDesign.save(); |
---|
| 310 | comment.save(); |
---|
| 311 | experimentalInfo.save(); |
---|
[83] | 312 | //factor.save(); |
---|
[64] | 313 | //termSource.save(); |
---|
[63] | 314 | } |
---|
| 315 | } |
---|
| 316 | } |
---|
| 317 | |
---|