Changeset 1149


Ignore:
Timestamp:
Aug 25, 2009, 2:33:52 PM (14 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #240: Bead summary importer should have an option to fail if the number of skipped data lines get too high

File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/base2/net.sf.basedb.illumina/trunk/src/net/sf/basedb/illumina/plugins/BeadSummaryImporter.java

    r943 r1149  
    8787import net.sf.basedb.util.ChainedProgressReporter;
    8888import net.sf.basedb.util.MD5;
     89import net.sf.basedb.util.Values;
    8990import net.sf.basedb.util.error.ClassMapErrorHandler;
    9091import net.sf.basedb.util.error.ErrorHandler;
     
    146147      "This can for example happen if an incorrect array design is used.\n\n"+
    147148      "skip = Skip the current data line and continue\n"+
     149      "auto = Skip and continue unless the threshold is reached\n" +
    148150      "fail = Stop with an error message",
    149       new StringParameterType(255, "skip", false, 1, 0, 0,
    150         Arrays.asList( new String[] { "skip", "fail"} ))
     151      new StringParameterType(255, "auto", false, 1, 0, 0,
     152        Arrays.asList( new String[] { "skip", "auto", "fail"} ))
     153    );
     154
     155  private static final PluginParameter<String> thresholdParameter =
     156    new PluginParameter<String>(
     157      "featureMismatchThreshold",
     158      "Probe not found: threshold",
     159      "If the 'Probe not found' options is set to auto the plug-in will skip " +
     160      "data lines until the threshold is reached. If the threshold is reached, the " +
     161      "plug-in stops with an error message. The threshold can be given as a percentage " +
     162      "or as an absolute value.",
     163      new StringParameterType(255, "5%", false)
    151164    );
    152165 
     
    170183  */
    171184  private ClassMapErrorHandler errorHandler;
     185  private boolean useAutoFeatureMismatchErrorHandling;
     186  private String featureMismatchThreshold;
    172187
    173188 
     
    387402        storeValue(job, request, ri.getParameter(Parameters.DEFAULT_ERROR));
    388403        storeValue(job, request, featureMismatchErrorParameter);
     404        storeValue(job, request, thresholdParameter);
    389405        storeValue(job, request, ri.getParameter(Parameters.INVALID_USE_OF_NULL_ERROR));
    390406        storeValue(job, request, ri.getParameter(Parameters.NUMBER_FORMAT_ERROR));
     
    547563     
    548564      parameters.add(featureMismatchErrorParameter);
     565      parameters.add(thresholdParameter);
    549566      parameters.add(Parameters.invalidUseOfNullError(null, null, null));
    550567      parameters.add(Parameters.numberFormatError(null,
     
    792809        done++;
    793810      }
     811     
     812      if (useAutoFeatureMismatchErrorHandling)
     813      {
     814        int maxSkipped = 0;
     815        if (featureMismatchThreshold == null) featureMismatchThreshold = "5%";
     816        if (featureMismatchThreshold.endsWith("%"))
     817        {
     818          int percentage = Values.getInt(featureMismatchThreshold.substring(0, featureMismatchThreshold.length()-1));
     819          maxSkipped = (numLines * percentage) / 100;
     820        }
     821        else
     822        {
     823          maxSkipped = Values.getInt(featureMismatchThreshold);
     824        }
     825        if (batcher.getNumSkippedMissingFeature() > maxSkipped)
     826        {
     827          throw new BaseException("Too many 'Not found probes'. " +
     828            batcher.getNumSkippedMissingFeature() +
     829            " > threshold (" + featureMismatchThreshold + ")");
     830        }
     831      }
     832     
    794833      batcher.flush();
    795834      batcher.close();
     
    840879    ErrorHandler defaultErrorHandler = new SimpleErrorHandler("skip".equals(config.getValue("defaultError")));
    841880    errorHandler = new ClassMapErrorHandler(defaultErrorHandler);
    842     addErrorHandler(ItemNotFoundException.class,
    843       createErrorHandler((String)config.getValue("featureMismatchError"), defaultErrorHandler));
     881    String featureMismatchError = (String)config.getValue("featureMismatchError");
     882    useAutoFeatureMismatchErrorHandling = "auto".equals(featureMismatchError);
     883    if (useAutoFeatureMismatchErrorHandling)
     884    {
     885      addErrorHandler(ItemNotFoundException.class,
     886        createErrorHandler("skip", defaultErrorHandler));
     887      featureMismatchThreshold = (String)config.getValue("featureMismatchThreshold");
     888    }
     889    else
     890    {
     891      addErrorHandler(ItemNotFoundException.class,
     892        createErrorHandler(featureMismatchError, defaultErrorHandler));
     893    }
    844894    addErrorHandler(InvalidUseOfNullException.class,
    845895      createErrorHandler((String)config.getValue("invalidUseOfNullError"), defaultErrorHandler));
Note: See TracChangeset for help on using the changeset viewer.