Changeset 1760


Ignore:
Timestamp:
Nov 30, 2012, 12:45:00 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #424: Select RNA items for library preparation

Implemented a simple auto-selection feature that find:

  • RNA items with no child mRNA
  • A non-empty creation date
  • Remaining quantity >= 1.1µg
  • Not manually included on the mRNA plate
  • Sorted by RNA plate and location: plate, row, column

The user designing the plate need to account for replicates/stratagene by leaving room on each pool and then using copy/paste to duplicate some RNA. The user must also manually assign items for QC.

Location:
extensions/net.sf.basedb.reggie/branches/ticket-422
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/branches/ticket-422/resources/libprep/select_rna.jsp

    r1742 r1760  
    342342    }
    343343   
    344     for (var i = 0; i < response.rna.length; i++)
    345     {
    346       var rna = response.rna[i];
     344    rna.cacheInfo(response.rna);
     345  }
     346 
     347  rna.cacheInfo = function(rnaList)
     348  {
     349    for (var i = 0; i < rnaList.length; i++)
     350    {
     351      var rna = rnaList[i];
    347352      info['N'+rna.name] = rna;
    348353      info['I'+rna.id] = rna;
     
    475480      {
    476481        text += '<div class="ndconc">'+Numbers.formatNumber(info.NDConc, 2, 'ng/µl') + '</div>';
    477         text += '<div class="volume">'+Numbers.formatNumber(use/10, 1)+' + '+Numbers.formatNumber(water/10, 1)+'µl</div>';
     482        text += '<div class="volumes"><span class="volume">'+Numbers.formatNumber(use/10, 1)+'</span> + <span class="water">'+Numbers.formatNumber(water/10, 1)+'µl</span></div>';
    478483      }
    479484      else
     
    835840{
    836841  Main.openPopup('select_file.jsp?ID=<%=ID%>', 'SelectFile', 600, 400);
     842}
     843
     844
     845/**
     846  Let the wizard automatically select among unprocessed RNA items.
     847*/
     848function autoSelect()
     849{
     850
     851  var wells = Plate.getWells();
     852  var ignore = [];
     853  var selected = 0;
     854  var notEmpty = 0;
     855 
     856  // Count selected and non-empty wells and keep track of RNA that is already present
     857  for (var i = 0; i < wells.length; i++)
     858  {
     859    var well = wells[i];
     860    if (well.selected)
     861    {
     862      selected++;
     863      if (well.rna && !well.hasError()) notEmpty++;
     864    }
     865    if (well.rna && well.rna.id)
     866    {
     867      ignore[ignore.length] = well.rna.id;
     868    }
     869  }
     870 
     871  if (selected == 0)
     872  {
     873    alert('Please select one or more wells were RNA should be placed.');
     874    return;
     875  }
     876 
     877  if (notEmpty > 0)
     878  {
     879    if (!confirm('Replace RNA in ' + notEmpty + ' wells?'))
     880    {
     881      return;
     882    }
     883  }
     884
     885  var request = Ajax.getXmlHttpRequest();
     886  var url = '../MRna.servlet?ID=<%=ID%>&cmd=AutoSelectRnaForMRna&numToSelect='+currentSelected;
     887  url += '&ignore='+ignore.join(',');
     888  request.open("GET", url, false);
     889  request.send(null);
     890
     891  if (debug) Main.debug(request.responseText);
     892  var response = JSON.parse(request.responseText); 
     893  if (response.status != 'ok')
     894  {
     895    setFatalError(response.message);
     896    return false;
     897  }
     898 
     899  // Cache RNA information
     900  Rna.cacheInfo(response.rna);
     901 
     902  if (response.rna.length == 0)
     903  {
     904    alert('Could not find any unprocessed RNA at this time.');
     905  }
     906 
     907  for (var i = 0; i < response.rna.length; i++)
     908  {
     909    if (i < selected.length)
     910    {
     911      var well = selected[i];
     912      // Create a new RNA object
     913      var rna = Rna.createByName(response.rna[i].name);
     914      well.setRna(rna);
     915      well.selected = false;
     916    }
     917  }
     918 
     919  // Check for replicates on the whole plate and repaint it
     920  Plate.checkReplicates(null, true);
     921  Plate.paint(Plate.getWells());
    837922}
    838923
     
    11581243  display: none;
    11591244}
    1160 .plate.hide-volume .volume
     1245.plate.hide-volumes .volumes
    11611246{
    11621247  display: none;
     
    11651250{
    11661251  display: none;
     1252}
     1253
     1254.volume
     1255{
     1256  color: #C80000;
     1257}
     1258.water
     1259{
     1260  color: #0000C8;
    11671261}
    11681262
     
    12131307            <td>
    12141308              <input type="checkbox" name="ndconc" id="ndconc" onclick="toggleInfo('ndconc')"><label for="ndconc">NDConc</label><br>
    1215               <input type="checkbox" name="volume" id="volume" onclick="toggleInfo('volume')"><label for="volume">Used volume+water</label><br>
     1309              <input type="checkbox" name="volumes" id="volumes" onclick="toggleInfo('volumes')"><label for="volumes">Used volume+water</label><br>
    12161310            </td>
    12171311          </tr>
     
    12361330       
    12371331        <tbl:button
    1238           title="Auto-select&hellip;"
     1332          title="Auto-select"
    12391333          image="<%=home+"/images/wizard.png"%>"
    12401334          onclick="autoSelect()"
     
    12781372        />
    12791373      </tbl:toolbar>
    1280         <table class="plate hide-volume hide-ndconc" style="margin: 1em 1em 0 1em;" id="plate">
     1374        <table class="plate hide-volumes hide-ndconc" style="margin: 1em 1em 0 1em;" id="plate">
    12811375        <%
    12821376        int columns = 12;
  • extensions/net.sf.basedb.reggie/branches/ticket-422/src/net/sf/basedb/reggie/servlet/MRnaServlet.java

    r1758 r1760  
    22
    33import java.io.IOException;
     4import java.util.Arrays;
    45import java.util.Date;
    56import java.util.HashMap;
     
    111112        json.put("bioplates", jsonLists);
    112113      }
     114      else if ("AutoSelectRnaForMRna".equals(cmd))
     115      {
     116        dc = sc.newDbControl();
     117       
     118        int numToSelect = Values.getInt(req.getParameter("numToSelect"));
     119        Integer[] ignore = Values.getInt(req.getParameter("ignore").split(","));
     120        ItemQuery<Extract> query = Extract.getQuery();
     121        query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     122        Subtype.RNA.addFilter(dc, query);
     123        // Filter for RNA already included on the plate
     124        if (ignore != null && ignore.length > 0)
     125        {
     126          query.restrict(Restrictions.not(Restrictions.in(Hql.property("id"), Expressions.parameter("ignore"))));
     127          query.setParameter("ignore", Arrays.asList(ignore), Type.INT);
     128        }
     129       
     130        // Filter for non-empty creation date
     131        query.join(Hql.innerJoin("creationEvent", "ce"));
     132        query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null));
     133       
     134        // Filter for enough remaining quantity >= 1.1 µg
     135        query.restrict(Restrictions.gteq(Hql.property("remainingQuantity"), Expressions.aFloat(1.1f)));
     136       
     137        // Create a query that load all RNA extracts that has at least one mRNA child extract
     138        ItemQuery<Extract> subquery = Extract.getQuery();
     139        subquery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     140        // Filter on RNA subtype
     141        Subtype.RNA.addFilter(dc, subquery);
     142       
     143        // Join child items and filter on RNAQC subtype
     144        subquery.join(Hql.innerJoin("childCreationEvents", "cce"));
     145        subquery.join(Hql.innerJoin("cce", "event", "evt", null, false));
     146        subquery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false));
     147        Subtype.MRNA.addFilter(dc, subquery, "bm");
     148       
     149        // Filter on id not equal to any that has a mRNA child
     150        query.restrict(Restrictions.neq(Hql.property("id"), Expressions.all(subquery)));
     151       
     152        // Order by RNA plate and location: plate - row - column
     153        query.join(Hql.innerJoin(null, "bioWell", "w", true));
     154        query.join(Hql.innerJoin("w", "bioPlate", "bp", true));
     155        query.order(Orders.asc(Hql.property("bp", "name")));
     156        query.order(Orders.asc(Hql.property("w", "row")));
     157        query.order(Orders.asc(Hql.property("w", "column")));
     158        query.setMaxResults(numToSelect);
     159       
     160        json.put("query", query.toQl(dc));
     161       
     162        List<Rna> rna = Rna.toRna(query.list(dc));
     163        JSONArray jsonRna = new JSONArray();
     164       
     165        for (Rna r : rna)
     166        {
     167          r.loadBioPlateLocation();
     168          r.setAnnotation("remainingQuantity", r.getExtract().getRemainingQuantity());
     169          r.loadAnnotations(dc, "NDConc", Annotationtype.ND_CONC, null);
     170          jsonRna.add(r.asJSONObject());
     171        }
     172       
     173        json.put("rna", jsonRna);
     174       
     175      }
    113176      else if ("GetMRnaInfoForPlate".equals(cmd))
    114177      {
Note: See TracChangeset for help on using the changeset viewer.