Changeset 5941


Ignore:
Timestamp:
May 18, 2020, 8:15:51 AM (3 weeks ago)
Author:
Nicklas Nordborg
Message:

References #1239: Include Single Sample Predictor models in the StringTie? pipeline

Added some checks for configured models before they are used:

  • That an annotation type exists
  • That the .Rdata file exists


If a check fails a warning messge is displayed and the model can't be used.

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

Legend:

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

    r5937 r5941  
    8888        <!-- Each entry should have a 'name' and an associated 'annotation-type'. -->
    8989        <!-- The 'annotation-type-scores' is optional. If provided it is used to store list with all classes and scores -->
    90         <!-- A 'description' is optional. -->
    91         <!-- The annotation type need to be created manually. -->
    92         <model name="Subtype" annotation-type="SSP_Subtype" annotation-type-scores="SSP_Subtype_Scores" description="">
     90        <!-- The annotation types need to be created manually. -->
     91        <model name="Subtype" annotation-type="SSP_Subtype" annotation-type-scores="SSP_Subtype_Scores">
    9392          Training_Run19081Genes_noNorm_SSP.subtypeMost.Fcc15_5x5foldCV.num.rules.50_24.selRules.AIMS.GS.RData
    9493        </model>
  • extensions/net.sf.basedb.reggie/trunk/resources/analysis/ssp_start.js

    r5927 r5941  
    241241      var model = models[mNo];
    242242      html += '<tr class="align-top">';
    243       if (mNo == 0)
    244       {
    245         html += '<td class="prompt" rowspan="'+models.length+'">Models</td>';
    246       }
    247        
    248       html += '<td class="input">';
    249       html += '<label><input type="checkbox" checked name="model.'+mNo+'">'+Strings.encodeTags(model.name)+'</label>';
    250      
    251       if (mNo == 0)
    252       {
    253         html += '<td class="status" id="models.status" rowspan="'+models.length+'"></td>';
    254       }
    255       html += '<td class="help">';
    256       if (mNo == 0)
    257       {
    258         html += '<span id="models.message" class="message"></span>';
    259       }
    260       html += Strings.encodeTags(model.description) + '</td>';
     243      html += '<td class="subprompt"><label for="model.'+mNo+'">'+Strings.encodeTags(model.name)+'</label></td>';
     244      html += '<td style="width: 2em;"><input type="checkbox" name="model.'+mNo+'" id="model.'+mNo+'"></td>';
     245      html += '<td class="input"><div class="modeldescription">'+(Strings.encodeTags(model.description) || '&nbsp;')+'</div></td>';
     246      html += '<td class="status" id="model.'+mNo+'.status"></td>';
     247      html += '<td class="help"><span id="model.'+mNo+'.message" class="message"></span></td>';
    261248      html += '</tr>';
    262249    }
    263250    Doc.element('models').innerHTML = html;
    264    
    265     var checkboxes = Doc.element('models').getElementsByTagName('input');
    266     for (var i = 0; i < checkboxes.length; i++)
    267     {
    268       Events.addEventHandler(checkboxes[i], 'change', ssp.onModelSelected);
    269     }
    270     numModelsSelected = models.length;
    271     Wizard.setInputStatus('models', 'valid');
     251    Forms.linkCheckboxesWithLabels(Doc.element('models'));
     252   
     253    for (var mNo = 0; mNo < models.length; mNo++)
     254    {
     255      var model = models[mNo];
     256      var checkbox = Doc.element('model.'+mNo);
     257      if (model.error)
     258      {
     259        Wizard.setInputStatus('model.'+mNo, 'warning', model.error);
     260        checkbox.disabled = true;
     261      }
     262      else
     263      {
     264        checkbox.checked = true;
     265      }
     266      Events.addEventHandler(checkbox, 'change', ssp.onModelSelected);
     267    }
     268    ssp.onModelSelected();
    272269   
    273270    Wizard.setCurrentStep(2);
  • extensions/net.sf.basedb.reggie/trunk/resources/analysis/ssp_start.jsp

    r5927 r5941  
    2929  scripts="~../reggie-2.js,~ssp_start.js"
    3030  styles="path.css,~../css/reggie-2.css"
    31 />
     31>
     32<style>
     33.modeldescription
     34{
     35  font-style: italic;
     36  padding-bottom: 0.25em;
     37}
     38</style>
     39</base:head>
    3240<base:body>
    3341
     
    7381
    7482      <table class="step-form">
    75       <tbody id="models">
    76      
    77       </tbody>
     83        <td class="prompt">Models</td>
     84        <td class="input" colspan="2"></td>
     85        <td class="status" id="models.status"></td>
     86        <td class="help"><span id="models.message" class="message"></span>
     87          Select one or more SSP models to run.
     88        </td>
     89      </tr>
     90      <tbody id="models"></tbody>
    7891      </table>
    7992    </div>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/SspServlet.java

    r5927 r5941  
    33import java.io.IOException;
    44import java.util.ArrayList;
    5 import java.util.Collections;
    65import java.util.List;
    76
     
    1413import org.json.simple.JSONObject;
    1514
     15import net.sf.basedb.core.AnnotationType;
    1616import net.sf.basedb.core.DbControl;
    1717import net.sf.basedb.core.ItemList;
     
    121121      else if ("GetModels".equals(cmd))
    122122      {
     123        dc = sc.newDbControl();
    123124        JSONArray jsonModels = new JSONArray();
    124125        List<SspModel> models = SspModel.getConfiguredModels();
    125         Collections.sort(models);
     126        //Collections.sort(models);
    126127        for (SspModel m : models)
    127128        {
     129          AnnotationType at = m.getAnnotationType(dc);
     130         
    128131          JSONObject jsonModel = new JSONObject();
    129132          jsonModel.put("name", m.getName());
    130           jsonModel.put("description", m.getDescription());
     133          jsonModel.put("annotationType", m.getAnnotationTypeName());
     134          if (at != null)
     135          {
     136            jsonModel.put("description", at.getDescription());
     137          }
     138          else
     139          {
     140            jsonModel.put("error", "Can't find annotation type: " + m.getAnnotationTypeName());
     141          }
     142          if (!m.modelDataExists()) jsonModel.put("error", "Can't find file: "+m.getModelData());
    131143          jsonModels.add(jsonModel);
    132144        }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/ssp/SspModel.java

    r5937 r5941  
    8383 
    8484  private final String name;
    85   private final String description;
    8685  private final String modelData;
    8786  private final String annotationTypeName;
     
    9493  {
    9594    this.name = e.getAttributeValue("name");
    96     this.description = e.getAttributeValue("description");
    9795    this.modelData = e.getTextTrim();
    9896    this.annotationTypeName = e.getAttributeValue("annotation-type");
     
    116114    return modelData;
    117115  }
    118 
    119   /**
    120     Get a description of the model.
    121     Configured in reggie-config.xml, "description" attribute of the "model" tag.
    122   */
    123   public String getDescription()
    124   {
    125     return description;
     116 
     117  /**
     118    Check if the .Rdata file actually exists at the expected location.
     119  */
     120  public boolean modelDataExists()
     121  {
     122    XmlConfig config = Reggie.getConfig();
     123    // Check that files and directories exists
     124    String sourceDir = config.getConfig("rscript/ssp/path", null, null);
     125    String modelsDir = config.getConfig("rscript/ssp/models-dir", null, sourceDir + "/models");
     126    java.io.File rdataFile = new java.io.File(modelsDir, modelData);
     127    return rdataFile.isFile();
    126128  }
    127129 
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/ssp/SspPlugin.java

    r5937 r5941  
    510510  // ------------------------------------------------
    511511
    512   private PluginParameter<String> getSspModelsParameter()
     512  private PluginParameter<String> getSspModelsParameter(DbControl dc)
    513513  {
    514514    Enumeration<String, String> reportOptions = new Enumeration<String, String>();
    515515    List<SspModel> models = SspModel.getConfiguredModels();
    516     Collections.sort(models);
     516    //Collections.sort(models);
    517517    for (SspModel model : models)
    518518    {
    519       String name = model.getName();
    520       reportOptions.add(name, name);
     519      if (model.getAnnotationType(dc) != null && model.modelDataExists())
     520      {
     521        String name = model.getName();
     522        reportOptions.add(name, name);
     523      }
    521524    }
    522525
     
    528531 
    529532  private RequestInformation getConfigurePluginParameters()
    530   {   
     533  {
    531534    List<PluginParameter<?>> parameters = new ArrayList<PluginParameter<?>>();
    532     parameters.add(getSspModelsParameter());
     535    DbControl dc = null;
     536    try
     537    {
     538      dc = sc.newDbControl();
     539      parameters.add(getSspModelsParameter(dc));
     540    }
     541    finally
     542    {
     543      if (dc != null) dc.close();
     544    }
    533545   
    534546    RequestInformation configurePlugin = new RequestInformation
     
    579591        }
    580592      }
    581       parameters.add(getSspModelsParameter());
     593      parameters.add(getSspModelsParameter(dc));
    582594     
    583595      parameters.add(Parameters.errorSection(null, null));
Note: See TracChangeset for help on using the changeset viewer.