/** * Creates a new DownsamplingIterator using the supplied Strategy that attempts to read from the provided iterator and return * approximately proportion of the records read. * * @param iterator The iterator from which to consume SAMRecords * @param strategy The downsampling strategy to use * @param proportion The proportion of records the downsampling strategy should attempt to emit * @param accuracy If supported by the downsampling strategy, the accuracy goal for the downsampler. Higher accuracy will generally * require higher memory usage. An accuracy value of 0.0001 tells the strategy to try and ensure the emitted proportion * is within proportion +/0 0.0001. * @param seed The seed value to use for any random process used in down-sampling. */ public static DownsamplingIterator make(final Iterator<SAMRecord> iterator, final Strategy strategy, final double proportion, final double accuracy, final int seed) { if (strategy == null) throw new IllegalArgumentException("strategy may not be null"); if (iterator == null) throw new IllegalArgumentException("iterator may not be null"); if (proportion < 0) throw new IllegalArgumentException("proportion must be greater than 0"); if (proportion > 1) throw new IllegalArgumentException("proportion must be less than 1"); switch (strategy) { case HighAccuracy: return new HighAccuracyDownsamplingIterator(iterator, proportion, seed).setTargetAccuracy(accuracy); case ConstantMemory: return new ConstantMemoryDownsamplingIterator(iterator, proportion, seed); case Chained: return new ChainedDownsamplingIterator(iterator, proportion, seed).setTargetAccuracy(accuracy); default: throw new IllegalStateException("Unexpected value for Strategy enum in switch statement. Bug!!"); } }
/** * Creates a new DownsamplingIterator using the supplied Strategy that attempts to read from the provided iterator and return * approximately proportion of the records read. * * @param iterator The iterator from which to consume SAMRecords * @param strategy The downsampling strategy to use * @param proportion The proportion of records the downsampling strategy should attempt to emit * @param accuracy If supported by the downsampling strategy, the accuracy goal for the downsampler. Higher accuracy will generally * require higher memory usage. An accuracy value of 0.0001 tells the strategy to try and ensure the emitted proportion * is within proportion +/0 0.0001. * @param seed The seed value to use for any random process used in down-sampling. */ public static DownsamplingIterator make(final Iterator<SAMRecord> iterator, final Strategy strategy, final double proportion, final double accuracy, final int seed) { if (strategy == null) throw new IllegalArgumentException("strategy may not be null"); if (iterator == null) throw new IllegalArgumentException("iterator may not be null"); if (proportion < 0) throw new IllegalArgumentException("proportion must be greater than 0"); if (proportion > 1) throw new IllegalArgumentException("proportion must be less than 1"); switch (strategy) { case HighAccuracy: return new HighAccuracyDownsamplingIterator(iterator, proportion, seed).setTargetAccuracy(accuracy); case ConstantMemory: return new ConstantMemoryDownsamplingIterator(iterator, proportion, seed); case Chained: return new ChainedDownsamplingIterator(iterator, proportion, seed).setTargetAccuracy(accuracy); default: throw new IllegalStateException("Unexpected value for Strategy enum in switch statement. Bug!!"); } }