-
Notifications
You must be signed in to change notification settings - Fork 577
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a unit test to verify that GATKReads are being coded correctly regardless of backing implementation.
- Loading branch information
Showing
4 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...test/java/org/broadinstitute/hellbender/engine/dataflow/coders/GATKReadCoderUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.broadinstitute.hellbender.engine.dataflow.coders; | ||
|
||
import com.google.cloud.dataflow.sdk.Pipeline; | ||
import com.google.cloud.dataflow.sdk.testing.DataflowAssert; | ||
import com.google.cloud.dataflow.sdk.testing.TestPipeline; | ||
import com.google.cloud.dataflow.sdk.transforms.Create; | ||
import com.google.cloud.dataflow.sdk.values.PCollection; | ||
import org.broadinstitute.hellbender.utils.dataflow.DataflowUtils; | ||
import org.broadinstitute.hellbender.utils.read.ArtificialReadUtils; | ||
import org.broadinstitute.hellbender.utils.read.GATKRead; | ||
import org.broadinstitute.hellbender.utils.test.BaseTest; | ||
import org.testng.annotations.DataProvider; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
|
||
public class GATKReadCoderUnitTest extends BaseTest { | ||
|
||
private GATKRead makeGoogleRead( final int uuid, final String name, final int start, final int length ) { | ||
return ArtificialReadUtils.createGoogleBackedReadWithUUID(new UUID(0, uuid), name, start, length); | ||
} | ||
|
||
public GATKRead makeSamRead( final int uuid, final String name, final int start, final int length ) { | ||
return ArtificialReadUtils.createSamBackedReadWithUUID(new UUID(0, uuid), name, start, length); | ||
} | ||
|
||
@DataProvider(name = "reads") | ||
public Object[][] makeReads() { | ||
final List<GATKRead> googleReads = Arrays.asList(makeGoogleRead(1, "google1", 1, 10), makeGoogleRead(2, "google2", 20, 40)); | ||
final List<GATKRead> samReads = Arrays.asList(makeSamRead(1, "sam1", 1, 10), makeSamRead(2, "sam2", 20, 40)); | ||
|
||
return new Object[][] { | ||
{ googleReads }, | ||
{ samReads } | ||
}; | ||
} | ||
|
||
@Test(dataProvider = "reads") | ||
public void testGATKReadCoding( final List<GATKRead> reads ) { | ||
// The simplest way to figure out if a class is coded correctly is to create a PCollection | ||
// of that type and see if it matches the List version. | ||
final Pipeline p = TestPipeline.create(); | ||
DataflowUtils.registerGATKCoders(p); | ||
|
||
final PCollection<GATKRead> dataflowReads = p.apply(Create.of(reads)); | ||
DataflowAssert.that(dataflowReads).containsInAnyOrder(reads); | ||
p.run(); | ||
} | ||
} |