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

Proposed replacement for progress PR #1302

Merged
merged 11 commits into from
Mar 22, 2019
Merged

Conversation

yfarjoun
Copy link
Contributor

This PR is a replacement for #1180. it adds the feature that the read-name printing is only turned on after the logger notices 1000 incidents where the position was decreasing.

More exactly: The logger keep a counter that increments when the position is decreasing and vice versa (but remains non-negative) If this counter is greater than 1000, the logger will also emit read-names.

@codecov-io
Copy link

codecov-io commented Feb 22, 2019

Codecov Report

Merging #1302 into master will increase coverage by 1.657%.
The diff coverage is 67.647%.

@@               Coverage Diff               @@
##              master     #1302       +/-   ##
===============================================
+ Coverage     67.644%   69.301%   +1.657%     
- Complexity      8188      9321     +1133     
===============================================
  Files            560       563        +3     
  Lines          33462     36757     +3295     
  Branches        5635      6502      +867     
===============================================
+ Hits           22635     25473     +2838     
- Misses          8644      8958      +314     
- Partials        2183      2326      +143
Impacted Files Coverage Δ Complexity Δ
src/main/java/htsjdk/samtools/util/Log.java 59.016% <33.333%> (ø) 17 <0> (ø) ⬇️
...a/htsjdk/samtools/util/AbstractProgressLogger.java 53.425% <70.968%> (+10.832%) 13 <8> (+6) ⬆️
...ava/htsjdk/samtools/cram/structure/CramHeader.java 41.026% <0%> (-6.974%) 9% <0%> (+2%)
.../main/java/htsjdk/samtools/util/ftp/FTPClient.java 17.094% <0%> (-6.077%) 7% <0%> (+1%)
.../java/htsjdk/samtools/util/IntervalListWriter.java 86.364% <0%> (-1.636%) 4% <0%> (-1%)
...java/htsjdk/samtools/cram/structure/Container.java 93.636% <0%> (-1.1%) 28% <0%> (+15%)
...c/main/java/htsjdk/samtools/util/IntervalList.java 73.585% <0%> (-0.834%) 129% <0%> (+55%)
src/main/java/htsjdk/samtools/util/Interval.java 63.043% <0%> (-0.593%) 50% <0%> (+24%)
...va/htsjdk/samtools/SAMSequenceDictionaryCodec.java 86.957% <0%> (-0.543%) 12% <0%> (+6%)
...ain/java/htsjdk/samtools/util/MergingIterator.java 85.417% <0%> (-0.298%) 18% <0%> (+7%)
... and 62 more

this.lastStartTime = System.currentTimeMillis();
protected synchronized boolean record(final String chrom, final int pos, final String rname) {
lastChrom = chrom;
if (pos >= lastPos) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

only increase counter when chrom name is unchanged, and do not decrease counter.

}

/** Left pads a string until it is at least the given length. */
private String pad (String in, final int length) {
while (in.length() < length) {
in = " " + in;
final StringBuilder inBuilder = new StringBuilder(in);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

preallocate the builder

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewrite to avoid silliness.

@lbergelson lbergelson self-requested a review February 25, 2019 19:59
@lbergelson lbergelson added the Waiting for revisions This PR has received comments from reviewers and is waiting for the Author to respond label Feb 25, 2019
@yfarjoun
Copy link
Contributor Author

@lbergelson this is ready for a review...

@lbergelson lbergelson assigned lbergelson and unassigned yfarjoun Mar 18, 2019
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.

@yfarjoun This seems much better. A few minor comments and then 👍

private int lastPos = 0;
private String lastReadName = null;
private long countNonIncreasing = 0;
final private long PRINT_READ_NAME_THRESHOLD = 1000;
Copy link
Member

Choose a reason for hiding this comment

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

might as well make this static

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

private String pad (String in, final int length) {
while (in.length() < length) {
in = " " + in;
protected static String pad(final String in, final int length) {
Copy link
Member

Choose a reason for hiding this comment

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

make this default package instead of protected.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

("hello", 5, "hello"),
("hello", 4, "hello"),
("hello", -1, "hello")).foreach { case (in, len, expected) =>
AbstractProgressLogger.pad(in, len) shouldEqual expected
Copy link
Member

Choose a reason for hiding this comment

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

The formatting seems really weird here, but maybe that's scala standard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah.that's the default intellij formatting

@yfarjoun yfarjoun merged commit 9f5d86e into master Mar 22, 2019
@yfarjoun yfarjoun deleted the yf_he_progresslogger_rns branch March 22, 2019 13:47
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.

3 participants