Changeset 1940


Ignore:
Timestamp:
Apr 18, 2013, 1:57:14 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #424: Select RNA items for library preparation

Added filter for RIN/RQS ≥ 6 in the auto-select wizard. RNA below this value are flagged with LowQualityScore annotation and place in the 'Flagged RNA' list.

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

Legend:

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

    r1928 r1940  
    3636  var frm = document.forms['options'];
    3737  if (frm.remainingQuantity.checked) options.remainingQuantity = 1.1;
     38  if (frm.qualityScore.checked) options.qualityScore = 6.0;
    3839  if (frm.flag.checked) options.flag = 1;
    3940  if (frm.reProcess.checked) options.reProcess = 1;
     
    7071      <td>
    7172        <input type="checkbox" name="remainingQuantity" id="remainingQuantity" value="1" checked><label for="remainingQuantity">Remaining quantity ≥ 1.1µg</label><br>
    72 
     73        <input type="checkbox" name="qualityScore" id="qualityScore" value="1" checked><label for="qualityScore">RQS/RIN ≥ 6</label><br>
    7374      </td>
    7475    </tr>
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/select_rna.jsp

    r1939 r1940  
    275275  loadStratagene();
    276276 
    277   keepSessionAlive('<%=ID%>', debug, '../');
     277  keepSessionAlive('<%=ID%>', false, '../');
    278278 
    279279  var frm = document.forms['reggie'];
     
    817817    url += '&ignore='+ignore.join(',');
    818818   
    819     if (options.remainingQuantity)
    820     {
    821       url += '&remainingQuantity='+options.remainingQuantity;
    822     }
    823     if (options.flag)
    824     {
    825       url += '&flag=1';
    826     }
    827     if (options.reProcess)
    828     {
    829       url += '&reProcess=1';
    830     }
     819    options.ignore = ignore;
     820    if (debug) Main.debug(JSON.stringify(options));
    831821   
    832     request.open("GET", url, false);
    833     request.send(null);
     822    request.open("POST", url, false);
     823    request.send(JSON.stringify(options));
    834824
    835825    if (debug) Main.debug(request.responseText);
     
    13401330
    13411331  var flagged = Rna.getFlagged();
    1342   Main.openPopup('show_flagged_rna.jsp?ID=<%=ID%>&numFlagged='+flagged.length+'&numSelected='+currentSelected.length, 'FlaggedRna', 600, 400);
     1332  Main.openPopup('show_flagged_rna.jsp?ID=<%=ID%>&numFlagged='+flagged.length+'&numSelected='+currentSelected.length, 'FlaggedRna', 700, 500);
    13431333}
    13441334
  • extensions/net.sf.basedb.reggie/trunk/resources/libprep/show_flagged_rna.jsp

    r1881 r1940  
    4747    }
    4848    document.getElementById('remainingQuantity.'+i).innerHTML = rna.remainingQuantity;
     49    document.getElementById('qualityScore.'+i).innerHTML = rna.rqs || rna.rin;
    4950    document.getElementById('flag.'+i).innerHTML = rna.flag;
     51    if (rna.flag == 'NotEnoughRemainingQuantity')
     52    {
     53      makeBold('remainingQuantity.'+i)
     54    }
     55    else if (rna.flag == 'LowQualityScore')
     56    {
     57      makeBold('qualityScore.'+i)
     58    }
    5059    frm['use.'+i].rna = rna;
    5160  }
     61}
     62
     63function makeBold(elementId)
     64{
     65  Main.addClass(document.getElementById(elementId), 'bold');
    5266}
    5367
     
    6983</script>
    7084
     85<style>
     86.bold
     87{
     88  color: #C80000;
     89  font-weight: bold;
     90}
     91</style>
     92
    7193</base:head>
    7294<base:body onload="init()">
     
    7799    <tbl:columndef id="rna" title="RNA" />
    78100    <tbl:columndef id="location" title="Bioplate" />
    79     <tbl:columndef id="remainingQuanity" title="Remaining quantity (µg)" />
     101    <tbl:columndef id="remainingQuanity" title="Remaining (µg)" />
     102    <tbl:columndef id="qualityScore" title="RQS/RIN" />
    80103    <tbl:columndef id="flag" title="Flag" />
    81104 
     
    97120          <tbl:cell column="location" id="<%="location."+i%>"></tbl:cell>
    98121          <tbl:cell column="remainingQuanity" id="<%="remainingQuantity."+i%>"></tbl:cell>
     122          <tbl:cell column="qualityScore" id="<%="qualityScore."+i%>"></tbl:cell>
    99123          <tbl:cell column="flag" id="<%="flag."+i%>"></tbl:cell>
    100124        </tbl:row>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/JsonUtil.java

    r1826 r1940  
    3737  }
    3838
     39  /**
     40    Get a value from a JSON object as a Float value, or null
     41    if no value exists.
     42    @since 2.12
     43  */
     44  public static Float getAsFloat(JSONObject json, String key)
     45  {
     46    Number n = (Number)json.get(key);
     47    return n == null ? null : n.floatValue();
     48  }
    3949 
    4050  @SuppressWarnings("unchecked")
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Rna.java

    r1939 r1940  
    3939  */
    4040  public static final String FLAG_NOT_ENOUGH_REMAINING_QUANTITY = "NotEnoughRemainingQuantity";
     41
     42  /**
     43    Flag value for the {@link Annotationtype#FLAG} annotation when a RNA doesn't have
     44    a high enough quality score (RQS or RIN) to be auto-selected for library preparation.
     45    Additional processing of backup lysate or speciman may be required.
     46    @since 2.12
     47  */
     48  public static final String FLAG_LOW_QUALITY_SCORE = "LowQualityScore";
    4149 
    4250  /**
     
    319327 
    320328 
    321   public Extract loadRnaQc(DbControl dc)
     329  public Float loadRnaQc(DbControl dc)
    322330  {
    323331    Extract qc = findLastRnaQc(dc);
     
    329337    if (rin != null) setAnnotation("rin", rin);
    330338   
    331     return qc;
     339    return rqs != null ? rqs : rin;
    332340  }
    333341 
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/MRnaServlet.java

    r1939 r1940  
    22
    33import java.io.IOException;
    4 import java.util.Arrays;
    54import java.util.Date;
    65import java.util.HashMap;
     
    4645import net.sf.basedb.core.query.Orders;
    4746import net.sf.basedb.core.query.Restrictions;
     47import net.sf.basedb.reggie.JsonUtil;
    4848import net.sf.basedb.reggie.Reggie;
    4949import net.sf.basedb.reggie.dao.Annotationtype;
     
    132132        }
    133133        json.put("bioplates", jsonPlates);
    134       }
    135       else if ("AutoSelectRnaForMRna".equals(cmd))
    136       {
    137         dc = sc.newDbControl();
    138        
    139         int numToSelect = Values.getInt(req.getParameter("numToSelect"));
    140         Integer[] ignore = Values.getInt(req.getParameter("ignore").split(","));
    141        
    142         Float remainingQuantityLimit = Values.getFloat(req.getParameter("remainingQuantity"), null);
    143         boolean flagNotSelected = Values.getBoolean(req.getParameter("flag"));
    144         boolean reProcess = Values.getBoolean(req.getParameter("reProcess"));
    145        
    146         ItemQuery<Extract> query = Extract.getQuery();
    147         query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    148         Subtype.RNA.addFilter(dc, query);
    149         // Filter for RNA already included on the plate
    150         if (ignore != null && ignore.length > 0)
    151         {
    152           query.restrict(Restrictions.not(Restrictions.in(Hql.property("id"), Expressions.parameter("ignore"))));
    153           query.setParameter("ignore", Arrays.asList(ignore), Type.INT);
    154         }
    155        
    156         // Filter for non-empty creation date
    157         query.join(Hql.innerJoin("creationEvent", "ce"));
    158         query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null));
    159         // Filter on parent != null (to get rid of 'Stratagene'
    160         query.restrict(Restrictions.neq(Hql.property("parent"), null));
    161        
    162         // Join AUTO_PROCESSING annotation
    163         query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap"));
    164        
    165         // Create a subquery that load all RNA extracts that has at least one mRNA child extract
    166         ItemQuery<Extract> mrnaQuery = Extract.getQuery();
    167         mrnaQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
    168         // Filter on RNA subtype
    169         Subtype.RNA.addFilter(dc, mrnaQuery);
    170        
    171         // Join child items and filter on mRNA subtype
    172         mrnaQuery.join(Hql.innerJoin("childCreationEvents", "cce"));
    173         mrnaQuery.join(Hql.innerJoin("cce", "event", "evt", null, false));
    174         mrnaQuery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false));
    175         Subtype.MRNA.addFilter(dc, mrnaQuery, "bm");
    176        
    177         /* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND <no mrna children>) */
    178         Expression autoProcessing = Hql.alias("ap");
    179         query.restrict(
    180           Restrictions.nullSafeOr(
    181             reProcess ? Restrictions.eq(autoProcessing, Expressions.string("ReProcess")) : null,
    182             Restrictions.and(
    183               Restrictions.eq(autoProcessing, null),
    184               Restrictions.neq(Hql.property("id"), Expressions.all(mrnaQuery))
    185             )
    186           )
    187         );
    188        
    189         // Order by RNA plate and location: plate - row - column
    190         query.join(Hql.innerJoin(null, "bioWell", "w", true));
    191         query.join(Hql.innerJoin("w", "bioPlate", "bp", true));
    192         query.order(Orders.asc(Hql.property("bp", "name")));
    193         query.order(Orders.asc(Hql.property("w", "row")));
    194         query.order(Orders.asc(Hql.property("w", "column")));
    195         query.setMaxResults(numToSelect * 2);
    196        
    197         // Debug
    198         json.put("query", query.toQl(dc));
    199 
    200         JSONArray jsonRna = new JSONArray();
    201         JSONArray jsonFlagged = new JSONArray();
    202         ItemResultIterator<Extract> it = query.iterate(dc);
    203         try
    204         {
    205           String autoProcess = null;
    206           while (it.hasNext() && jsonRna.size() < numToSelect)
    207           {
    208             Extract rna = it.next();
    209             boolean okToProcess = true;
    210             Float remainingQuantity = rna.getRemainingQuantity();
    211            
    212             Rna r = Rna.get(rna);
    213             r.loadBioPlateLocation();
    214             r.loadRnaQc(dc);
    215             r.setAnnotation("remainingQuantity", remainingQuantity);
    216             r.loadAnnotations(dc, "NDConc", Annotationtype.ND_CONC, null);
    217            
    218             if (reProcess)
    219             {
    220               autoProcess = (String)Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, rna);
    221             }
    222            
    223             if (autoProcess == null)
    224             {
    225               if (remainingQuantityLimit != null)
    226               {
    227                 if (remainingQuantity == null || remainingQuantity < remainingQuantityLimit)
    228                 {
    229                   okToProcess = false;
    230                   r.setAnnotation("flag", Rna.FLAG_NOT_ENOUGH_REMAINING_QUANTITY);
    231                 }
    232               }
    233             }
    234  
    235             if (okToProcess)
    236             {
    237               jsonRna.add(r.asJSONObject());
    238             }
    239             else if (flagNotSelected)
    240             {
    241               jsonFlagged.add(r.asJSONObject());
    242             }
    243           }
    244         }
    245         finally
    246         {
    247           it.close();
    248         }
    249        
    250         json.put("rna", jsonRna);
    251         json.put("flagged", jsonFlagged);
    252        
    253134      }
    254135      else if ("GetMRnaInfoForPlate".equals(cmd))
     
    366247       
    367248        json.put("rna", jsonRna);
     249      }
     250      else if ("AutoSelectRnaForMRna".equals(cmd))
     251      {
     252        dc = sc.newDbControl();
     253       
     254        int numToSelect = Values.getInt(req.getParameter("numToSelect"));
     255       
     256        JSONObject jsonReq = (JSONObject)new JSONParser().parse(req.getReader());
     257        JSONArray jsonIgnore = (JSONArray)jsonReq.get("ignore");
     258       
     259        Float remainingQuantityLimit = JsonUtil.getAsFloat(jsonReq, "remainingQuantity");
     260        Float qualityScoreLimit = JsonUtil.getAsFloat(jsonReq, "qualityScore");
     261        boolean flagNotSelected = jsonReq.get("flag") != null;
     262        boolean reProcess = jsonReq.get("reProcess") != null;
     263       
     264        ItemQuery<Extract> query = Extract.getQuery();
     265        query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     266        Subtype.RNA.addFilter(dc, query);
     267        // Filter for RNA already included on the plate
     268        if (jsonIgnore != null && jsonIgnore.size() > 0)
     269        {
     270          query.restrict(Restrictions.not(Restrictions.in(Hql.property("id"), Expressions.parameter("ignore"))));
     271          query.setParameter("ignore", jsonIgnore, Type.LONG);
     272        }
     273       
     274        // Filter for non-empty creation date
     275        query.join(Hql.innerJoin("creationEvent", "ce"));
     276        query.restrict(Restrictions.neq(Hql.property("ce", "eventDate"), null));
     277        // Filter on parent != null (to get rid of 'Stratagene'
     278        query.restrict(Restrictions.neq(Hql.property("parent"), null));
     279       
     280        // Join AUTO_PROCESSING annotation
     281        query.join(Annotations.leftJoin(null, Annotationtype.AUTO_PROCESSING.load(dc), "ap"));
     282       
     283        // Create a subquery that load all RNA extracts that has at least one mRNA child extract
     284        ItemQuery<Extract> mrnaQuery = Extract.getQuery();
     285        mrnaQuery.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT);
     286        // Filter on RNA subtype
     287        Subtype.RNA.addFilter(dc, mrnaQuery);
     288       
     289        // Join child items and filter on mRNA subtype
     290        mrnaQuery.join(Hql.innerJoin("childCreationEvents", "cce"));
     291        mrnaQuery.join(Hql.innerJoin("cce", "event", "evt", null, false));
     292        mrnaQuery.join(Hql.innerJoin("evt", "bioMaterial", "bm", null, false));
     293        Subtype.MRNA.addFilter(dc, mrnaQuery, "bm");
     294       
     295        /* Create filter: AUTO_PROCESS==ReProcess OR (AUTO_PROCESS=null AND <no mrna children>) */
     296        Expression autoProcessing = Hql.alias("ap");
     297        query.restrict(
     298          Restrictions.nullSafeOr(
     299            reProcess ? Restrictions.eq(autoProcessing, Expressions.string("ReProcess")) : null,
     300            Restrictions.and(
     301              Restrictions.eq(autoProcessing, null),
     302              Restrictions.neq(Hql.property("id"), Expressions.all(mrnaQuery))
     303            )
     304          )
     305        );
     306       
     307        // Order by RNA plate and location: plate - row - column
     308        query.join(Hql.innerJoin(null, "bioWell", "w", true));
     309        query.join(Hql.innerJoin("w", "bioPlate", "bp", true));
     310        query.order(Orders.asc(Hql.property("bp", "name")));
     311        query.order(Orders.asc(Hql.property("w", "row")));
     312        query.order(Orders.asc(Hql.property("w", "column")));
     313        query.setMaxResults(numToSelect * 2);
     314       
     315        // Debug
     316        //json.put("query", query.toQl(dc));
     317
     318        JSONArray jsonRna = new JSONArray();
     319        JSONArray jsonFlagged = new JSONArray();
     320        ItemResultIterator<Extract> it = query.iterate(dc);
     321        try
     322        {
     323          String autoProcess = null;
     324          while (it.hasNext() && jsonRna.size() < numToSelect)
     325          {
     326            Extract rna = it.next();
     327            boolean okToProcess = true;
     328            Float remainingQuantity = rna.getRemainingQuantity();
     329           
     330            Rna r = Rna.get(rna);
     331            r.loadBioPlateLocation();
     332            Float qualityScore = r.loadRnaQc(dc);
     333            r.setAnnotation("remainingQuantity", remainingQuantity);
     334            r.loadAnnotations(dc, "NDConc", Annotationtype.ND_CONC, null);
     335           
     336            if (reProcess)
     337            {
     338              autoProcess = (String)Annotationtype.AUTO_PROCESSING.getAnnotationValue(dc, rna);
     339            }
     340           
     341            if (autoProcess == null)
     342            {
     343              if (remainingQuantityLimit != null)
     344              {
     345                if (remainingQuantity == null || remainingQuantity < remainingQuantityLimit)
     346                {
     347                  okToProcess = false;
     348                  r.setAnnotation("flag", Rna.FLAG_NOT_ENOUGH_REMAINING_QUANTITY);
     349                }
     350              }
     351              if (okToProcess && qualityScoreLimit != null)
     352              {
     353                if (qualityScore == null || qualityScore < qualityScoreLimit)
     354                {
     355                  okToProcess = false;
     356                  r.setAnnotation("flag", Rna.FLAG_LOW_QUALITY_SCORE);
     357                }
     358              }
     359            }
     360 
     361            if (okToProcess)
     362            {
     363              jsonRna.add(r.asJSONObject());
     364            }
     365            else if (flagNotSelected)
     366            {
     367              jsonFlagged.add(r.asJSONObject());
     368            }
     369          }
     370        }
     371        finally
     372        {
     373          it.close();
     374        }
     375       
     376        json.put("rna", jsonRna);
     377        json.put("flagged", jsonFlagged);
     378       
    368379      }
    369380      else if ("CreateMRnaPlate".equals(cmd))
Note: See TracChangeset for help on using the changeset viewer.