diff --git a/java/src/org/broadinstitute/sting/utils/FileProgressTracker.java b/java/src/org/broadinstitute/sting/utils/FileProgressTracker.java deleted file mode 100644 index e9291cd2a..000000000 --- a/java/src/org/broadinstitute/sting/utils/FileProgressTracker.java +++ /dev/null @@ -1,189 +0,0 @@ -package org.broadinstitute.sting.utils; - -import org.apache.log4j.Logger; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.nio.channels.FileChannel; - -/** - * Created by IntelliJ IDEA. - * User: mdepristo - * Date: Mar 2, 2009 - * Time: 2:25:18 PM - * - * This class is intended to track the reading of files composed of records of approximately equivalent - * size. It can be used to estimate time to completion, complete read, performance of io, etc. - * - */ -public class FileProgressTracker implements Iterator { - private static int DEFAULT_HISTORY_SIZE = 1000; - - private int historySize = DEFAULT_HISTORY_SIZE; - private int samplingFrequency = 1000; - private File file; - private FileChannel channel; - private ArrayList history; - private long nNexts = 0; - private Iterator it = null; - private long startTime = -1; - private int historyI = 0; - - public FileProgressTracker( File file, Iterator it, FileChannel channel, int historySize ) { - this.file = file; - this.channel = channel; - this.it = it; - this.historySize = historySize; - this.history = new ArrayList(Collections.nCopies(historySize, 0L)); - startTime = System.currentTimeMillis(); - } - - public FileProgressTracker( File file, Iterator it, FileChannel channel ) { - this(file, it, channel, DEFAULT_HISTORY_SIZE); - } - - /** - * our log, which we want to capture anything from this class - */ - private static Logger logger = Logger.getLogger(FileProgressTracker.class); - - - // ----------------------------------------------------------------- - // - // iterator support - // - // ----------------------------------------------------------------- - public boolean hasNext() { return it.hasNext(); } - - public T next() { - T x = it.next(); - if ( nNexts % samplingFrequency == 0 ) { - inc(); - //printStatus(); - } - nNexts++; - return x; - } - - public void remove () { - it.remove(); - } - - /** - * Fundamental operation -- must be called ever time a record is read from the file - * Enables the system to track the relationship between file byte offsets and record - * sizes. - */ - public void inc() { - int i = historyIndex(); - long pos = getPosition(); - history.set(i, pos); - historyI++; - -// for ( long x : history ) { -// System.out.printf("%d ", x); -// } -// System.out.printf("%n"); -// -// for ( long x : recordSizes() ) { -// System.out.printf("%d ", x); -// } -// System.out.printf("%n"); - } - - public long nRecordsProcessed() { - return nNexts; - } - - public double elapsedTimeInSecs() { - return (System.currentTimeMillis() - startTime) / 1000.0; - } - - public int historyIndex() { - return historyIndex(historyI); - } - public int historyIndex(long index) { - return (int)((index + historySize) % historySize); - } - - public int averageRecordSize() { - return Math.round((int)Utils.average(recordSizes(), Math.min(historyI - 1, historySize)) / samplingFrequency); - } - - public double processingRate() { - return nRecordsProcessed() / elapsedTimeInSecs(); - } - - public long estRecordsInFile() { - return (long)(getFileSize() / Math.max(averageRecordSize(),1)); - } - - public double estFractionProgressThroughFile() { - return (1.0 * nRecordsProcessed()) / estRecordsInFile(); - } - - public double estTimeTotal() { - return estRecordsInFile() / processingRate(); - } - - public double estTimeRemaining() { - return estTimeTotal() * ( 1 - estFractionProgressThroughFile() ); - } - - public void printStatus() { - logger.debug(String.format("FileProgressTracker:%n")); - logger.debug(String.format(" -> File size is: %d%n", getFileSize())); - logger.debug(String.format(" -> Sampling depth: %d%n", historyI)); - logger.debug(String.format(" -> File position: %d%n", getPosition())); - logger.debug(String.format(" -> Number of records processed: %d%n", nRecordsProcessed())); - logger.debug(String.format(" -> Average record size is %d%n", averageRecordSize())); - logger.debug(String.format(" -> Elapsed time in secs is %.2f%n", elapsedTimeInSecs())); - logger.debug(String.format(" -> Processing rate (records per second) %.2f%n", processingRate())); - logger.debug(String.format(" -> Estimated number of records in file %d%n", estRecordsInFile())); - logger.debug(String.format(" -> Estimated percent progress through file %.2f%n", estFractionProgressThroughFile() * 100.0)); - logger.debug(String.format(" -> Estimated time for entire processing %.2f hrs / %.2f min / %.2f sec%n", estTimeTotal() / (60*60), estTimeTotal() / (60), estTimeTotal())); - logger.debug(String.format(" -> Estimated time remaining %.2f hrs / %.2f min / %.2f sec%n", estTimeRemaining() / (60*60), estTimeRemaining() / 60, estTimeRemaining())); - } - - public String progressMeter() { - //printStatus(); - return String.format("Est. %.2f%% completed, time remaining (%.2f hrs / %.2f min) of (%.2f hrs / %.2f min) total", - estFractionProgressThroughFile() * 100.0, - estTimeRemaining() / (60*60), estTimeRemaining() / 60, - estTimeTotal() / (60*60), estTimeTotal() / (60)); - } - - public ArrayList recordSizes() { - ArrayList sizes = new ArrayList(history); - for ( int i = 0; i < historySize; i++ ) { - long val = 0; - if ( history.get(historyIndex(i)) >= history.get(historyIndex(i-1) ) ) - val = history.get(historyIndex(i)) - history.get(historyIndex(i-1)); - sizes.set(i, val); - } - -// for ( long size : sizes ) { -// System.out.printf("%d ", size); -// } -// System.out.printf("%n"); - - return sizes; - } - - private final long getPosition() { - try { - return channel.position(); - } catch ( IOException e ) { - return 0; - } - } - - private final long getFileSize() { - return file.length(); - } - - -} diff --git a/java/src/org/broadinstitute/sting/utils/windowmaker/PositionalDataGenerator.java b/java/src/org/broadinstitute/sting/utils/windowmaker/PositionalDataGenerator.java deleted file mode 100755 index 37c3e46ae..000000000 --- a/java/src/org/broadinstitute/sting/utils/windowmaker/PositionalDataGenerator.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.broadinstitute.sting.utils.windowmaker; - -import org.broadinstitute.sting.utils.GenomeLoc; -import org.broadinstitute.sting.utils.Pair; - -import java.util.Iterator; - -/** - * Created by IntelliJ IDEA. - * User: depristo - * Date: Apr 14, 2009 - * Time: 9:33:00 AM - * To change this template use File | Settings | File Templates. - */ -public interface PositionalDataGenerator { - public Pos lastPos(); -} \ No newline at end of file diff --git a/java/src/org/broadinstitute/sting/utils/windowmaker/WindowMaker.java b/java/src/org/broadinstitute/sting/utils/windowmaker/WindowMaker.java deleted file mode 100755 index a10457dae..000000000 --- a/java/src/org/broadinstitute/sting/utils/windowmaker/WindowMaker.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.broadinstitute.sting.utils.windowmaker; - -import org.broadinstitute.sting.utils.Pair; - -import java.util.ArrayList; - -/** - * System for allowing "windowed" access into a data stream - * - * User: depristo - * Date: May 1, 2009 - * Time: 3:03:20 PM - * To change this template use File | Settings | File Templates. - */ -public abstract class WindowMaker { - private PositionalDataGenerator dataSource; - - public WindowMaker(PositionalDataGenerator pdg) - { - dataSource = pdg; - } - - /** - * - */ - public abstract boolean hasNext(); - - /** - * Get the next object in the stream. Does not advance the stream pointer. Successive peek() - * calls return the same object. - * - * @return - */ - public abstract Pair peek(); - - /** - * Return the next N objects in the stream. Does not advance the stream pointer. Successive peek() - * calls return the same Array of Objects. - * - * @param N - * @return - */ - public abstract ArrayList> peek(int N); - - /** - * Pop the leftmost object off the window - */ - public abstract void pop(); - - /** - * Pop the leftmost N objects off the window - * @param N - */ - public abstract void pop(int N); - - /** - * Advance the internal stream pointer to from, collect all data until to, and return the data - * from -> to as an ArrayList - * - * @param from - * @param to - * @return - */ - public abstract ArrayList> speek(Pos from, Pos to); - - /** - * Advance the internal stream pointer to from, collect N data units, and return the data - * as an ArrayList - * - * @param from - * @param length - * @return - */ - public abstract ArrayList> speek(Pos from, int N); - - - /** - * Advance the internal stream pointer to from, collect all remaining data units from the - * data stream, and return them all as one (potentially large) arraylist - * - * @param from - * @return - */ - public abstract ArrayList> speek(Pos from); -}