diff --git a/src/main/java/htsjdk/samtools/util/AbstractProgressLogger.java b/src/main/java/htsjdk/samtools/util/AbstractProgressLogger.java index 4499c211aa..2b73cc8d76 100644 --- a/src/main/java/htsjdk/samtools/util/AbstractProgressLogger.java +++ b/src/main/java/htsjdk/samtools/util/AbstractProgressLogger.java @@ -23,6 +23,7 @@ abstract public class AbstractProgressLogger implements ProgressLoggerInterface private long lastStartTime = -1; private String lastChrom = null; private int lastPos = 0; + private String lastReadName = null; /** * Construct an AbstractProgressLogger. @@ -60,10 +61,18 @@ private synchronized void record() { if (this.lastChrom == null) readInfo = "*/*"; else readInfo = this.lastChrom + ":" + fmt.format(this.lastPos); + final String rnInfo; + if(lastReadName != null) { + rnInfo = ". Last read name: " + lastReadName; + } + else { + rnInfo = ""; + } + final long n = (this.processed % this.n == 0) ? this.n : this.processed % this.n; log(this.verb, " ", processed, " " + noun + ". Elapsed time: ", elapsed, "s. Time for last ", fmt.format(n), - ": ", period, "s. Last read position: ", readInfo); + ": ", period, "s. Last read position: ", readInfo, rnInfo); } /** @@ -80,10 +89,10 @@ public synchronized boolean log() { } } - @Override - public synchronized boolean record(final String chrom, final int pos) { + protected synchronized boolean record(final String chrom, final int pos, final String rname) { this.lastChrom = chrom; this.lastPos = pos; + this.lastReadName = rname; if (this.lastStartTime == -1) { this.lastStartTime = System.currentTimeMillis(); } @@ -96,6 +105,11 @@ public synchronized boolean record(final String chrom, final int pos) { } } + @Override + public synchronized boolean record(final String chrom, final int pos) { + return record(chrom, pos, null); + } + /** * Records that a given record has been processed and triggers logging if necessary. * @return boolean true if logging was triggered, false otherwise @@ -103,10 +117,10 @@ public synchronized boolean record(final String chrom, final int pos) { @Override public synchronized boolean record(final SAMRecord rec) { if (SAMRecord.NO_ALIGNMENT_REFERENCE_NAME.equals(rec.getReferenceName())) { - return record(null, 0); + return record(null, 0, rec.getReadName()); } else { - return record(rec.getReferenceName(), rec.getAlignmentStart()); + return record(rec.getReferenceName(), rec.getAlignmentStart(), rec.getReadName()); } }