Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
IndexingVariantContextWriter cleanup #706
Conversation
coveralls
commented
Sep 13, 2016
cmnbroad
was assigned
by droazen
Sep 13, 2016
| @@ -140,7 +141,7 @@ public void close() { | ||
| // close the index stream (keep it separate to help debugging efforts) | ||
| if (indexer != null) { | ||
| if (indexer instanceof TribbleIndexCreator) { | ||
| - setIndexSequenceDictionary((TribbleIndexCreator)indexer, refDict); | ||
| + ((TribbleIndexCreator)indexer).setIndexSequenceDictionary(refDict); |
cmnbroad
Sep 15, 2016
•
Contributor
I think if we're going to move setIndexSequenceDictionary so we can use it for other index types, we should just add it to the base interface (IndexCreator) with a default no-op implementation, and have TribbleIndexCreator override it. Then we can get rid of the instanceOf and downcast operators here, and other index types can use it if they choose to, or just ignore it.
| +* THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| +*/ | ||
| + | ||
| +package htsjdk.tribble.writers; |
cmnbroad
Sep 15, 2016
Contributor
There isn't anything tribble-specific about this, so I wouldn't extend the namespace for this one file. I would just put it in the htsjdk.util package where the other stream wrappers live.
magicDGS
Sep 16, 2016
Contributor
I will extend the namespace later, while addressing #701. But I will change it anyway.
| + * Wraps output stream in a manner which keeps track of the position within the file and allowing writes | ||
| + * at arbitrary points | ||
| + */ | ||
| +public final class PositionalOutputStream extends OutputStream implements LocationAware |
magicDGS
Sep 16, 2016
Contributor
Added a very simple test to check that the position is the expected one.
|
Addressed comments @cmnbroad -- back to you! Thanks for reviewing! |
coveralls
commented
Sep 16, 2016
| @@ -26,14 +26,14 @@ | ||
| package htsjdk.variant.variantcontext.writer; | ||
| import htsjdk.samtools.SAMSequenceDictionary; | ||
| -import htsjdk.samtools.SAMSequenceRecord; | ||
| import htsjdk.samtools.util.LocationAware; | ||
| import htsjdk.samtools.util.RuntimeIOException; | ||
| import htsjdk.tribble.index.DynamicIndexCreator; | ||
| import htsjdk.tribble.index.Index; | ||
| import htsjdk.tribble.index.IndexCreator; | ||
| import htsjdk.tribble.index.IndexFactory; | ||
| import htsjdk.tribble.index.TribbleIndexCreator; |
| + // check that write a byte array adds its length | ||
| + final byte[] bytes = new byte[]{1, 3, 5, 7}; | ||
| + wrapped.write(bytes); | ||
| + Assert.assertEquals(wrapped.getPosition(), bytes.length + 1); |
cmnbroad
Sep 16, 2016
Contributor
Thanks for adding this test. One minor request for clarity - can you keep the running count in a variable so that each assert doesn't need to recalculate the running total.
|
@magicDGS A couple of minor cleanup requests, then squash and rebase. Thx. |
coveralls
commented
Sep 17, 2016
|
Squashed and rebased. Ready to go, @cmnbroad. Thank you very much! |
magicDGS commentedSep 13, 2016
•
edited
Description
Checklist