Changeset 2137


Ignore:
Timestamp:
Nov 13, 2013, 3:53:05 PM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #527: Implement manual pooled library selection

This should now be functional. Need some more testing for border cases.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/create_pools.jsp

    r2053 r2137  
    9696  }
    9797  return response.bioplates;
     98}
     99
     100function createManualPool()
     101{
     102  location.replace('create_manual_pool.jsp?ID=<%=ID%>');
    98103}
    99104
     
    874879      </tr>
    875880      <tr valign="top">
    876         <td class="prompt">Manual select</td>
    877         <td class="input"> // TODO</td>
     881        <td class="prompt"></td>
     882        <td class="input">
     883          <table><tr><td>
     884            <base:button title="Create manual pool" onclick="createManualPool()" image="<%=home+"/images/gonext.png"%>" />
     885          </td></tr></table>
     886       
     887        </td>
    878888        <td class="status"></td>
    879889        <td class="help"></td>
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/pools.js

    r2053 r2137  
    307307  pm.calculateLibVolume = function(lib, targetMolarity, targetVolume, mixingStrategy)
    308308  {
    309     var maxVolume = lib.speedVacConc != null ? AVAILABLE_VOLUME_AFTER_SPEEDVAC : AVAILABLE_VOLUME;
     309    var maxVolume = lib.remainingVolume;
    310310    if (mixingStrategy == 'fixed' && maxVolume > targetVolume)
    311311    {
     
    387387      // Calculate the total volume needed to get to the
    388388      // target molarity for the pooled libs
    389       var totalPoolVolume = totalLibAmount / targetMolarity;
    390       var totalEbVolume = totalPoolVolume - totalLibVolume - fixedEbVolume;
     389      // Round all summarized values to avoid precision problems (eg. 4.0 --> 3.999999998)
     390      var totalPoolVolume = pm.round(totalLibAmount / targetMolarity);
     391      totalLibVolume = pm.round(totalLibVolume);
     392      fixedEbVolume = pm.round(fixedEbVolume);
     393      var totalEbVolume = pm.round(totalPoolVolume - totalLibVolume - fixedEbVolume);
    391394
    392395      // Divide EB volume among the libs (rounded to 1 decimal)
     
    405408      }
    406409     
     410      usedEb = pm.round(usedEb);
     411     
    407412      // If the used EB doesn't add up to the total amount needed (due to rounding)
    408413      // add the extra amount to the last lib
    409       if (Math.abs(totalEbVolume - usedEb) > 0.1 && adjustableLib)
     414      if (Math.abs(totalEbVolume - usedEb) >= 0.05 && adjustableLib)
    410415      {
    411416        adjustableLib.eb += totalEbVolume - usedEb;
     
    427432      var lib = libs[libNo];
    428433      var vol = lib.maxVolume < lib.volume ? lib.maxVolume : lib.volume;
    429       var eb = Math.max(0, lib.eb);
    430434      libVolume += vol;
    431       ebVolume += eb;
     435      ebVolume += lib.eb;
    432436      if (mixingStrategy == 'dynamic' && (!lib.mixFactor || lib.mixFactor == 1))
    433437      {
    434         ebFinalMix += eb;
     438        ebFinalMix += lib.eb;
    435439      }
    436440      libAmount += vol * lib.molarity;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PoolServlet.java

    r2104 r2137  
    184184       
    185185      }
     186      else if ("GetLibraryInfo".equals(cmd))
     187      {
     188        // Get information about a single library
     189        int libId = Values.getInt(req.getParameter("libraryId"));
     190        dc = sc.newDbControl();
     191       
     192        Library lib = Library.getById(dc, libId);
     193        lib.loadBioPlateLocation();
     194        addPoolingCalculationsToLib(dc, lib, null);
     195        lib.setAnnotation("comment", lib.getExtract().getDescription());
     196       
     197        json.put("library", lib.asJSONObject());
     198       
     199      }
    186200      else if ("GetLibraryInfoForPlate".equals(cmd))
    187201      {
     
    208222        {
    209223          lib.loadBioPlateLocation();
    210           addPoolingCalculationsToLib(dc, lib, null, libs.size());
     224          addPoolingCalculationsToLib(dc, lib, null);
    211225          lib.setAnnotation("comment", lib.getExtract().getDescription());
    212226          jsonLibs.add(lib.asJSONObject());
     
    230244        int numNames = Values.getInt(req.getParameter("numNames"));
    231245        json.put("names", PooledLibrary.generateNamesForBatch(dc, 1, numNames));
     246        JSONObject poolInfo = new JSONObject();
     247        poolInfo.put("targetMolarity", TARGET_MOLARITY_IN_POOL);
     248        poolInfo.put("targetVolumePerLib", DEFAULT_TARGET_VOLUME_IN_POOL_PER_LIB);
     249        poolInfo.put("extraLargeMixFactor", EXTRA_LARGE_MIX_FACTOR);
     250        poolInfo.put("limitForExtraLargeMix", LIMIT_FOR_EXTRA_LARGE_MIX);
     251        json.put("poolInfo", poolInfo);
    232252      }
    233253      else if ("CountUnprocessedPools".equals(cmd))
     
    283303          {
    284304            lib.loadBioPlateLocation();
    285             addPoolingCalculationsToLib(dc, lib, pool, libs.size());
     305            addPoolingCalculationsToLib(dc, lib, pool);
    286306            lib.setAnnotation("comment", lib.getExtract().getDescription());
    287307            jsonLibs.add(lib.asJSONObject());
     
    597617 
    598618 
    599   private void addPoolingCalculationsToLib(DbControl dc, Library lib, PooledLibrary pool, int numLibs)
     619  private void addPoolingCalculationsToLib(DbControl dc, Library lib, PooledLibrary pool)
    600620  {
    601621    // Load original and SpeedVac:ed concentrations
     
    612632   
    613633    // Load remaining quantity of the lib
    614     lib.setAnnotation("remainingQuantity", libEx.getRemainingQuantity());
     634    Float remain = libEx.getRemainingQuantity();
     635    lib.setAnnotation("remainingQuantity", remain);
     636    if (remain != null && (originalConc != null || speedVacConc != null))
     637    {
     638      // Remaining volume in µl
     639      Float conc = speedVacConc == null ? originalConc : speedVacConc;
     640      lib.setAnnotation("remainingVolume", 1000 * remain / conc);
     641    }
    615642
    616643    if (pool != null)
     
    642669  }
    643670 
     671 
    644672  @SuppressWarnings("unchecked")
    645673  private JSONObject getJSONForLibPlate(DbControl dc, BioPlate libPlate)
Note: See TracChangeset for help on using the changeset viewer.