Changeset 1968
- Timestamp:
- May 8, 2013, 11:10:06 AM (9 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/libprep/lib_registration.jsp
r1963 r1968 258 258 { 259 259 qubitCsvFileOnChange(); 260 frm.libProtocol.focus();261 260 } 262 261 else … … 310 309 Main.addClass(document.body, 'please-wait'); 311 310 setInputStatus('welltable', 'Checking...', 'checking'); 312 var url = '../LibPrep.servlet?ID=<%=ID%>&cmd=PreValidateCaliperWellTable&csv='+csvId+'&bioplate='+frm.bioplate.value; 311 var qubitCsv = frm['qubitcsv.id'].value; 312 var url = '../LibPrep.servlet?ID=<%=ID%>&cmd=PreValidateCaliperWellTable&csv='+csvId+'&bioplate='+frm.bioplate.value+'&qubit='+qubitCsv; 313 313 314 314 var request = Ajax.getXmlHttpRequest(); … … 633 633 <td class="input"> 634 634 <input type="text" class="required" name="libDate" value="" size="12" maxlength="10" 635 onblur="libDateOnChange()" onkeypress="focusOnEnter(event, ' welltable.path')">635 onblur="libDateOnChange()" onkeypress="focusOnEnter(event, 'qubitcsv.path')"> 636 636 </td> 637 637 <td class="status" id="libDate.status"></td> … … 641 641 </tr> 642 642 <tbody id="filesSection"> 643 <tr> 644 <td class="prompt">Qubit files</td> 645 <td class="input"></td> 646 <td class="status"></td> 647 <td class="help"></td> 648 </tr> 649 <tr valign="top"> 650 <td class="subprompt">Conc. CSV</td> 651 <td class="input"> 652 <input type="hidden" name="qubitcsv.id" value=""> 653 <table> 654 <tr> 655 <td><input class="text required" type="text" 656 name="qubitcsv.path" value="" 657 size="50" onkeypress="doOnEnter(event, function(){document.getElementById('btnQubitCsv').click()})" 658 onblur="qubitCsvFileOnChange()" 659 ></td> 660 <td style="padding-left: 4px;"><base:button 661 title="Browse…" 662 onclick="browseOnClick('qubitcsv', 'csv')" 663 id="btnQubitCsv" 664 /> 665 </td> 666 </tr> 667 </table> 668 </td> 669 <td class="status" id="qubitcsv.status"></td> 670 <td class="help"><span id="qubitcsv.message" class="message" style="display: none;"></span> 671 Select the <b>Qubit CSV</b> file that contains the table with concentration 672 measurements. 673 </td> 674 </tr> 643 675 <tr> 644 676 <td class="prompt">Caliper files</td> … … 722 754 </td> 723 755 </tr> 724 <tr>725 <td class="prompt">Qubit files</td>726 <td class="input"></td>727 <td class="status"></td>728 <td class="help"></td>729 </tr>730 <tr valign="top">731 <td class="subprompt">Conc. CSV</td>732 <td class="input">733 <input type="hidden" name="qubitcsv.id" value="">734 <table>735 <tr>736 <td><input class="text required" type="text"737 name="qubitcsv.path" value=""738 size="50" onkeypress="doOnEnter(event, function(){document.getElementById('btnQubitCsv').click()})"739 onblur="qubitCsvFileOnChange()"740 ></td>741 <td style="padding-left: 4px;"><base:button742 title="Browse…"743 onclick="browseOnClick('qubitcsv', 'csv')"744 id="btnQubitCsv"745 />746 </td>747 </tr>748 </table>749 </td>750 <td class="status" id="qubitcsv.status"></td>751 <td class="help"><span id="qubitcsv.message" class="message" style="display: none;"></span>752 Select the <b>Qubit CSV</b> file that contains the table with concentration753 measurements.754 </td>755 </tr>756 756 </tbody> 757 757 <tr valign="top"> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/LibPrepServlet.java
r1966 r1968 411 411 int csvId = Values.getInt(req.getParameter("csv")); 412 412 int libPlateId = Values.getInt(req.getParameter("bioplate")); 413 int qubitId = Values.getInt(req.getParameter("qubit")); 413 414 414 415 dc = sc.newDbControl(); … … 420 421 cpi.setBioPlate(BioPlate.getById(dc, libPlateId)); 421 422 cpi.setAllowMatchAgainstLocation(true); // Allow a few lines to have location coordinates instead of lib name 423 424 if (qubitId != 0) 425 { 426 AnnotationType qubitConcType = Annotationtype.QUBIT_CONC.load(dc); 427 AnnotationType speedVacConcType = Annotationtype.QUBIT_CONC_AFTER_SPEEDVAC.load(dc); 428 File qubitCsv = File.getById(dc, qubitId); 429 addQubitFileLookups(cpi, qubitCsv, qubitConcType, speedVacConcType); 430 } 431 422 432 if (cpi.doImport(dc, csv.getDownloadStream(0), true)) 423 433 { … … 631 641 // Parse the Qubit file and return a map extract name -> concentration 632 642 private void addQubitFileLookups(CaliperPlateImporter cpi, File qubitCsv, AnnotationType originalConcType, AnnotationType speedVacConcType) 633 throws IOException634 643 { 635 // Parse the Qubit file and store concentration before and after speedvac in two maps 636 FlatFileParser ffp = new FlatFileParser(); 637 ffp.setDataHeaderRegexp(Pattern.compile(".*Well.*Library name.*Qubit ng/ml.*After SpeedVac.*")); 638 ffp.setIgnoreRegexp(Pattern.compile("^\\\"?#.*")); // Ignore all lines starting with '#' ( or "#) 639 ffp.setDataSplitterRegexp(Pattern.compile("\t|,")); // Split on tab or comma 640 ffp.setInputStream(qubitCsv.getDownloadStream(0), "UTF-8"); 641 ffp.setTrimQuotes(true); 642 if (ffp.parseHeaders() != LineType.DATA_HEADER) 643 { 644 throw new InvalidDataException("File '" + qubitCsv.getName() + "': Could not find header line starting with 'Well{tab}Library name{tab}Qubit ng/ml...'"); 645 } 646 647 Mapper nameMapper = ffp.getMapper("\\Library name\\"); 648 Mapper originalConcMapper = ffp.getMapper("\\Qubit ng/ml\\"); 649 Mapper speedVacConcMapper = ffp.getMapper("\\After SpeedVac\\"); 650 651 Map<String, Float> originalConc = new HashMap<String, Float>(); 652 Map<String, Float> speedVacConc = new HashMap<String, Float>(); 653 while (ffp.hasMoreData()) 654 { 655 int lineNo = ffp.getParsedLines(); 656 FlatFileParser.Data data = ffp.nextData(); 657 String libName = nameMapper.getValue(data); 658 originalConc.put(libName, checkQubitConcentration(originalConcMapper.getFloat(data), lineNo)); 659 speedVacConc.put(libName, checkQubitConcentration(speedVacConcMapper.getFloat(data), lineNo)); 660 } 661 662 // An original concentration is required, but SpeedVac concentration is optional 663 LookupConverter<String, Float> originalConcLookup = new LookupConverter<String, Float>(originalConc, 664 "Could not find original concentration for extract '{KEY}'" 665 ); 666 LookupConverter<String, Float> speedVacConcLookup = new LookupConverter<String, Float>(speedVacConc, null); 667 668 cpi.addExternalLookup(originalConcLookup, originalConcType); 669 cpi.addExternalLookup(speedVacConcLookup, speedVacConcType); 644 try 645 { 646 // Parse the Qubit file and store concentration before and after speedvac in two maps 647 FlatFileParser ffp = new FlatFileParser(); 648 ffp.setDataHeaderRegexp(Pattern.compile(".*Well.*Library name.*Qubit ng/ml.*After SpeedVac.*")); 649 ffp.setIgnoreRegexp(Pattern.compile("^\\\"?#.*")); // Ignore all lines starting with '#' ( or "#) 650 ffp.setDataSplitterRegexp(Pattern.compile("\t|,")); // Split on tab or comma 651 ffp.setInputStream(qubitCsv.getDownloadStream(0), "UTF-8"); 652 ffp.setTrimQuotes(true); 653 if (ffp.parseHeaders() != LineType.DATA_HEADER) 654 { 655 throw new InvalidDataException("Could not find header line starting with 'Well{tab}Library name{tab}Qubit ng/ml...'"); 656 } 657 658 Mapper nameMapper = ffp.getMapper("\\Library name\\"); 659 Mapper originalConcMapper = ffp.getMapper("\\Qubit ng/ml\\"); 660 Mapper speedVacConcMapper = ffp.getMapper("\\After SpeedVac\\"); 661 662 Map<String, Float> originalConc = new HashMap<String, Float>(); 663 Map<String, Float> speedVacConc = new HashMap<String, Float>(); 664 while (ffp.hasMoreData()) 665 { 666 int lineNo = ffp.getParsedLines(); 667 FlatFileParser.Data data = ffp.nextData(); 668 String libName = nameMapper.getValue(data); 669 originalConc.put(libName, checkQubitConcentration(originalConcMapper.getFloat(data), lineNo)); 670 speedVacConc.put(libName, checkQubitConcentration(speedVacConcMapper.getFloat(data), lineNo)); 671 } 672 673 // An original concentration is required, but SpeedVac concentration is optional 674 LookupConverter<String, Float> originalConcLookup = new LookupConverter<String, Float>(originalConc, 675 "Could not find Qubit concentration for extract '{KEY}' in file: " + qubitCsv.getName() 676 ); 677 LookupConverter<String, Float> speedVacConcLookup = new LookupConverter<String, Float>(speedVacConc, null); 678 679 cpi.addExternalLookup(originalConcLookup, originalConcType); 680 cpi.addExternalLookup(speedVacConcLookup, speedVacConcType); 681 } 682 catch (Exception ex) 683 { 684 throw new RuntimeException("File '" + qubitCsv.getName() + "': " + ex.getMessage(), ex); 685 } 670 686 } 671 687
Note: See TracChangeset
for help on using the changeset viewer.