Changeset 1934


Ignore:
Timestamp:
Apr 17, 2013, 10:35:45 AM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #485: Select libraries for pooling

Very preliminary wizard for creating pooled library items. Expect it to change a lot in the future. For safety reasons, it will not save any information in the database. It would cause incorrect calculations in the (also preliminary) lab protocols for the pooling.

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

Legend:

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

    r1931 r1934  
    263263          <dd>
    264264            <ul>
     265            <li><a href="libprep/create_pools.jsp?ID=<%=ID%>">Create pooled libraries</a>
    265266            <li><a href="libprep/pool_protocol.jsp?ID=<%=ID%>">Lab protocols for pooling and flow cell preparation</a>
    266267            <li><a href="libprep/pool_registration.jsp?ID=<%=ID%>">Register pooled libraries</a>
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/lib_registration.jsp

    r1931 r1934  
    653653        <td class="input"><textarea rows="4" cols="50" style="width: 90%;" name="libComments" value="" onblur="libCommentsOnChange()"></textarea></td>
    654654        <td class="status" id="libComments.status"></td>
    655         <td class="help"><span id="libComments.message" class="message" style="display: none;"></span>Comments about the quality control results.</td>
     655        <td class="help"><span id="libComments.message" class="message" style="display: none;"></span>Comments about the library preparation.</td>
    656656      </tr>
    657657      </table>
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/plate.js

    r1865 r1934  
    6666  plate.getPools = function()
    6767  {
    68     return plate.poolSchema ? plate.poolSchema.getPools() : 0;
     68    return plate.poolSchema ? plate.poolSchema.numPools : 0;
    6969  }
    7070 
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/PoolServlet.java

    r1925 r1934  
    1515import org.json.simple.JSONArray;
    1616import org.json.simple.JSONObject;
     17import org.json.simple.parser.JSONParser;
    1718
    1819
    1920
    2021import net.sf.basedb.core.Application;
     22import net.sf.basedb.core.BioMaterialEvent;
     23import net.sf.basedb.core.BioMaterialEventSource;
    2124import net.sf.basedb.core.BioPlate;
    2225import net.sf.basedb.core.DbControl;
     
    2528import net.sf.basedb.core.InvalidDataException;
    2629import net.sf.basedb.core.ItemQuery;
     30import net.sf.basedb.core.ItemSubtype;
    2731import net.sf.basedb.core.SessionControl;
    2832import net.sf.basedb.core.query.Annotations;
     
    3539import net.sf.basedb.reggie.dao.BioplateType;
    3640import net.sf.basedb.reggie.dao.Library;
     41import net.sf.basedb.reggie.dao.PooledLibrary;
    3742import net.sf.basedb.reggie.dao.ReactionPlate;
     43import net.sf.basedb.reggie.dao.Subtype;
    3844import net.sf.basedb.util.Values;
    3945import net.sf.basedb.util.error.ThrowableUtil;
     
    130136        json.put("libraries", jsonLibs);
    131137      }
     138      else if ("GetNextAutoGeneratedPoolNames".equals(cmd))
     139      {
     140        dc = sc.newDbControl();
     141        int numNames = Values.getInt(req.getParameter("numNames"));
     142        json.put("names", PooledLibrary.generateNamesForBatch(dc, 1, numNames));
     143
     144      }
    132145    }
    133146    catch (Throwable t)
     
    166179    try
    167180    {
    168       if ("CreateBarcodedLibraries".equals(cmd))
    169       {
     181      if ("CreatePools".equals(cmd))
     182      {
     183        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());
     184        JSONArray jsonPools = (JSONArray)jsonReq.get("pools");
     185       
     186        dc = sc.newDbControl();
     187        ItemSubtype pooledLibraryType = Subtype.POOLED_LIBRARY.load(dc);
     188       
     189        for (int i = 0; i < jsonPools.size(); i++)
     190        {
     191          JSONObject jsonPool = (JSONObject)jsonPools.get(i);
     192          JSONArray jsonLibs = (JSONArray)jsonPool.get("libs");
     193         
     194          Extract pool = Extract.getNew(dc);
     195          pool.setItemSubtype(pooledLibraryType);
     196          pool.setName((String)jsonPool.get("name"));
     197         
     198          BioMaterialEvent poolEvent = pool.getCreationEvent();
     199         
     200          for (int j = 0; j < jsonLibs.size(); j++)
     201          {
     202            JSONObject jsonLib = (JSONObject)jsonLibs.get(j);
     203            Number libId = (Number)jsonLib.get("id");
     204
     205            Extract lib = Extract.getById(dc, libId.intValue());
     206            BioMaterialEventSource src = poolEvent.addSource(lib);
     207           
     208            Float originalConc = (Float)Annotationtype.QUBIT_CONC.getAnnotationValue(dc, lib);
     209            Float speedVacConc = (Float)Annotationtype.QUBIT_CONC_AFTER_SPEEDVAC.getAnnotationValue(dc, lib);
     210            Float usedConc = speedVacConc == null ? originalConc : speedVacConc;
     211            Float molarity = (Float)Annotationtype.CA_MOLARITY.getAnnotationValue(dc, lib);
     212
     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());
     217            src.setUsedQuantity(usedQuantity);
     218          }
     219         
     220          // TODO - how to calculate the original quantity of the pool
     221          // pool.setOriginalQuantity(????);
     222         
     223          dc.saveItem(pool);
     224         
     225          jsonMessages.add("Created '" + pool.getName() + "' from " + jsonLibs.size() + " libraries");
     226        }
     227       
     228        //dc.commit();
    170229      }
    171230      json.put("messages", jsonMessages);
Note: See TracChangeset for help on using the changeset viewer.