-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
progress logger logs read name too #1180
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is nitpicky, but I'd probably make this block into a one liner since it's really just an assignment.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding the previous comments about formatting, I think we should be pushing the code to a consistent style based on the Sun/Oracle java style guidelines. Reformatting non-conforming code (such as the So here you'd add a space after |
||
rnInfo = ". Last read name: " + lastReadName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like this to say "record" instead of "read", to be able to log non-reads record names. |
||
} | ||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes read names are really long, or we don't want them in the log, can we just turn this off? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can make a protected alternate constructor with the bool explicit and/or a IMO this should roll out by default and folks can turn it off if they specifically object. I'll let the hivemind chime in if there are objections to more-useful-by-default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perhaps the logger can figure out if the records are sorted or not, and only emit readnames when they are not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it doesn't do that for chr/pos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will also vote for default to a switch for this feature, and default to off (to keep the previous behaviour). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @helgridly: I think that if you add the feature that the logger will output readname only after it notices that the records are not coordinate-sorted, this will be a good compromise between, providing information and terseness. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. providing a switch would require adding yet another Default setting to HTSJDK which is gross. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cannot be done on construction? |
||
} | ||
|
||
/** | ||
|
@@ -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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not making this public API also in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is clearly scope-creep. I would hold-off on requesting that from the OP |
||
this.lastChrom = chrom; | ||
this.lastPos = pos; | ||
this.lastReadName = rname; | ||
if (this.lastStartTime == -1) { | ||
this.lastStartTime = System.currentTimeMillis(); | ||
} | ||
|
@@ -96,17 +105,22 @@ 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 | ||
*/ | ||
@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()); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
readName
instead ofrn
here? That would match what the rest of the code here does. Also, I believe that abbreviations like this make the code harder to read.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍