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

new Interface VCFIterator extends CloseableIterator<VariantContext> (continued) #1245

Merged
merged 20 commits into from
Dec 19, 2018
Merged

Conversation

romanzenka
Copy link
Contributor

Description

This is a PR based on #837 - the only difference is addressing the reviewer comments + a little bit of extra testing.

My purpose is to continue "carrying the torch" of the original PR by @lindenb until successful completion, as I could REALLY use the VCFIterator interface.

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-io commented Dec 19, 2018

Codecov Report

Merging #1245 into master will increase coverage by 0.045%.
The diff coverage is 85%.

@@               Coverage Diff               @@
##              master     #1245       +/-   ##
===============================================
+ Coverage     69.359%   69.404%   +0.045%     
- Complexity      8143      8156       +13     
===============================================
  Files            547       548        +1     
  Lines          32649     32691       +42     
  Branches        5517      5521        +4     
===============================================
+ Hits           22645     22689       +44     
+ Misses          7784      7783        -1     
+ Partials        2220      2219        -1
Impacted Files Coverage Δ Complexity Δ
src/main/java/htsjdk/variant/bcf2/BCF2Codec.java 76.19% <100%> (+0.73%) 33 <1> (+1) ⬆️
src/main/java/htsjdk/samtools/SamStreams.java 72.308% <100%> (+1.255%) 19 <1> (ø) ⬇️
...rc/main/java/htsjdk/samtools/SamReaderFactory.java 67.464% <100%> (ø) 7 <0> (ø) ⬇️
src/main/java/htsjdk/samtools/util/IOUtil.java 57.143% <56.25%> (+0.187%) 115 <3> (+1) ⬆️
...in/java/htsjdk/variant/vcf/VCFIteratorBuilder.java 94.595% <94.595%> (ø) 9 <9> (?)
...htsjdk/tribble/readers/LongLineBufferedReader.java 30.286% <0%> (+1.143%) 15% <0%> (+1%) ⬆️
src/main/java/htsjdk/variant/bcf2/BCFVersion.java 94.737% <0%> (+10.526%) 7% <0%> (+1%) ⬆️

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.

@romanzenka Thank you for taking this on and doing the rebase / resolving the last round of comments. @lindenb Thank you for doing this work initially.

I wrote a bunch of nitpicky comments, but i'm going to resolve them myself in a future pr rather than delay this longer.

@@ -66,26 +66,11 @@ public static boolean isBAMFile(final InputStream stream)
/**
* Checks whether the file is a gzipped sam file. Returns true if it
* is and false otherwise.
* @see @link IOUtil#isGZIPInputStream(InputStream)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @see @link IOUtil#isGZIPInputStream(InputStream)
* @deprecated use {@link IOUtil#isGZIPInputStream(InputStream)} instead

@@ -1157,6 +1155,38 @@ public static Path toPath(File fileOrNull) {
return files.stream().map(File::toPath).collect(Collectors.toList());
}

/** number of bytes that will be read for the GZIP-header in the function {@link #isGZIPInputStream(InputStream)} */
public static final int GZIP_HEADER_READ_LENGTH = 8000;
Copy link
Member

Choose a reason for hiding this comment

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

Could you stick this at the top of the file with the other constants?

* @param stream the input stream.
* @return true if `stream` starts with a gzip signature
* @throws IllegalArgumentException if `stream` cannot mark or reset the stream
* @see SamStreams#isGzippedSAMFile(InputStream)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @see SamStreams#isGzippedSAMFile(InputStream)

We can drop this pointer to the old method.

* @see SamStreams#isGzippedSAMFile(InputStream)
*/
public static boolean isGZIPInputStream(final InputStream stream) {
/* this function was previously implemented in SamStreams.isGzippedSAMFile */
Copy link
Member

Choose a reason for hiding this comment

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

You don't need this comment.

Suggested change
/* this function was previously implemented in SamStreams.isGzippedSAMFile */

// wrap the input stream into a BufferedInputStream to reset/read a BCFHeader or a GZIP
// buffer must be large enough to contain the BCF header and/or GZIP signature
BufferedInputStream bufferedinput = new BufferedInputStream(in, Math.max(
BCF2Codec.SIZEOF_BCF_HEADER,
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 just put these one one line, but that's just a very minor nitpick.

if(IOUtil.isGZIPInputStream(bufferedinput)) {
// this is a gzipped input stream, wrap it into GZIPInputStream
// and re-wrap it into BufferedInputStream so we can test for the BCF header
bufferedinput = new BufferedInputStream(
Copy link
Member

Choose a reason for hiding this comment

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

same here

throw new IllegalStateException("Could not reset stream.");
}
}
return IOUtil.isGZIPInputStream(stream);
Copy link
Member

Choose a reason for hiding this comment

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

There's a new use of this deprecated method in VCFHeaderReader. It should be migrated.

@lbergelson lbergelson merged commit 2473407 into samtools:master Dec 19, 2018
lbergelson added a commit that referenced this pull request Dec 19, 2018
@lindenb
Copy link
Contributor

lindenb commented Dec 19, 2018

🎉

lbergelson added a commit that referenced this pull request Dec 19, 2018
lbergelson added a commit that referenced this pull request Dec 19, 2018
@romanzenka romanzenka deleted the vcfiter branch December 20, 2018 01:32
@romanzenka
Copy link
Contributor Author

I was going to resolve the "nitpicks", but it looks like you've done it alraedy. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants