Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

helgridly
Copy link

Description

Running Picard SortSam to sort with queryname gave me output during that didn't tell me much about how done I was.

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

@codecov-io
Copy link

Codecov Report

Merging #1180 into master will decrease coverage by <.001%.
The diff coverage is 62.5%.

@@               Coverage Diff               @@
##              master     #1180       +/-   ##
===============================================
- Coverage     68.398%   68.398%   -<.001%     
- Complexity      8013      8015        +2     
===============================================
  Files            541       541               
  Lines          32688     32694        +6     
  Branches        5528      5529        +1     
===============================================
+ Hits           22358     22362        +4     
- Misses          8125      8128        +3     
+ Partials        2205      2204        -1
Impacted Files Coverage Δ Complexity Δ
...a/htsjdk/samtools/util/AbstractProgressLogger.java 41.379% <62.5%> (+0.995%) 7 <1> (+1) ⬆️
...samtools/util/AsyncBlockCompressedInputStream.java 72% <0%> (-4%) 12% <0%> (-1%)
...va/htsjdk/samtools/sra/SRAIndexedSequenceFile.java 64.865% <0%> (+2.703%) 7% <0%> (+1%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 74.359% <0%> (+7.692%) 8% <0%> (+1%) ⬆️

2 similar comments
@codecov-io
Copy link

Codecov Report

Merging #1180 into master will decrease coverage by <.001%.
The diff coverage is 62.5%.

@@               Coverage Diff               @@
##              master     #1180       +/-   ##
===============================================
- Coverage     68.398%   68.398%   -<.001%     
- Complexity      8013      8015        +2     
===============================================
  Files            541       541               
  Lines          32688     32694        +6     
  Branches        5528      5529        +1     
===============================================
+ Hits           22358     22362        +4     
- Misses          8125      8128        +3     
+ Partials        2205      2204        -1
Impacted Files Coverage Δ Complexity Δ
...a/htsjdk/samtools/util/AbstractProgressLogger.java 41.379% <62.5%> (+0.995%) 7 <1> (+1) ⬆️
...samtools/util/AsyncBlockCompressedInputStream.java 72% <0%> (-4%) 12% <0%> (-1%)
...va/htsjdk/samtools/sra/SRAIndexedSequenceFile.java 64.865% <0%> (+2.703%) 7% <0%> (+1%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 74.359% <0%> (+7.692%) 8% <0%> (+1%) ⬆️

@codecov-io
Copy link

Codecov Report

Merging #1180 into master will decrease coverage by <.001%.
The diff coverage is 62.5%.

@@               Coverage Diff               @@
##              master     #1180       +/-   ##
===============================================
- Coverage     68.398%   68.398%   -<.001%     
- Complexity      8013      8015        +2     
===============================================
  Files            541       541               
  Lines          32688     32694        +6     
  Branches        5528      5529        +1     
===============================================
+ Hits           22358     22362        +4     
- Misses          8125      8128        +3     
+ Partials        2205      2204        -1
Impacted Files Coverage Δ Complexity Δ
...a/htsjdk/samtools/util/AbstractProgressLogger.java 41.379% <62.5%> (+0.995%) 7 <1> (+1) ⬆️
...samtools/util/AsyncBlockCompressedInputStream.java 72% <0%> (-4%) 12% <0%> (-1%)
...va/htsjdk/samtools/sra/SRAIndexedSequenceFile.java 64.865% <0%> (+2.703%) 7% <0%> (+1%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 74.359% <0%> (+7.692%) 8% <0%> (+1%) ⬆️

@@ -23,6 +23,7 @@
private long lastStartTime = -1;
private String lastChrom = null;
private int lastPos = 0;
private String lastRN = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastReadName

rnInfo = ", last read name: " + lastRN;
} else {
rnInfo = "";
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting not consistent with the rest of the code

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);
Copy link
Member

Choose a reason for hiding this comment

The 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?

Copy link
Author

@helgridly helgridly Sep 19, 2018

Choose a reason for hiding this comment

The 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 setLogReadNames method, but I'm trying not to mess with the ProgressLoggerInterface so it'd only be available to subclasses of AbstractProgressLogger.

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

Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't do that for chr/pos

Copy link
Member

Choose a reason for hiding this comment

The 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).

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be done on construction?

@codecov-io
Copy link

Codecov Report

Merging #1180 into master will decrease coverage by <.001%.
The diff coverage is 62.5%.

@@               Coverage Diff               @@
##              master     #1180       +/-   ##
===============================================
- Coverage     68.398%   68.398%   -<.001%     
- Complexity      8013      8015        +2     
===============================================
  Files            541       541               
  Lines          32688     32694        +6     
  Branches        5528      5529        +1     
===============================================
+ Hits           22358     22362        +4     
- Misses          8125      8128        +3     
+ Partials        2205      2204        -1
Impacted Files Coverage Δ Complexity Δ
...a/htsjdk/samtools/util/AbstractProgressLogger.java 41.379% <62.5%> (+0.995%) 7 <1> (+1) ⬆️
...samtools/util/AsyncBlockCompressedInputStream.java 72% <0%> (-4%) 12% <0%> (-1%)
...va/htsjdk/samtools/sra/SRAIndexedSequenceFile.java 64.865% <0%> (+2.703%) 7% <0%> (+1%) ⬆️
...sjdk/samtools/util/Md5CalculatingOutputStream.java 74.359% <0%> (+7.692%) 8% <0%> (+1%) ⬆️

@@ -60,10 +61,18 @@ private synchronized void record() {
if (this.lastChrom == null) readInfo = "*/*";
else readInfo = this.lastChrom + ":" + fmt.format(this.lastPos);

final String rnInfo;
Copy link
Contributor

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 of rn 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

The 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 if on line 61) is preferable to committing new code that doesn't conform.

So here you'd add a space after if and delete the newline before else. IMO this is also an OK place to use a ternary op, but that's up to you.

Copy link
Member

@magicDGS magicDGS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not making this public API also in the ProgressLoggerInterface? Instead of read name, it can also log record names (might be useful for some other data sources). For the interface, you can use a default value not to break compatibility with other implementations...

Copy link
Contributor

Choose a reason for hiding this comment

The 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

@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The 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.

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);
Copy link
Member

Choose a reason for hiding this comment

The 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).

@samtools samtools deleted a comment from codecov-io Sep 24, 2018
@samtools samtools deleted a comment from codecov-io Sep 24, 2018
@samtools samtools deleted a comment from codecov-io Sep 24, 2018
@samtools samtools deleted a comment from codecov-io Sep 24, 2018
@yfarjoun yfarjoun added the Waiting for revisions This PR has received comments from reviewers and is waiting for the Author to respond label Sep 24, 2018
Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea of detecting if it's ordered by position and outputting read names only iff it's not seems reasonable. I've added my own helpful nitpicking formatting suggestion as well.

@@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The 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.

final String readNameInfo = lastReadName == null ? "" : ".  Last read name: " + lastReadName;

@lbergelson
Copy link
Member

Closing this since @yfarjoun has taken it over as #1302

@lbergelson lbergelson closed this Feb 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting for revisions This PR has received comments from reviewers and is waiting for the Author to respond
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants