Changeset 1966
- Timestamp:
- May 8, 2013, 9:36:48 AM (9 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/sampleproc/rnaqc_plate_import.jsp
r1915 r1966 60 60 if (lastExtension == 'csv') 61 61 { 62 preValidateCsvFile();62 setTimeout(preValidateCsvFile, 100); 63 63 } 64 64 else … … 76 76 if (!csvId) return; 77 77 78 Main.hide('messages'); 79 Main.addClass(document.body, 'please-wait'); 80 setInputStatus('csv', 'Checking...', 'checking'); 81 78 82 var url = '../RnaQc.servlet?ID=<%=ID%>&cmd=PreValidateCaliperResults&csv='+csvId; 79 83 80 84 var request = Ajax.getXmlHttpRequest(); 81 request.open("POST", url, false); 85 Ajax.setReadyStateHandler(request, onCsvValidated); 86 request.open("POST", url, true); 82 87 request.send(''); 83 88 89 } 90 91 function onCsvValidated(request) 92 { 93 Main.removeClass(document.body, 'please-wait'); 84 94 if (debug) Main.debug(request.responseText); 85 95 var response = JSON.parse(request.responseText); 86 96 97 var numWarnings = 0; 87 98 if (response.messages && response.messages.length > 0) 88 99 { … … 90 101 for (var i = 0; i < response.messages.length; i++) 91 102 { 92 messages += '<li>' + response.messages[i]; 103 var msgLine = response.messages[i]; 104 if (msgLine.indexOf('[Warning]') >= 0) 105 { 106 messages += '<li class="warning">' + msgLine.replace('[Warning]', ''); 107 numWarnings++; 108 } 109 else 110 { 111 messages += '<li>' + msgLine; 112 } 93 113 } 94 114 messages += '</ul>'; … … 110 130 } 111 131 112 setInputStatus('csv', '', 'valid');132 setInputStatus('csv', '', numWarnings > 0 ? 'warning' : 'valid'); 113 133 hasValidatedCsv = true; 114 134 … … 167 187 168 188 Main.hide('goimport'); 189 Main.hide('messages'); 169 190 170 191 frm['csv.path'].disabled = true; … … 268 289 </script> 269 290 291 <style> 292 body.please-wait 293 { 294 cursor: wait !important; 295 } 296 </style> 270 297 271 298 </base:head> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/CaliperPlateImporter.java
r1963 r1966 159 159 } 160 160 161 public boolean doPreValidate(DbControl dc, InputStream in, int maxDataLines)162 throws IOException163 {164 errorMessages.clear();165 166 FlatFileParser ffp = getFlatFileParser();167 ffp.setInputStream(in, "UTF-8");168 169 if (ffp.parseHeaders() != LineType.DATA_HEADER)170 {171 addErrorMessage("Could not find header line starting with 'Plate Name,Well Label,Sample Name...'");172 return false; // Can't continue if no data is found in the file173 }174 175 // Check that all annotation columns are found176 for (String col : annotations.keySet())177 {178 if (ffp.getColumnHeaderIndex(col) == null)179 {180 addErrorMessage("Column '" + col + "' not found in column headers.");181 }182 }183 184 if (hasError()) return false;185 186 Mapper plateMapper = ffp.getMapper("\\Plate Name\\");187 Mapper wellMapper = ffp.getMapper("\\Well Label\\");188 Mapper nameMapper = ffp.getMapper("\\Sample Name\\");189 Map<String,Integer> locations = new HashMap<String, Integer>();190 191 int numExtractsByName = 0;192 int numExtractsByLocation = 0;193 194 while (ffp.hasMoreData() && (maxDataLines == -1 || maxDataLines > ffp.getParsedDataLines()))195 {196 boolean errorOnThisLine = false;197 FlatFileParser.Data data = ffp.nextData();198 int lineNo = ffp.getParsedLines();199 200 // Check that the "Plate Name" is a valid entry201 String plateName = plateMapper.getValue(data);202 if (plate == null)203 {204 plate = findBioPlate(dc, plateName, lineNo);205 if (plate == null) errorOnThisLine = true;206 }207 else208 {209 if (!checkBioPlate(dc, plateName, plate, lineNo))210 {211 errorOnThisLine = true;212 }213 }214 215 if (errorOnThisLine) break; // stop validation216 217 // Check that the "Sample Name" column maps to a valid extract218 String extractName = nameMapper.getValue(data);219 String location = wellMapper.getValue(data);220 221 Extract extract = null;222 if (allowMatchAgainstLocation && extractName.matches("\\w\\d\\d?"))223 {224 extract = findExtractByLocation(dc, plate, extractName, lineNo);225 if (extract != null)226 {227 numExtractsByLocation++;228 addWarningMessage("[Warning] Line " + lineNo + ": No sample name, extract '" + extract.getName() + "' found using location '" + extractName + "'");229 }230 }231 else232 {233 extract = findExtractByName(dc, plate, extractName, lineNo, location);234 if (extract != null) numExtractsByName++;235 }236 237 if (extract == null) continue; // with the next line238 239 // Validate that the location is the same in BASE and the CSV240 if (!checkLocation(dc, extract, location, lineNo)) continue; // with the next line241 242 // Check that the same location has not been seen before in this file243 if (locations.containsKey(location))244 {245 addErrorMessage("Line " + lineNo + ": Duplicate well '" + location + "' with extract '" + extractName + "'. Also found on line " + locations.get(location) + ".");246 continue; // with the next line247 }248 locations.put(location, lineNo);249 }250 251 if (numExtractsByLocation > numExtractsByName)252 {253 addErrorMessage("Too many lines have location instead of 'Sample name': " + numExtractsByLocation + " of " + (numExtractsByLocation+numExtractsByName));254 }255 return !hasError();256 }257 258 161 /** 259 162 Import data from the input stream. 260 163 @param in 261 164 */ 262 public boolean doImport(DbControl dc, InputStream in )165 public boolean doImport(DbControl dc, InputStream in, boolean validateOnly) 263 166 throws IOException 264 167 { 265 168 numImported = 0; 266 169 errorMessages.clear(); 170 warningMessages.clear(); 267 171 Map<String,Integer> locations = new HashMap<String, Integer>(); 268 172 … … 394 298 395 299 Object val = at.getValueType().parseString(sval); 396 as.getAnnotation(at).setValue(val); 300 if (!validateOnly) 301 { 302 as.getAnnotation(at).setValue(val); 303 } 397 304 398 305 // For debugging … … 423 330 } 424 331 425 if (val != null) as.getAnnotation(at).setValue(val); 332 if (!validateOnly) 333 { 334 if (val != null) as.getAnnotation(at).setValue(val); 335 } 426 336 427 337 // For debugging … … 441 351 if (numExtractsByLocation > numExtractsByName) 442 352 { 443 addErrorMessage("Too many lines have location instead of 'Sample name': " + numExtractsByLocation );353 addErrorMessage("Too many lines have location instead of 'Sample name': " + numExtractsByLocation + " of " + (numExtractsByLocation+numExtractsByName)); 444 354 } 445 355 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/LibPrepServlet.java
r1964 r1966 414 414 dc = sc.newDbControl(); 415 415 File csv = File.getById(dc, csvId); 416 AnnotationType size = Annotationtype.CA_SIZE.load(dc); 416 417 417 418 CaliperPlateImporter cpi = new CaliperPlateImporter(BioplateType.LIBRARY.getPlateNamePrefix()); 418 cpi.setAnnotationMapping("Region[180-600] Size [BP]", null); // safe to use 'null' when validating419 cpi.setAnnotationMapping("Region[180-600] Size [BP]", size); 419 420 cpi.setBioPlate(BioPlate.getById(dc, libPlateId)); 420 421 cpi.setAllowMatchAgainstLocation(true); // Allow a few lines to have location coordinates instead of lib name 421 if (cpi.do PreValidate(dc, csv.getDownloadStream(0), -1))422 if (cpi.doImport(dc, csv.getDownloadStream(0), true)) 422 423 { 423 424 // The validation was ok -- but there may be some warnings. … … 538 539 addQubitFileLookups(cpi, qubitCsv, qubitConcType, speedVacConcType); 539 540 540 if (cpi.doImport(dc, wellTableCsv.getDownloadStream(0) ))541 if (cpi.doImport(dc, wellTableCsv.getDownloadStream(0), false)) 541 542 { 542 543 // The import was successful -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/RnaQcServlet.java
r1963 r1966 367 367 dc = sc.newDbControl(); 368 368 File csv = File.getById(dc, csvId); 369 AnnotationType rqs = Annotationtype.CA_RQS.load(dc); 369 370 370 371 CaliperPlateImporter cpi = new CaliperPlateImporter(BioplateType.CALIPER_RNAQC.getPlateNamePrefix()); 371 cpi.setAnnotationMapping("RNA Quality Score", null); // safe to use 'null' when validating 372 373 if (cpi.doPreValidate(dc, csv.getDownloadStream(0), 5)) 374 { 372 cpi.setAnnotationMapping("RNA Quality Score", rqs); 373 cpi.setAllowMatchAgainstLocation(true); // Allow a few lines to have location coordinates instead of rnaqc name 374 375 if (cpi.doImport(dc, csv.getDownloadStream(0), true)) 376 { 377 // The validation was ok -- but there may be some warnings. 378 if (cpi.hasWarning()) 379 { 380 jsonMessages.addAll(cpi.getWarningMessages()); 381 } 382 375 383 // The validation was ok 376 384 BioPlate plate = cpi.getBioPlate(); … … 406 414 CaliperPlateImporter cpi = new CaliperPlateImporter(BioplateType.CALIPER_RNAQC.getPlateNamePrefix()); 407 415 cpi.setAnnotationMapping("RNA Quality Score", rqs); 408 409 if (cpi.doImport(dc, csv.getDownloadStream(0))) 416 cpi.setAllowMatchAgainstLocation(true); 417 418 if (cpi.doImport(dc, csv.getDownloadStream(0), false)) 410 419 { 411 420 // The import was successful
Note: See TracChangeset
for help on using the changeset viewer.