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

Add support for re-serializing (sharding and reassembling) CRAM containers. #1609

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cmnbroad
Copy link
Collaborator

@cmnbroad cmnbroad commented May 3, 2022

Fixes #1606.

@cmnbroad cmnbroad force-pushed the cn_rewrite_containers branch 2 times, most recently from cd08c69 to f0e32c6 Compare May 3, 2022 23:54
@codecov-commenter
Copy link

codecov-commenter commented May 4, 2022

Codecov Report

Merging #1609 (fd7cb83) into master (f461401) will increase coverage by 0.028%.
The diff coverage is 94.737%.

@@               Coverage Diff               @@
##              master     #1609       +/-   ##
===============================================
+ Coverage     69.838%   69.866%   +0.028%     
- Complexity      9666      9677       +11     
===============================================
  Files            703       704        +1     
  Lines          37690     37728       +38     
  Branches        6121      6124        +3     
===============================================
+ Hits           26322     26359       +37     
- Misses          8914      8916        +2     
+ Partials        2454      2453        -1     
Impacted Files Coverage Δ
...a/htsjdk/samtools/CRAMContainerStreamRewriter.java 92.000% <92.000%> (ø)
...java/htsjdk/samtools/cram/structure/Container.java 84.783% <100.000%> (+0.692%) ⬆️
...tsjdk/samtools/cram/structure/ContainerHeader.java 86.364% <100.000%> (+0.426%) ⬆️
...ain/java/htsjdk/samtools/cram/structure/Slice.java 82.873% <100.000%> (+0.422%) ⬆️
src/main/java/htsjdk/io/AsyncWriterPool.java 72.222% <0.000%> (-1.389%) ⬇️
src/main/java/htsjdk/tribble/gff/Gff3BaseData.java 80.556% <0.000%> (+1.389%) ⬆️

@cmnbroad cmnbroad force-pushed the cn_rewrite_containers branch 2 times, most recently from b1ded6e to 317bec6 Compare May 9, 2022 14:59
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.

@cmnbroad Questions / comments about mutability. If this is the only sane way to do this I can accept that it adds some more state.

private final OutputStream outputStream;
private final String outputStreamIdentifier;
private final CramHeader cramHeader;
private final SAMFileHeader samFileHeader;
Copy link
Member

Choose a reason for hiding this comment

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

This field is assigned but never accessed.

cramIndexer.finish();
}
} catch (final IOException e) {
throw new RuntimeIOException(String.format("IOException closing stream for %s", outputStreamIdentifier));
Copy link
Member

Choose a reason for hiding this comment

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

Is the output stream actually closed here? It seems like it's just flushed.

* @param streamByteOffset the new stream byte offset counter for this container
* @return the updated global record counter
*/
public long relocateContainer(final long containerRecordCounter, final long streamByteOffset) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to mutate the container? It was previously effectively immutable wasn't it? It seems like it would be nicer to copy it since I assume the container / slice objects are fairly lightweight and you could just pass through the reference to the heavy data?

Not a blocker if you think this is necessary for efficiency reasons / copying a container being very annoying.

@@ -249,4 +249,8 @@ public boolean isEOF() {
return v3 || v2;
}

void setGlobalRecordCounter(final long recordCounter) {
this.globalRecordCounter = recordCount;
Copy link
Member

Choose a reason for hiding this comment

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

again, unfortunate to make this mutable.

@@ -190,6 +190,7 @@ public int write(final CRAMVersion cramVersion, final OutputStream outputStream)
// landmark 0 = byte length of the compression header
// landmarks after 0 = byte length of the compression header plus all slices before this one
landmarks.add(tempOutputStream.size());
slice.byteOffsetOfContainer = containerByteOffset;
Copy link
Member

Choose a reason for hiding this comment

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

Why is this updated again here when it's already set by relocate?

@@ -78,7 +78,7 @@ public class Slice {

private final CompressionHeader compressionHeader;
private final SliceBlocks sliceBlocks;
private final long byteOffsetOfContainer;
public long byteOffsetOfContainer;
Copy link
Member

Choose a reason for hiding this comment

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

Why make this public? It seems like it's already updated through relocate.

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.

Add support for reserializing CRAM containers
3 participants