use of com.esotericsoftware.kryo.io.Input in project gatk by broadinstitute.
the class ReadMetadataTest method serializationTest.
@Test(groups = "spark")
void serializationTest() {
final SAMFileHeader header = ArtificialReadUtils.createArtificialSamHeaderWithGroups(1, 1, 10000000, 1);
final ReadMetadata.ReadGroupFragmentStatistics statistics = new ReadMetadata.ReadGroupFragmentStatistics(400, 175, 20);
final Set<Integer> crossContigIgnoreSet = new HashSet<>(3);
crossContigIgnoreSet.add(0);
final ReadMetadata readMetadata = new ReadMetadata(crossContigIgnoreSet, header, statistics, 1, 1L, 1L, 1);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final Output out = new Output(bos);
final Kryo kryo = new Kryo();
kryo.writeClassAndObject(out, readMetadata);
out.flush();
final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
final Input in = new Input(bis);
final ReadMetadata readMetadata2 = (ReadMetadata) kryo.readClassAndObject(in);
Assert.assertEquals(readMetadata, readMetadata2);
}
use of com.esotericsoftware.kryo.io.Input in project gatk by broadinstitute.
the class NovelAdjacencyReferenceLocationsUnitTest method testKryoSerializer.
@Test(groups = "sv")
void testKryoSerializer() throws IOException {
// uses inversion subclass for testing
final NovelAdjacencyReferenceLocations novelAdjacencyReferenceLocations1 = getBreakpoints("asm00001:tig0001", "foo");
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final Output out = new Output(bos);
final Kryo kryo = new Kryo();
kryo.writeClassAndObject(out, novelAdjacencyReferenceLocations1);
out.flush();
final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
final Input in = new Input(bis);
@SuppressWarnings("unchecked") final NovelAdjacencyReferenceLocations roundTrip = (NovelAdjacencyReferenceLocations) kryo.readClassAndObject(in);
Assert.assertEquals(roundTrip, novelAdjacencyReferenceLocations1);
}
use of com.esotericsoftware.kryo.io.Input in project gatk by broadinstitute.
the class BreakpointEvidenceTest method serializationTest.
@Test(groups = "spark")
void serializationTest() {
final List<BreakpointEvidence> evidenceList = new ArrayList<>(7);
final SAMFileHeader samHeader = ArtificialReadUtils.createArtificialSamHeader();
final ReadMetadata.ReadGroupFragmentStatistics groupStatistics = new ReadMetadata.ReadGroupFragmentStatistics(400, 175, 20);
final ReadMetadata metadata = new ReadMetadata(Collections.emptySet(), samHeader, groupStatistics, 1, 2L, 2L, 1);
final List<GATKRead> readPair = ArtificialReadUtils.createPair(samHeader, "firstReadPair", 101, 1010, 1382, false, false);
final GATKRead read = readPair.get(0);
evidenceList.add(new BreakpointEvidence.SplitRead(read, metadata, true));
evidenceList.add(new BreakpointEvidence.LargeIndel(read, metadata, read.getStart() + 50));
evidenceList.add(new BreakpointEvidence.MateUnmapped(read, metadata));
evidenceList.add(new BreakpointEvidence.InterContigPair(read, metadata));
evidenceList.add(new BreakpointEvidence.OutiesPair(read, metadata));
evidenceList.add(new BreakpointEvidence.SameStrandPair(read, metadata));
evidenceList.add(new BreakpointEvidence.WeirdTemplateSize(read, metadata));
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final Output out = new Output(bos);
final Kryo kryo = new Kryo();
kryo.writeClassAndObject(out, evidenceList);
out.flush();
final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
final Input in = new Input(bis);
@SuppressWarnings("unchecked") final List<BreakpointEvidence> evidenceList2 = (List<BreakpointEvidence>) kryo.readClassAndObject(in);
Assert.assertEquals(evidenceList.size(), evidenceList2.size());
for (int idx = 0; idx != evidenceList.size(); ++idx) {
Assert.assertEquals(evidenceList.get(idx).toString(), evidenceList2.get(idx).toString());
}
}
use of com.esotericsoftware.kryo.io.Input in project gatk by broadinstitute.
the class NovelAdjacencyReferenceLocationsUnitTest method seeIfItWorks.
private static void seeIfItWorks(final NovelAdjacencyReferenceLocations breakpoints, final NovelAdjacencyReferenceLocations.EndConnectionType expectedEndConnectionType, final SimpleInterval expectedLeftBreakpoint, final SimpleInterval expectedRightBreakpoint, final SimpleInterval expectedRepeatUnitRefSpan, final String expectedHomology, final String expectedInsertion, final int expectedRefDupNum, final int expectedCtgDupNum, final List<String> expectedTandupCigarStrings) {
Assert.assertEquals(breakpoints.leftJustifiedLeftRefLoc, expectedLeftBreakpoint);
Assert.assertEquals(breakpoints.leftJustifiedRightRefLoc, expectedRightBreakpoint);
Assert.assertEquals(breakpoints.endConnectionType, expectedEndConnectionType);
Assert.assertEquals(breakpoints.complication.getHomologyForwardStrandRep(), expectedHomology);
Assert.assertEquals(breakpoints.complication.getInsertedSequenceForwardStrandRep(), expectedInsertion);
Assert.assertEquals(breakpoints.complication.getDupSeqRepeatUnitRefSpan(), expectedRepeatUnitRefSpan);
Assert.assertEquals(breakpoints.complication.getDupSeqRepeatNumOnRef(), expectedRefDupNum);
Assert.assertEquals(breakpoints.complication.getDupSeqRepeatNumOnCtg(), expectedCtgDupNum);
Assert.assertEquals(breakpoints.complication.getCigarStringsForDupSeqOnCtg(), expectedTandupCigarStrings);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final Output out = new Output(bos);
final Kryo kryo = new Kryo();
kryo.writeClassAndObject(out, breakpoints);
out.flush();
final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
final Input in = new Input(bis);
@SuppressWarnings("unchecked") final NovelAdjacencyReferenceLocations roundTrip = (NovelAdjacencyReferenceLocations) kryo.readClassAndObject(in);
Assert.assertEquals(roundTrip, breakpoints);
}
use of com.esotericsoftware.kryo.io.Input in project gatk by broadinstitute.
the class PathSeqFilterSpark method doKmerFiltering.
@SuppressWarnings("unchecked")
private JavaRDD<GATKRead> doKmerFiltering(final JavaSparkContext ctx, final JavaRDD<GATKRead> reads) {
final PipelineOptions options = getAuthenticatedGCSOptions();
Input input = new Input(BucketUtils.openFile(KMER_LIB_PATH));
Kryo kryo = new Kryo();
kryo.setReferences(false);
Set<SVKmer> kmerLibSet = (HopscotchSet<SVKmer>) kryo.readClassAndObject(input);
return reads.filter(new ContainsKmerReadFilterSpark(ctx.broadcast(kmerLibSet), KMER_SIZE));
}
Aggregations