Changeset 5076


Ignore:
Timestamp:
Aug 25, 2009, 11:15:41 AM (13 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #1362: Validate the number of raw data spots against the number of array design features

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/net/sf/basedb/util/overview/GenericOverview.java

    r4789 r5076  
    294294    Get the validation options currently in use.
    295295  */
     296  @Override
    296297  public ValidationOptions getValidationOptions()
    297298  {
  • trunk/src/core/net/sf/basedb/util/overview/OverviewContext.java

    r4768 r5076  
    6868  public Project getProject();
    6969
     70  /**
     71    Get the validation options that are currently in effect.
     72    @since 2.13
     73  */
     74  public ValidationOptions getValidationOptions();
     75 
    7076  /**
    7177    Store an auxilliary object in the overview cache. This is a service
  • trunk/src/core/net/sf/basedb/util/overview/OverviewUtil.java

    r4767 r5076  
    130130          Arrays.asList(new Validator[]
    131131          {
    132             Validator.NONMATHCING_ARRAYDESIGN, Validator.MULTIPLE_ARRAYDESIGNS,
     132            Validator.NONMATHCING_ARRAYDESIGN, Validator.NONMATCHING_SPOTCOUNT,
     133            Validator.MULTIPLE_ARRAYDESIGNS,
    133134            Validator.INCORRECT_PROTOCOLTYPE, Validator.INCORRECT_SOFTWARETYPE,
    134135            Validator.INCORRECT_HARDWARETYPE, Validator.INCORRECT_ARRAY_NUM,
  • trunk/src/core/net/sf/basedb/util/overview/ValidationOptions.java

    r4789 r5076  
    4444    Maps Validator ID to severity.
    4545  */
    46   private Map<String, Severity> options;
     46  private Map<String, Severity> severities;
     47 
     48  /**
     49    Other options. Key is validator ID + key
     50  */
     51  private Map<String, String> options;
    4752 
    4853  /**
     
    6267  public ValidationOptions(Preset preset)
    6368  {
    64     this.options = new HashMap<String, Severity>();
     69    this.severities = new HashMap<String, Severity>();
     70    this.options = new HashMap<String, String>();
    6571    if (preset != null) loadFromPreset(preset, true);
    6672  }
     
    7581  public Severity getSeverity(Validator validator)
    7682  {
    77     Severity option = options.get(validator.getId());
     83    Severity option = severities.get(validator.getId());
    7884    if (option == null) option = validator.getDefaultSeverity();
    7985    return option;
     
    8995    if (severity == null)
    9096    {
    91       options.remove(validator.getId());
     97      severities.remove(validator.getId());
    9298    }
    9399    else
    94100    {
    95       options.put(validator.getId(), severity);
     101      severities.put(validator.getId(), severity);
     102    }
     103  }
     104 
     105  /**
     106    Get the configured option for a validator rule.
     107   
     108    @param validator The validator
     109    @param key The key (name) of the option
     110    @param defaultValue The default value in case there is no configured value
     111    @return The value of the option
     112    @since 2.13
     113  */
     114  public String getOption(Validator validator, String key, String defaultValue)
     115  {
     116    String value =  options.get(validator.getId() + "+" + key);
     117    if (value == null) value = defaultValue;
     118    return value;
     119  }
     120 
     121  /**
     122    Set an option for a validator rule.
     123   
     124    @param validator The validator
     125    @param key The key (name) of the option
     126    @param value The value to set or null to remove the value
     127    @since 2.13
     128  */
     129  public void setOption(Validator validator, String key, String value)
     130  {
     131    key = validator.getId() + "+" + key;
     132    if (value == null)
     133    {
     134      options.remove(key);
     135    }
     136    else
     137    {
     138      options.put(key, value);
    96139    }
    97140  }
     
    109152  public void loadFromPreset(Preset preset, boolean clearFirst)
    110153  {
    111     if (clearFirst) options.clear();
     154    if (clearFirst)
     155    {
     156      severities.clear();
     157      options.clear();
     158    }
    112159    for (Map.Entry<String, String> entry : preset)
    113160    {
    114       options.put(entry.getKey(), Severity.valueOf(entry.getValue()));
     161      String key = entry.getKey();
     162      String value = entry.getValue();
     163      if (key.contains("+"))
     164      {
     165        options.put(key, value);
     166      }
     167      else
     168      {
     169        severities.put(key, Severity.valueOf(value));
     170      }
    115171    }
    116172  }
     
    123179  public void saveToPreset(net.sf.basedb.core.Presets.Preset preset)
    124180  {
    125     for (Map.Entry<String, Severity> entry : options.entrySet())
     181    for (Map.Entry<String, Severity> entry : severities.entrySet())
    126182    {
    127183      preset.setSetting(entry.getKey(), entry.getValue().name());
     184    }
     185    for (Map.Entry<String, String> entry : options.entrySet())
     186    {
     187      preset.setSetting(entry.getKey(), entry.getValue());
    128188    }
    129189  }
  • trunk/src/core/net/sf/basedb/util/overview/Validator.java

    r4789 r5076  
    438438      "array design as of the associated hybridization.",
    439439      "Array design mismatch", Severity.WARNING
     440    );
     441
     442  /**
     443    Validator rule that checks if the number of raw data spots
     444    are the same as the number of features (given a certain threshold).
     445    Default severity level is WARNING.
     446  */
     447  public static final Validator NONMATCHING_SPOTCOUNT = new Validator(
     448      "misc.nonmatchingspotcount", "Raw spots <> features",
     449      "Checks if the number of raw data spots matches the number of " +
     450      "array design features. A threshold can be given as either an " +
     451      "absolute number or as a percentage.",
     452      "Raw spots <> features", Severity.WARNING
    440453    );
    441454
  • trunk/src/core/net/sf/basedb/util/overview/validator/RawBioAssayValidator.java

    r4816 r5076  
    2525import java.util.Map;
    2626
     27import net.sf.basedb.core.ArrayDesign;
    2728import net.sf.basedb.core.DbControl;
    2829import net.sf.basedb.core.Hybridization;
     
    3132import net.sf.basedb.core.RawDataType;
    3233import net.sf.basedb.core.Scan;
     34import net.sf.basedb.util.Values;
    3335import net.sf.basedb.util.overview.Fix;
    3436import net.sf.basedb.util.overview.OverviewContext;
     
    4345  <li>Two raw bioassays from the same scan uses the same array index:
    4446    {@link Validator#DUPLICATE_ARRAY_NUM}
     47  <li>The number of raw data spots is different from the number of
     48    features on the array design: {@link Validator#NONMATCHING_SPOTCOUNT}.
    4549  </ul>
    4650
     
    129133    {}
    130134   
     135    if (rba.hasArrayDesign() && rba.hasData())
     136    {
     137      try
     138      {
     139        ArrayDesign design = rba.getArrayDesign();
     140        String threshold = context.getValidationOptions().getOption(
     141            Validator.NONMATCHING_SPOTCOUNT, "threshold", "5%");
     142       
     143        int numDbSpots = rba.getNumDbSpots();
     144        int numDbFeatures = design.getNumDbFeatures();
     145        int numFileSpots = rba.getNumFileSpots();
     146        int numFileFeatures = design.getNumFileFeatures();
     147        int maxDbDelta = 0;
     148        int maxFileDelta = 0;
     149        if (threshold.endsWith("%"))
     150        {
     151          int percentage = Values.getInt(threshold.substring(0, threshold.length()-1));
     152          if (numDbFeatures > 0) maxDbDelta = (numDbFeatures * percentage) / 100;
     153          if (numFileFeatures > 0) maxFileDelta = (numFileFeatures * percentage) / 100;
     154        }
     155        else
     156        {
     157          maxDbDelta = Values.getInt(threshold);
     158          maxFileDelta = maxDbDelta;
     159        }
     160       
     161       
     162        if (numDbSpots > 0 && Math.abs(numDbFeatures - numDbSpots) > maxDbDelta)
     163        {
     164          context.createFailure(Validator.NONMATCHING_SPOTCOUNT, node,
     165            "Raw spots (db) <> features by more than " + threshold + ": " +
     166            numDbSpots  + "<>" + numDbFeatures);
     167        }
     168        if (numFileSpots > 0 && Math.abs(numFileFeatures - numFileSpots) > maxFileDelta)
     169        {
     170          context.createFailure(Validator.NONMATCHING_SPOTCOUNT, node,
     171            "Raw spots (file) <> features by more than " + threshold + ": " +
     172            numFileSpots  + "<>" + numFileFeatures);
     173        }
     174       
     175      }
     176      catch (Exception ex)
     177      {}
     178    }
    131179  }
    132180
  • trunk/www/common/overview/index.jsp

    r4864 r5076  
    9696      }
    9797    }
     98    options.setOption(Validator.NONMATCHING_SPOTCOUNT, "threshold", request.getParameter("threshold"));
    9899    options.saveToPreset(presets.getDefault());
    99100    OverviewUtil.saveValidationPresets(sc);
     
    112113      }
    113114    }
     115    preset.setSetting(Validator.NONMATCHING_SPOTCOUNT.getId() + "+threshold",
     116        request.getParameter("threshold"));
    114117    OverviewUtil.saveValidationPresets(sc);
    115118    forward = "options.jsp";
  • trunk/www/common/overview/options.jsp

    r4745 r5076  
    5050final DbControl dc = sc.newDbControl();
    5151final String presetName = Values.getStringOrNull(request.getParameter("presetName"));
     52final boolean resetToDefault = Values.getBoolean(request.getParameter("resetToDefault"));
    5253try
    5354{
    5455  Presets presets = OverviewUtil.getValidationPresets(sc);
    55   ValidationOptions options = presetName == null ?
    56     new ValidationOptions() :
    57     new ValidationOptions(presets.getPreset(presetName));
     56  ValidationOptions options = null;
     57  if (resetToDefault)
     58  {
     59    options = new ValidationOptions();
     60  }
     61  else if (presetName == null)
     62  {
     63    options = new ValidationOptions(presets.getDefault());
     64  }
     65  else
     66  {
     67    options = new ValidationOptions(presets.getPreset(presetName));
     68  }
    5869  Map<String, List<Validator>> validators = OverviewUtil.getValidators();
    5970  %>
     
    128139    var frm = document.forms['options'];
    129140    var selected = frm.presets[frm.presets.selectedIndex].value;
    130     if (selected != '---')
    131     {
    132       location.href = 'options.jsp?ID=<%=ID%>&presetName='+escape(selected);
     141    if (selected == '')
     142    {
     143      location.href = 'options.jsp?ID=<%=ID%>&resetToDefault=1';
     144    }
     145    else if (selected != '---')
     146    {
     147      location.href = 'options.jsp?ID=<%=ID%>&presetName='+encodeURIComponent(selected);
    133148    }
    134149  }
     
    208223            />&nbsp;<b><%=HTML.encodeTags(title)%></b></a>&nbsp;&nbsp;
    209224          </td>
    210           <td style="padding-top: 6px;">
     225          <td style="padding-top: 6px;" colspan="3">
    211226            <select name="setall.<%=grp%>" onchange="setAllOnChange(<%=grp%>, this)">
    212227            <option value="">- set all in this group -
     
    243258              image="<%=hasNext ? "joust/big/join.gif" : "joust/big/joinbottom.gif"%>"
    244259              /><%=HTML.encodeTags(validator.getTitle())%>&nbsp;&nbsp;</td>
    245             <td>
     260            <td colspan="3">
    246261            <select id="select.<%=grp%>.<%=vld%>" name="<%=validatorId%>">
    247262              <%
     
    254269              %>
    255270            </select>
     271            <%
     272            if (validator == Validator.NONMATCHING_SPOTCOUNT)
     273            {
     274              %>
     275              Threshold:
     276              <input type="text" class="text"
     277                name="threshold"
     278                title="Threshold, as a percentage or an absolute value"
     279                size="8"
     280                value="<%=HTML.encodeTags(options.getOption(validator, "threshold", "5%"))%>" >
     281              <%
     282            }
     283            %>
    256284            </td>
    257285          </tr>
Note: See TracChangeset for help on using the changeset viewer.