Changeset 1544


Ignore:
Timestamp:
Feb 29, 2012, 2:36:08 PM (10 years ago)
Author:
Nicklas Nordborg
Message:

References #365: Export bioplate information to a file that can be used by the Caliper machine

Added CaliperSampleNameExporter. It can be used from Reggie or from the Bioplate view page (as an export plug-in).

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
4 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/META-INF/extensions.xml

    r1536 r1544  
    1515    <url>http://baseplugins.thep.lu.se/wiki/net.sf.basedb.reggie</url>
    1616  </about>
     17
     18  <plugin-definition id="CaliperSampleNameExporter">
     19    <about>
     20      <name>Caliper sample name exporter</name>
     21      <description>
     22        Plug-in that export the sample names on a bioplate to a
     23        CSV file that can be used by the Caliper software. The
     24        exported file has one line for each non-empty well with
     25        five columns. Only the first two columns are used:
     26        Well coordinate, sample name.
     27      </description>
     28    </about>
     29    <plugin-class>net.sf.basedb.reggie.plugins.CaliperSampleNameExporter</plugin-class>
     30    <settings>
     31      <property name="everyone-use">1</property>
     32      <property name="immediate-execution">1</property>
     33    </settings>
     34  </plugin-definition>
     35
    1736  <extension
    1837    id="net.sf.basedb.reggie"
  • extensions/net.sf.basedb.reggie/trunk/resources/css/reggie.css

    r1543 r1544  
    11@charset "UTF-8";
    22
    3 
     3.error a
     4{
     5  color: #FFFFFF;
     6  font-weight: bold;
     7  font-style: italic;
     8}
    49.stepform
    510{
  • extensions/net.sf.basedb.reggie/trunk/resources/index.jsp

    r1543 r1544  
    235235            <ul>
    236236            <li><a href="rnaqc_aliquot.jsp?ID=<%=ID%>">Create aliquots on Bioanalyzer/Caliper plates</a>
    237             <li><a href="rnaqc_plate_export.jsp?ID=<%=ID%>">Export Caliper plate information</a>
     237            <li><a href="rnaqc_plate_export.jsp?ID=<%=ID%>">Export Caliper sample name file</a>
    238238            <li><a href="rnaqc_plate_import.jsp?ID=<%=ID%>">Import RQS scores from Caliper data file</a>
    239239            </ul>
  • extensions/net.sf.basedb.reggie/trunk/resources/reggie.js

    r1543 r1544  
    109109  Main.show('errorMessage');
    110110  var buttons = Main.getElementsByTagAndClassName('div', 'buttonclass');
     111  if (buttons.length == 0) buttons = Main.getElementsByTagAndClassName('div', 'basicbutton');
    111112  for (var i = 0; i < buttons.length; i++)
    112113  {
  • extensions/net.sf.basedb.reggie/trunk/resources/rnaqc_aliquot.jsp

    r1543 r1544  
    133133  // Get more information about the selected rna
    134134  var request = Ajax.getXmlHttpRequest();
    135   var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetRnaInfo&id=' + id;   
     135  var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetRnaInfo&rnaId=' + id;   
    136136  request.open("GET", url, false); 
    137137  request.send(null);
     
    258258  var bioPlateId = frm.bioPlates[frm.bioPlates.selectedIndex].value;
    259259  var request = Ajax.getXmlHttpRequest();
    260   var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetFreeWellsInfo&id='+bioPlateId;   
     260  var url = 'RnaQc.servlet?ID=<%=ID%>&cmd=GetFreeWellsInfo&bioPlateId='+bioPlateId;   
    261261  request.open("GET", url, false); 
    262262  request.send(null);
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/BioplateType.java

    r1543 r1544  
    11package net.sf.basedb.reggie.dao;
     2
     3import java.lang.reflect.Field;
    24
    35import net.sf.basedb.core.BioPlate;
     
    3335  public static final BioplateType CALIPER_RNAQC =
    3436    new BioplateType("Caliper RNAQC reaction plate", Item.EXTRACT, Subtype.RNAQC, LockMode.LOCKED_AFTER_ADD);
     37
     38 
     39  /**
     40    Get the bioplate type by name of the static constant defined in this class.
     41   
     42    @param name The name of the static constant
     43    @return A bioplate type object or null if not found
     44   */
     45  public static BioplateType getByCName(String cName)
     46  {
     47    if (cName == null) return null;
     48    BioplateType bioplateType = null;
     49    try
     50    {
     51      Field f = BioplateType.class.getDeclaredField(cName);
     52      bioplateType = (BioplateType)f.get(null);
     53    }
     54    catch (NoSuchFieldException ex)
     55    {}
     56    catch (IllegalAccessException ex)
     57    {}
     58    catch (ClassCastException ex)
     59    {}
     60    return bioplateType;
     61  }
    3562
    3663 
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/ReactionPlate.java

    r1543 r1544  
    4141    <ul>
    4242    <li>Are not marked as destroyed
    43     <li>Have at least one free well
     43    <li>Have at least the specified number of free wells
    4444    <li>Have no value set for the 'run date' annotation
    4545    </ul>
    4646   
    4747    @param dc
     48    @param bioPlateType The required bioplate type, or null to not filter on bioplate type
    4849    @param subtype A biomaterial subtype, or null to not filter on subtype
    4950    @param runDateAnnotation The name of an annotation type, or null to not filter on annotation
    5051    @return
    5152  */
    52   public static List<ReactionPlate> findActiveByBioMaterialSubtype(DbControl dc, Subtype subtype, String runDateAnnotation)
     53  public static List<ReactionPlate> findActiveByBioMaterialSubtype(DbControl dc,
     54    BioplateType bioPlateType, Subtype subtype, int numFreeWells, String runDateAnnotation)
    5355  {
    5456    ItemQuery<BioPlate> query = BioPlate.getQuery();
    55     if (subtype != null)
     57    if (subtype != null || bioPlateType != null)
    5658    {
    5759      query.join(Hql.innerJoin("bioPlateType", "bpt"));
    58       subtype.addFilter(dc, query, "bpt");
     60      if (bioPlateType != null) bioPlateType.addFilter(dc, query, false);
     61      if (subtype != null) subtype.addFilter(dc, query, "bpt");
    5962    }
    6063   
    6164    query.restrict(Restrictions.eq(Hql.property("destroyed"), Expressions.parameter("destroyed", false, Type.BOOLEAN)));
    62     query.restrict(Restrictions.gt(Hql.property("freeWells"), Expressions.integer(0)));
     65    query.restrict(Restrictions.gteq(Hql.property("freeWells"), Expressions.integer(numFreeWells)));
    6366    if (runDateAnnotation != null)
    6467    {
     
    135138   
    136139    json.put("freeWells", plate.getFreeWells());
     140    json.put("usedWells", plate.getUsedWells());
    137141    json.put("barcode", plate.getBarcode());
    138142    json.put("rows", geometry.getRows());
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/Subtype.java

    r1543 r1544  
    11package net.sf.basedb.reggie.dao;
     2
     3import java.lang.reflect.Field;
    24
    35import org.json.simple.JSONObject;
     
    108110  }
    109111 
     112  /**
     113    Get the subtype by name of the static constant defined in this class.
     114   
     115    @param name The name of the static constant
     116    @return A subtype object or null if not found
     117    @since 2.4
     118  */
     119  public static Subtype getByCName(String cName)
     120  {
     121    if (cName == null) return null;
     122    Subtype subtype = null;
     123    try
     124    {
     125      Field f = Subtype.class.getDeclaredField(cName);
     126      subtype = (Subtype)f.get(null);
     127    }
     128    catch (NoSuchFieldException ex)
     129    {}
     130    catch (IllegalAccessException ex)
     131    {}
     132    catch (ClassCastException ex)
     133    {}
     134    return subtype;
     135  }
     136 
    110137  private final String name;
    111138  private final Item mainType;
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/RnaQcServlet.java

    r1543 r1544  
    22
    33import java.io.IOException;
     4import java.io.Writer;
    45import java.util.Date;
    56import java.util.List;
     
    2425import net.sf.basedb.core.ItemNotFoundException;
    2526import net.sf.basedb.core.ItemQuery;
     27import net.sf.basedb.core.Path;
    2628import net.sf.basedb.core.Protocol;
    2729import net.sf.basedb.core.SessionControl;
    2830import net.sf.basedb.reggie.Reggie;
     31import net.sf.basedb.reggie.dao.BioplateType;
    2932import net.sf.basedb.reggie.dao.ReactionPlate;
    3033import net.sf.basedb.reggie.dao.Rna;
    3134import net.sf.basedb.reggie.dao.Subtype;
     35import net.sf.basedb.reggie.plugins.CaliperSampleNameExporter;
    3236import net.sf.basedb.util.Coordinate;
    3337import net.sf.basedb.util.Values;
     
    7175          annotation.
    7276        */
    73         dc = sc.newDbControl();
    74         List<ReactionPlate> plates = ReactionPlate.findActiveByBioMaterialSubtype(dc, Subtype.RNAQC, Reggie.ANNOTATION_QC_RUN_DATE);
     77        int numFreeWells = Values.getInt(req.getParameter("numFreeWells"), 1);
     78        BioplateType bioPlateType = BioplateType.getByCName(req.getParameter("bioPlateType"));
     79       
     80        dc = sc.newDbControl();
     81        List<ReactionPlate> plates = ReactionPlate.findActiveByBioMaterialSubtype(dc,
     82            bioPlateType, Subtype.RNAQC, numFreeWells, Reggie.ANNOTATION_QC_RUN_DATE);
    7583       
    7684        JSONArray jsonPlates = new JSONArray();
     
    107115        */
    108116        dc = sc.newDbControl();
    109         int rnaId = Values.getInt(req.getParameter("id"));
     117        int rnaId = Values.getInt(req.getParameter("rnaId"));
    110118        Rna rna = Rna.getById(dc, rnaId);
    111119       
     
    139147          Get information about free wells on the requested plate
    140148        */
    141         int bioPlateId = Values.getInt(req.getParameter("id"));
     149        int bioPlateId = Values.getInt(req.getParameter("bioPlateId"));
    142150        dc = sc.newDbControl();
    143151        ReactionPlate plate = ReactionPlate.getById(dc, bioPlateId);
     
    147155        json.put("bioPlate", plate.asJSONObject());
    148156      }
    149      
     157      else if ("ExportSampleNamesForCaliper".equals(cmd))
     158      {
     159        /*
     160          Generate CSV file with sample names for the Caliper software
     161        */
     162        int bioPlateId = Values.getInt(req.getParameter("bioPlateId"));
     163        dc = sc.newDbControl();
     164        BioPlate plate = BioPlate.getById(dc, bioPlateId);
     165       
     166        resp.setHeader("Content-Disposition", "attachment; filename=" + Path.makeSafeFilename(plate.getName(), "") + ".csv");
     167        resp.setContentType("text/csv");
     168        resp.setCharacterEncoding("UTF-8");
     169        Writer out = resp.getWriter();
     170        CaliperSampleNameExporter exporter = new CaliperSampleNameExporter();
     171        exporter.exportSampleNames(dc, plate, out);
     172 
     173        out.flush();
     174        out.close();
     175      }
    150176     
    151177    }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SubtypeServlet.java

    r1543 r1544  
    22
    33import java.io.IOException;
    4 import java.lang.reflect.Field;
    54
    65import javax.servlet.ServletException;
     
    1312import net.sf.basedb.core.Application;
    1413import net.sf.basedb.core.DbControl;
     14import net.sf.basedb.core.ItemNotFoundException;
    1515import net.sf.basedb.core.SessionControl;
    1616import net.sf.basedb.reggie.dao.Subtype;
     
    5757        */
    5858        String name = req.getParameter("name");
    59         Field f = Subtype.class.getDeclaredField(name);
    60         Subtype subtype = (Subtype)f.get(null);
     59        Subtype subtype = Subtype.getByCName(name);
     60        if (subtype == null)
     61        {
     62          throw new ItemNotFoundException("Subtype." + name);
     63        }
    6164       
    6265        dc = sc.newDbControl();
Note: See TracChangeset for help on using the changeset viewer.