Changeset 1975


Ignore:
Timestamp:
May 15, 2013, 1:20:50 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #485 and #479. Only use 1 decimal in lab protocols for pooling. Use the rounded values when calculating molarity and other values for the pool.

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

Legend:

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

    r1972 r1975  
    146146        tmp.volume = lib.volume;
    147147        tmp.eb = lib.eb;
    148         tmp.extraMixFactor = lib.extraMixFactor;
     148        tmp.mixFactor = lib.mixFactor;
    149149        poolInfo.libs[poolInfo.libs.length] = tmp;
    150150      }
     
    315315    }
    316316
    317     if (lib.extraMixFactor)
     317    if (lib.mixFactor > 1.001)
    318318    {
    319319      // Larger mix than default
    320       var mixedVolume = (lib.volume+lib.eb)*(1+lib.extraMixFactor);
     320      var mixedVolume = (lib.volume+lib.eb)*(lib.mixFactor);
    321321      remarks[remarks.length] = 'Mix ' + Numbers.formatNumber(mixedVolume, 0) + 'µl';
    322322    }
     
    353353      if (lib)
    354354      {
    355         poolMolarity += Math.min(lib.molarity, TARGET_MOLARITY_IN_POOL);
     355        poolMolarity += Math.min(lib.molarity, lib.mixMolarity);
    356356        poolVolume += TARGET_VOLUME_IN_POOL_PER_LIB;
    357357        numLibs++;
     
    392392      var name = lib.name;
    393393      var i = name.indexOf('.m');
    394       var mixFactor = 1+lib.extraMixFactor;
     394      var mixFactor = lib.mixFactor;
    395395      var displayName = name.substring(0, i)+'.<br>&nbsp;'+name.substring(i);
    396396      text += '<div class="lib">'+displayName+'</div>';
    397397      text += '<span class="barcode">'+lib.barcode.name+'</span>';
    398398      text += '<span class="molarity">'+Numbers.formatNumber(lib.molarity, 2)+'nM</span>';
    399       text += '<span class="volume">'+Numbers.formatNumber(lib.volume*mixFactor, 2) + 'µl</span>';
    400       text += '<span class="eb">'+Numbers.formatNumber(lib.eb*mixFactor, 2)+'µl</span>';
     399      text += '<span class="volume">'+Numbers.formatNumber(lib.volume*mixFactor, 1) + 'µl</span>';
     400      text += '<span class="eb">'+Numbers.formatNumber(lib.eb*mixFactor, 1)+'µl</span>';
    401401      text += '<div class="remarks">'+ lib.remarks.join('; ') + '</div>';
    402402    }
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/pool_protocol2.jsp

    r1965 r1975  
    212212      }
    213213 
    214       if (lib.extraMixFactor)
     214      if (lib.mixFactor > 1.001)
    215215      {
    216216        // Larger mix than default
    217         var mixedVolume = (lib.volume+lib.eb)*(1+lib.extraMixFactor);
     217        var mixedVolume = (lib.volume+lib.eb)*(lib.mixFactor);
    218218        remarks[remarks.length] = 'Mix ' + Numbers.formatNumber(mixedVolume, 0) + 'µl';
    219219      }
     
    266266        }
    267267
    268         addColumn(tr, "lib", lib.name);
    269         addColumn(tr, "remain", Numbers.formatNumber((lib.remainingQuantity+lib.usedQuantity)*1000, 2));
    270         addColumn(tr, "molarity", Numbers.formatNumber(lib.molarity, 2));
     268        addColumn(tr, 'lib', lib.name);
     269        addColumn(tr, 'remain', Numbers.formatNumber((lib.remainingQuantity+lib.usedQuantity)*1000, 2));
     270        addColumn(tr, 'molarity', Numbers.formatNumber(lib.molarity, 2));
    271271        <%
    272272        if (libPlate==null)
    273273        {
    274274          %>
    275           addColumn(tr, "workplate", well.bioPlate.name + ' ' + well.location);
     275          addColumn(tr, 'workplate', well.bioPlate.name + ' ' + well.location);
    276276          <%
    277277        }
     
    279279        {
    280280          %>
    281           addColumn(tr, "workplate", well.location);
     281          addColumn(tr, 'workplate', well.location);
    282282          <%
    283283        }
    284284        %>
    285         var mixFactor = 1+(lib.extraMixFactor || 0);
    286         addColumn(tr, "mix", '<span class="volume">'+Numbers.formatNumber(lib.volume*mixFactor, 2)+'</span>+<span class="eb">'+Numbers.formatNumber(lib.eb*mixFactor, 2)+'</span>');
     285        var mixFactor = lib.mixFactor || 1.0;
     286        addColumn(tr, 'volume', Numbers.formatNumber(lib.volume*mixFactor, 1));
     287        addColumn(tr, 'eb', Numbers.formatNumber(lib.eb*mixFactor, 1));
    287288        addColumn(tr, "remarks", lib.remarks.join('; '));
    288289        tbody.appendChild(tr);
     
    296297  function addColumn(tr, className, html)
    297298  {
    298    
    299299    var td = document.createElement('td');
    300300    td.className = className;
    301301    td.innerHTML = html;
    302302    tr.appendChild(td);
    303    
    304303  }
    305304 
     
    308307    Plate.init(8, 12, schema, WellPainter);
    309308   
    310     for (var i = 0; i < pools.length; i++)
    311     {
    312       var pool = pools[i];
    313       POOL_NAMES[i] = pool.name;
    314       for (var j = 0; j < pool.libraries.length; j++)
    315       {
    316         var lib = pool.libraries[j];
     309    for (var poolNo = 0; poolNo < pools.length; poolNo++)
     310    {
     311      var pool = pools[poolNo];
     312      POOL_NAMES[poolNo] = pool.name;
     313      for (var libNo = 0; libNo < pool.libraries.length; libNo++)
     314      {
     315        var lib = pool.libraries[libNo];
    317316        var well = lib.bioWell;
    318317        Plate.getWell(well.row, well.column).setExtract(lib);
     
    324323    PoolSchema.buildPoolTableRow(schema, 12);
    325324    Main.show('plateview');
     325   
     326   
     327    for (var poolNo = 0; poolNo < pools.length; poolNo++)
     328    {
     329      var pool = pools[poolNo];
     330      //setInnerHTML('molarity.'+pool.id, Numbers.formatNumber(pool.molarity, 2) + ' nM; ' + Numbers.formatNumber(1000*pool.originalQuantity / pool.conc, 0)+' µl');
     331
     332      var poolData = '<div class="pool-data">';
     333      poolData += Numbers.formatNumber(pool.molarity, 2)+'nM; ';
     334      poolData += Numbers.formatNumber(1000*pool.originalQuantity / pool.conc, 0) + 'µl';
     335      poolData += '</div>';
     336      document.getElementById('pool.'+poolNo).innerHTML = POOL_NAMES[poolNo] + poolData;
     337
     338    }
    326339  }
    327340
     
    349362      {
    350363        var name = lib.name;
    351         var mixFactor = 1+(lib.extraMixFactor || 0);
     364        var mixFactor = lib.mixFactor || 1.0;
    352365        var i = name.indexOf('.m');
    353366        text += '<div class="lib">'+name.substring(0, i)+'.<br>&nbsp;'+name.substring(i)+'</div>';
     
    478491  }
    479492
    480   .listview .mix
    481   {
    482     width: 8em;
     493  .listview .volume
     494  {
     495    width: 3.5em;
    483496    padding-right: 0.5em;
    484497    text-align: right;
    485   }
    486  
    487   .listview .empty .mix
    488   {
    489     visibility: hidden;
    490   }
    491  
    492   .listview .volume
    493   {
    494498    color: #C80000;
    495     padding-right: 3px;
    496499  }
    497500 
    498501  .listview .eb
    499502  {
     503    width: 3.5em;
     504    padding-right: 0.5em;
     505    text-align: right;
    500506    color: #0000C8;
    501     padding-left: 3px;
    502507  }
    503508 
     
    546551    color: #C80000;
    547552    font-style: italic;
     553  }
     554  #plateview .pool-data
     555  {
     556    font-weight: normal;
    548557  }
    549558  </style>
     
    620629          <th>DNA</th>
    621630          <th class="workplate">Work</th>
    622           <th>2nM, 5/10µl</th>
     631          <th colspan="2">2nM, 5/10µl</th>
    623632          <th></th>
    624633        </tr>
     
    629638          <th class="workplate">plate</th>
    630639          <th>(µl)</th>
     640          <th>EB</th>
    631641          <th>Remarks</th>
    632642        </tr>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r1953 r1975  
    156156  }
    157157 
     158  /**
     159    Round a floating point value to a given number of decimals.
     160    @since 2.12
     161  */
     162  public static float round(float value, int decimals)
     163  {
     164    double factor = Math.pow(10, decimals);
     165    return (float)(Math.round(factor * value) / factor);
     166  }
     167 
    158168}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PoolServlet.java

    r1974 r1975  
    6767 
    6868  /**
    69     Percentage to increase the mix when making an extra large mix.
    70     In the common case 1.0 means mixing 10µl instead of 5µl. But, only
     69    Factor to apply when making an extra large mix.
     70    In the common case 2.0 means mixing 10µl instead of 5µl. But, only
    7171    5µl is used for the pool and the remaining 5µl is saved in a temporary
    7272    location.
    7373  */
    74   private static final float EXTRA_LARGE_MIX_FACTOR = 1.0f;
     74  private static final float EXTRA_LARGE_MIX_FACTOR = 2.0f;
    7575 
    7676 
     
    358358           
    359359            //
    360             float extraMixFactor = ((Number)jsonLib.get("extraMixFactor")).floatValue();
     360            float mixFactor = ((Number)jsonLib.get("mixFactor")).floatValue();
    361361            float usedQuantityForExtra = 0f;
    362             if (extraMixFactor > 0)
     362            if (mixFactor > 1.001)
    363363            {
    364364              // Create 'dil' extract for keeping track of remaining quantity that has been mixed
    365               float usedVolumeForExtra = extraMixFactor * usedVolumeForPool;
     365              float usedVolumeForExtra = (mixFactor - 1) * usedVolumeForPool;
    366366              usedQuantityForExtra = usedVolumeForExtra * usedConc / 1000;
    367367              Extract dil = Extract.getNew(dc);
     
    375375              dil.setOriginalQuantity(usedQuantityForExtra);
    376376              dc.saveItem(dil);
     377             
     378              //jsonMessages.add("Created " + dil.getName() + "; volume=" + Values.formatNumber(usedVolumeForExtra, 2));
    377379            }
    378380           
    379             //jsonMessages.add("Using " + Values.formatNumber(usedQuantityForPool*1000, 2) + "+" + Values.formatNumber(usedQuantityForExtra*1000, 2) +"ng of " + Values.formatNumber(lib.getOriginalQuantity()*1000,2) + "ng from " + lib.getName()+"; molarity="+molarity);
     381            //jsonMessages.add("Using " + Values.formatNumber(usedQuantityForPool*1000, 2) + "+" + Values.formatNumber(usedQuantityForExtra*1000, 2) +"ng of " + Values.formatNumber(lib.getOriginalQuantity()*1000,2) + "ng from " + lib.getName()+"; molarity="+Values.formatNumber(molarity, 2) + "(" + Values.formatNumber(molarityForPool, 2) + ")");
    380382          }
    381383         
     
    387389          jsonMessages.add("Created '" + pool.getName() + "' from " + jsonLibs.size() + " libraries; pool molarity=" + Values.formatNumber(summedPoolMolarity / jsonLibs.size(), 2)); // conc="+Values.formatNumber(poolQuantity * 1000 / poolVolume, 2) + "ng/µl; quantity="+Values.formatNumber(poolQuantity*1000, 2)+"ng; volume="+Values.formatNumber(poolVolume, 2) + "µl");
    388390        }
     391       
    389392        dc.commit();
    390393      }
     
    476479        Float dilQuantity = dil.getOriginalQuantity();
    477480        //Float dilConc = (Float)Annotationtype.POOL_CONC.getAnnotationValue(dc, dil);
    478         lib.setAnnotation("extraMixFactor", dilQuantity / usedQuantity);
     481        lib.setAnnotation("mixFactor", (dilQuantity + usedQuantity) / usedQuantity);
    479482      }
    480483     
    481484      lib.setAnnotation("dils", result.size());
    482      
    483485    }
    484486    else
     
    486488      // Calculate mix volumes, but do not correct for negative volumes
    487489      // due to low concentration (this will be notified in the protocols)
    488       float usedVolumeForMix = TARGET_VOLUME_IN_POOL_PER_LIB * TARGET_MOLARITY_IN_POOL / molarity;
     490      // Round to 1 decimal since that is the expected accuracy of pipettes
     491      // Remember to use the rounded values in the calculations
     492      float usedVolumeForMix = Reggie.round(TARGET_VOLUME_IN_POOL_PER_LIB * TARGET_MOLARITY_IN_POOL / molarity, 1);
     493      float mixFactor = 1.0f;
     494      if (usedVolumeForMix < LIMIT_FOR_EXTRA_LARGE_MIX)
     495      {
     496        // Extra large mix is required if the usedVolume is small due to
     497        // difficulties to pipette the exact amount for small volumes
     498        mixFactor = EXTRA_LARGE_MIX_FACTOR;
     499        // Re-calculate volume to get the rounding correct
     500        usedVolumeForMix = Reggie.round(mixFactor * TARGET_VOLUME_IN_POOL_PER_LIB * TARGET_MOLARITY_IN_POOL / molarity, 1) / mixFactor;
     501      }
     502     
    489503      float ebVolumeForMix = TARGET_VOLUME_IN_POOL_PER_LIB - usedVolumeForMix;
    490504      lib.setAnnotation("volume", usedVolumeForMix);
    491505      lib.setAnnotation("eb", ebVolumeForMix);
    492       // Extra large mix is required if the usedVolume is small due to
    493       // difficulties to pipette the exact amount for small volumes
    494       lib.setAnnotation("extraMixFactor", usedVolumeForMix < LIMIT_FOR_EXTRA_LARGE_MIX ? EXTRA_LARGE_MIX_FACTOR : 0);
     506      lib.setAnnotation("mixMolarity", molarity * usedVolumeForMix / TARGET_VOLUME_IN_POOL_PER_LIB);
     507      lib.setAnnotation("mixFactor", mixFactor);
    495508    }
    496509  }
Note: See TracChangeset for help on using the changeset viewer.