Changeset 1952


Ignore:
Timestamp:
Apr 24, 2013, 11:33:32 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #485: Select libraries for pooling

Calculate volumes in the wizard instead of in the servlet.

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

Legend:

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

    r1935 r1952  
    263263          <dd>
    264264            <ul>
    265             <li><a href="libprep/create_pools.jsp?ID=<%=ID%>" class="not-implemented">Create pooled libraries</a>
     265            <li><a href="libprep/create_pools.jsp?ID=<%=ID%>">Create pooled libraries</a>
    266266            <li><a href="libprep/pool_protocol.jsp?ID=<%=ID%>">Lab protocols for pooling</a> (preliminary)
    267267            <li><a href="libprep/pool_registration.jsp?ID=<%=ID%>" class="not-implemented">Register pooled libraries</a>
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/create_pools.jsp

    r1934 r1952  
    3434var debug = true;
    3535var currentStep = 1;
     36var LIMIT_FOR_5_ML = 1.0;
    3637
    3738function init()
     
    134135    for (var j = 0; j < wells.length; j++)
    135136    {
    136       var lib = {};
    137       lib.id = wells[j].extract.id;
    138       poolInfo.libs[poolInfo.libs.length] = lib;
     137      var lib = wells[j].extract;
     138      if (lib)
     139      {
     140        var tmp = {};
     141        tmp.id = lib.id;
     142        tmp.name = lib.name;
     143        tmp.volume = lib.volume;
     144        poolInfo.libs[poolInfo.libs.length] = tmp;
     145      }
    139146    }
    140147   
     
    149156
    150157  var request = Ajax.getXmlHttpRequest();
    151   var url = '../Pool.servlet?ID=<%=ID%>';
    152   url += '&cmd=CreatePools';
    153   request.open("POST", url, false);
    154   request.setRequestHeader("Content-Type", "application/json");
    155   request.send(JSON.stringify(submitInfo));
     158  try
     159  {
     160    showLoadingAnimation('Creating pools...');
     161    var url = '../Pool.servlet?ID=<%=ID%>';
     162    url += '&cmd=CreatePools';
     163    request.open("POST", url, false);
     164    request.setRequestHeader("Content-Type", "application/json");
     165    request.send(JSON.stringify(submitInfo));
     166  }
     167  finally
     168  {
     169    hideLoadingAnimation();
     170  }
    156171
    157172  if (debug) Main.debug(request.responseText);
     
    277292  }
    278293 
     294  if (lib.molarity)
     295  {
     296    lib.volume = 10 / lib.molarity;
     297    lib.eb = 5-lib.volume;
     298    if (lib.speedVacConc != null)
     299    {
     300      remarks[remarks.length] = 'SpeedVac';
     301    }
     302    if (lib.volume > 5)
     303    {
     304      remarks[remarks.length] = 'Use 5 µl';
     305      //lib.volume = 5;
     306      //lib.eb = 0;
     307    }
     308
     309    if (lib.volume < LIMIT_FOR_5_ML)
     310    {
     311      lib.volume *= 2;
     312      lib.eb *= 2;
     313      remarks[remarks.length] = 'Mix 10µl';
     314    }
     315
     316  }
     317 
    279318  lib.remarks = remarks;
    280319}
     
    316355    var text = '';
    317356    var lib = well.extract;
    318     if (lib && lib.remainingQuantity)
     357    if (lib && lib.remainingQuantity && lib.molarity)
    319358    {
    320359      var name = lib.name;
     
    322361      text += '<div class="lib">'+name.substring(0, i)+'.<br>&nbsp;'+name.substring(i)+'</div>';
    323362      text += '<div class="barcode">'+lib.barcode.name+'</div>';
     363      text += '<span class="volume">'+Numbers.formatNumber(lib.volume, 2) + 'µl</span>';
     364      text += '<span class="eb">'+Numbers.formatNumber(lib.eb, 2)+'µl</span>';
    324365      text += '<div class="remarks">'+ lib.remarks.join('; ') + '</div>';
    325366    }
     
    332373</script>
    333374<style>
    334 #export div
    335 {
    336   margin-left: 1em;
     375.lib
     376{
     377  font-weight: bold;
     378  margin-bottom: 0.25em;
     379}
     380
     381.volume
     382{
     383  color: #C80000;
     384}
     385.eb
     386{
     387  color: #0000C8;
     388  float: right;
     389}
     390.remarks
     391{
     392  color: #C80000;
     393  font-style: italic;
    337394}
    338395</style>
     
    374431        </td>
    375432        <td class="status" id="bioplate.status"></td>
    376         <td class="help" rowspan="2"><span id="bioplate.message" class="message" style="display: none;"></span>
     433        <td class="help"><span id="bioplate.message" class="message" style="display: none;"></span>
    377434          Select an existing Library bioplate. The list contain all Library bioplates that
    378           has not yet been pooled (determined by ????).
     435          contain libraries with no child items.
    379436        </td>
     437      </tr>
     438      <tr valign="top">
     439        <td class="prompt"></td>
     440        <td class="input"> - or -</td>
     441        <td class="status" id="bioplate.status"></td>
     442        <td class="help"></td>
     443      </tr>
     444      <tr valign="top">
     445        <td class="prompt">Manual select</td>
     446        <td class="input"> // TODO</td>
     447        <td class="status" id="bioplate.status"></td>
     448        <td class="help"></td>
    380449      </tr>
    381450      </table>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PoolServlet.java

    r1934 r1952  
    8383        */
    8484        dc = sc.newDbControl();
     85       
     86        // Find Library items with remaining quantity==original quantity
     87        ItemQuery<Extract> libQuery = Extract.getQuery();
     88        libQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     89        Subtype.LIBRARY.addFilter(dc, libQuery);
     90        libQuery.restrict(Restrictions.eq(Hql.property("remainingQuantity"), Hql.property("originalQuantity")));
     91       
    8592        ItemQuery<BioPlate> query = BioPlate.getQuery();
    8693        query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    8794        // Only Library bioplates that are not destroyed
    8895        BioplateType.LIBRARY.addFilter(dc, query, true);
    89         // Must NOT have a creation date
    90         //query.restrict(Restrictions.eq(Hql.property("eventDate"), null));
    9196        // Must have a PLATE_PROCESS_RESULT=Success annotation
    9297        query.join(Annotations.leftJoin(null, Annotationtype.PLATE_PROCESS_RESULT.load(dc), "ppr"));
    9398        query.restrict(Restrictions.eq(Hql.alias("ppr"), Expressions.string(ReactionPlate.PROCESS_SUCCESSFUL)));
     99       
     100        query.join(Hql.innerJoin("bioWells", "bw"));
     101        query.join(Hql.innerJoin("bw", "bioMaterial", "bm"));
     102       
     103        query.restrict(Restrictions.eq(Hql.alias("bm"), Expressions.any(libQuery)));
     104        query.setDistinct(true);
    94105       
    95106        List<BioPlate> plates = query.list(dc);
     
    118129        query.join(Hql.innerJoin("bw", "bioPlate", "bp"));
    119130        query.restrict(Restrictions.eq(Hql.alias("bp"), Hql.entity(libPlate)));
     131        query.restrict(Restrictions.gt(Hql.property("remainingQuantity"), Expressions.aFloat(0f)));
    120132        query.order(Orders.asc(Hql.property("bw", "column")));
    121133        query.order(Orders.asc(Hql.property("bw", "row")));
     
    211223            Float molarity = (Float)Annotationtype.CA_MOLARITY.getAnnotationValue(dc, lib);
    212224
    213             // TODO - Most of the times 5 µl is used, but sometimes 10µl is used!!
    214             // Remember that concentration values are stored in ng/µl
    215             Float usedVolume = 10 / molarity;
    216             Float usedQuantity = Math.min(usedVolume * usedConc / 1000, lib.getRemainingQuantity());
     225            // Get the volume to use from the wizard. This calculated base on the CA_MOLARITY value for each
     226            // sample to give a final concentration of 2nM mixed to 5 or 10µl (for high concentration)
     227            Number usedVolume = (Number)jsonLib.get("volume");
     228            // We never use more than 5µl
     229            Float orginalVolume = usedVolume.floatValue();
     230            if (usedVolume.floatValue() > 5f) usedVolume = 5f;
     231           
     232            // Calculate usedQuantity, Remember that concentration values are stored in ng/µl
     233            Float usedQuantity = Math.min(usedVolume.floatValue() * usedConc / 1000, lib.getRemainingQuantity());
    217234            src.setUsedQuantity(usedQuantity);
     235           
     236            jsonMessages.add("Using " + Values.formatNumber(usedQuantity*1000, 2) + "/" + Values.formatNumber(orginalVolume*usedConc, 2) +" of " + Values.formatNumber(lib.getOriginalQuantity()*1000,2) + " from " + lib.getName());
    218237          }
    219238         
Note: See TracChangeset for help on using the changeset viewer.