Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
Merge c5a25f1 into 28398ce
Browse files Browse the repository at this point in the history
  • Loading branch information
deflaux committed Sep 11, 2017
2 parents 28398ce + c5a25f1 commit 73a9cc2
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 136 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -5,7 +5,7 @@ This project's goal is to reduce duplicate code across different Google Genomics

If you have duplicate code appearing in your projects, or see useful functions in the other [googlegenomics Java repositories](https://github.com/googlegenomics?query=-java) that you want to depend on, please [contribute](CONTRIBUTING.rst)!

##Depending on this project
## Depending on this project

Note: you can find the latest available version of this project in [Maven's central repository](https://search.maven.org/#search%7Cga%7C1%7Ca%3A%22google-genomics-utils%22).

Expand All @@ -17,7 +17,7 @@ Add the following to your `pom.xml` file:
<dependency>
<groupId>com.google.cloud.genomics</groupId>
<artifactId>google-genomics-utils</artifactId>
<version>v1beta2-0.1</version>
<version>v1-0.8</version>
</dependency>
</dependencies>
</project>
Expand All @@ -31,7 +31,7 @@ repositories {
}
dependencies {
compile 'com.google.cloud.genomics:google-genomics-utils:v1-0.7'
compile 'com.google.cloud.genomics:google-genomics-utils:v1-0.8'
}
```

Expand Down Expand Up @@ -113,9 +113,9 @@ This section contains details on getting a new release into Maven central and ca
mvn release:prepare && mvn release:perform
```
> ...
> **What is the release version for "Google Genomics Utils"?:** \<the next version, e.g. 'v1beta2-0.26'\>
> **What is the release version for "Google Genomics Utils"?:** \<the next version, e.g. 'v1-0.9'\>
> **What is SCM release tag or label for "Google Genomics Utils"?:** \<ENTER\>
> **What is the new development version for "Google Genomics Utils"?** \<the next, next version with a -SNAPSHOT suffix, e.g. v1beta2-0.27-SNAPSHOT\>
> **What is the new development version for "Google Genomics Utils"?** \<the next, next version with a -SNAPSHOT suffix, e.g. v1-0.10-SNAPSHOT\>
2. Find the repository at https://oss.sonatype.org/#stagingRepositories and close it.
3. If closing succeeds, then release it. See the [detailed instructions](http://central.sonatype.org/pages/releasing-the-deployment.html#close-and-drop-or-release-your-staging-repository) for more info.
Expand Down
57 changes: 44 additions & 13 deletions pom.xml
Expand Up @@ -80,7 +80,7 @@
<dependency>
<groupId>com.github.samtools</groupId>
<artifactId>htsjdk</artifactId>
<version>1.128</version>
<version>2.11.0</version>
<exclusions>
<exclusion>
<groupId>org.testng</groupId>
Expand All @@ -106,7 +106,25 @@
<dependency>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-genomics-v1</artifactId>
<version>0.0.9</version>
<version>0.1.0</version>
<exclusions>
<exclusion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-common-protos</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.api.grpc</groupId>
<artifactId>grpc-google-iam-v1</artifactId>
</exclusion>
<exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
<exclusion>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.http-client</groupId>
Expand Down Expand Up @@ -141,22 +159,37 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.10.8</version>
<scope>test</scope>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>2.8.47</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>${io.grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>${io.grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>${io.grpc.version}</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-all</artifactId>
<artifactId>grpc-auth</artifactId>
<version>${io.grpc.version}</version>
</dependency>

<!-- Used to test the custom builder logic -->
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-storage</artifactId>
<version>v1-rev22-1.19.0</version>
<version>v1-rev110-1.22.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down Expand Up @@ -287,13 +320,11 @@
</build>

<properties>
<junit.version>4.11</junit.version>
<google.api.version>1.22.0</google.api.version>
<google.auth.version>0.4.0</google.auth.version>
<google.api.genomics.version>v1-rev109-1.22.0</google.api.genomics.version>
<google.auth.version>0.7.1</google.auth.version>
<google.api.genomics.version>v1-rev512-1.22.0</google.api.genomics.version>
<google.guava.version>19.0</google.guava.version>
<io.grpc.version>1.0.1</io.grpc.version>
<mockito.version>1.10.8</mockito.version>
<io.grpc.version>1.6.1</io.grpc.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.targetEncoding>UTF-8</project.build.targetEncoding>
<java.version>1.7</java.version>
Expand Down
Expand Up @@ -29,22 +29,11 @@ public class IntegrationTestHelper {
public static final String PLATINUM_GENOMES_VARIANTSET = "3049512673186936334";
public static final String[] PLATINUM_GENOMES_CALLSET_NAMES = {
"NA12877",
"NA12893",
"NA12885",
"NA12889",
"NA12887",
"NA12881",
"NA12888",
"NA12882",
"NA12879",
"NA12891",
"NA12883",
"NA12892",
"NA12886",
"NA12890",
"NA12878",
"NA12884",
"NA12880",
};
public static final String[] PLATINUM_GENOMES_READGROUPSETS = {
"CMvnhpKTFhCAv6TKo6Dglgg",
Expand All @@ -66,7 +55,7 @@ public class IntegrationTestHelper {
};
public static final String PLATINUM_GENOMES_REFERENCE_SET_ID = "CNfS6aHAoved2AEQ6PnzkOzw15rqAQ";
public static final String PLATINUM_GENOMES_BRCA1_REFERENCES = "chr17:41196311:41277499";
public static final int PLATINUM_GENOMES_BRCA1_EXPECTED_NUM_VARIANTS = 19517;
public static final int PLATINUM_GENOMES_BRCA1_EXPECTED_NUM_VARIANTS = 7588;
public static final String PLATINUM_GENOMES_KLOTHO_REFERENCES = "chr13:33628137:33628138";
public static final ReferenceBound[] PLATINUM_GENOMES_VARIANTSET_BOUNDS = {
new ReferenceBound().setReferenceName("chr1").setUpperBound(250226910L),
Expand Down
Expand Up @@ -63,7 +63,7 @@ public class FaultyGenomicsServerITCase {
public static void startServer() throws IOException, GeneralSecurityException {
try {
server = InProcessServerBuilder.forName(SERVER_NAME)
.addService(StreamingVariantServiceGrpc.bindService(new VariantsIntegrationServerImpl()))
.addService(new VariantsIntegrationServerImpl())
.build().start();
} catch (IOException ex) {
throw new RuntimeException(ex);
Expand All @@ -76,8 +76,8 @@ public static void stopServer() {
server.shutdownNow();
}

protected static class VariantsIntegrationServerImpl implements
StreamingVariantServiceGrpc.StreamingVariantService {
protected static class VariantsIntegrationServerImpl extends
StreamingVariantServiceGrpc.StreamingVariantServiceImplBase {
final Random random = new Random();

@Override
Expand Down
Expand Up @@ -90,13 +90,12 @@ enum InjectionSite {

protected Server server;

protected static class UnitServerImpl implements StreamingReadServiceGrpc.StreamingReadService,
StreamingVariantServiceGrpc.StreamingVariantService {
protected static class FaultInjector {

protected final InjectionSite injectionSite;
protected volatile boolean failNow; // Accessed by the InProcess Server executor threads.

protected UnitServerImpl(InjectionSite targetSite) {
protected FaultInjector(InjectionSite targetSite) {
injectionSite = targetSite;
failNow = true;
}
Expand All @@ -109,18 +108,6 @@ protected synchronized boolean shouldInjectNow(InjectionSite currentSite) {
return false;
}

@Override
public void streamReads(StreamReadsRequest request,
StreamObserver<StreamReadsResponse> responseObserver) {
respondWithFaults(responseObserver, READ_RESPONSES);
}

@Override
public void streamVariants(StreamVariantsRequest request,
StreamObserver<StreamVariantsResponse> responseObserver) {
respondWithFaults(responseObserver, VARIANT_RESPONSES);
}

protected synchronized void respondWithFaults(StreamObserver responseObserver, Message[] responses) {
if (shouldInjectNow(InjectionSite.AT_BEGINNING)) {
responseObserver.onError(Status.UNAVAILABLE.withDescription("injected fault")
Expand Down Expand Up @@ -156,6 +143,34 @@ protected synchronized void respondWithFaults(StreamObserver responseObserver, M
}
}

protected static class ReadUnitServerImpl extends StreamingReadServiceGrpc.StreamingReadServiceImplBase {
final FaultInjector faultInjector;

public ReadUnitServerImpl(InjectionSite targetSite) {
faultInjector = new FaultInjector(targetSite);
}

@Override
public void streamReads(StreamReadsRequest request,
StreamObserver<StreamReadsResponse> responseObserver) {
faultInjector.respondWithFaults(responseObserver, READ_RESPONSES);
}
}

protected static class VariantUnitServerImpl extends StreamingVariantServiceGrpc.StreamingVariantServiceImplBase {
final FaultInjector faultInjector;

public VariantUnitServerImpl(InjectionSite targetSite) {
faultInjector = new FaultInjector(targetSite);
}

@Override
public void streamVariants(StreamVariantsRequest request,
StreamObserver<StreamVariantsResponse> responseObserver) {
faultInjector.respondWithFaults(responseObserver, VARIANT_RESPONSES);
}
}

/**
* Starts the in-process server configured to inject one fault at the specified target site.
*
Expand All @@ -165,8 +180,8 @@ public void startServer(InjectionSite targetSite) {
try {
server =
InProcessServerBuilder.forName(testName.getMethodName())
.addService(StreamingReadServiceGrpc.bindService(new UnitServerImpl(targetSite)))
.addService(StreamingVariantServiceGrpc.bindService(new UnitServerImpl(targetSite)))
.addService(new ReadUnitServerImpl(targetSite))
.addService(new VariantUnitServerImpl(targetSite))
.build()
.start();
} catch (IOException ex) {
Expand Down
Expand Up @@ -61,8 +61,8 @@ public class GenomicsStreamIteratorTest {
public static void startServer() {
try {
server = InProcessServerBuilder.forName(SERVER_NAME)
.addService(StreamingReadServiceGrpc.bindService(new ReadsUnitServerImpl()))
.addService(StreamingVariantServiceGrpc.bindService(new VariantsUnitServerImpl()))
.addService(new ReadsUnitServerImpl())
.addService(new VariantsUnitServerImpl())
.build().start();
} catch (IOException ex) {
throw new RuntimeException(ex);
Expand All @@ -74,7 +74,7 @@ public static void stopServer() {
server.shutdownNow();
}

protected static class ReadsUnitServerImpl implements StreamingReadServiceGrpc.StreamingReadService {
protected static class ReadsUnitServerImpl extends StreamingReadServiceGrpc.StreamingReadServiceImplBase {
@Override
public void streamReads(StreamReadsRequest request,
StreamObserver<StreamReadsResponse> responseObserver) {
Expand All @@ -88,7 +88,7 @@ public void streamReads(StreamReadsRequest request,
}
}

protected static class VariantsUnitServerImpl implements StreamingVariantServiceGrpc.StreamingVariantService {
protected static class VariantsUnitServerImpl extends StreamingVariantServiceGrpc.StreamingVariantServiceImplBase {
@Override
public void streamVariants(StreamVariantsRequest request,
StreamObserver<StreamVariantsResponse> responseObserver) {
Expand Down
Expand Up @@ -70,7 +70,7 @@ public class MergeAllVariantsAtSameSiteITCase {
public void testMerge() throws Exception {
ImmutableList<StreamVariantsRequest> requests =
ShardUtils.getVariantRequests(PROTOTYPE,
100L, "chr17:41204796:41204797");
100L, "chr17:41198773:41198774");
assertEquals(1, requests.size());

Iterator<StreamVariantsResponse> iter =
Expand All @@ -84,29 +84,15 @@ public void testMerge() throws Exception {

// Platinum genomes has both a snp and an insertion at this genomic site
// but merging the calls together yields an ambiguous result.
Variant expectedOutput1 = TestHelper.makeVariant("chr17", 41204796, 41204797, "A", Arrays.asList("AAC", "C"))
.addCalls(TestHelper.makeCall("NA12882", 1, 1)) // ambiguous
.addCalls(TestHelper.makeCall("NA12879", 1, 1)) // ambiguous
.addCalls(TestHelper.makeCall("NA12891", 0, 1)) // ambiguous
Variant expectedOutput1 = TestHelper.makeVariant("chr17", 41198773, 41198774, "C", Arrays.asList("A", "CA"))
.addCalls(TestHelper.makeCall("NA12878", 0, 1)) // ambiguous
.addCalls(TestHelper.makeCall("NA12884", 1, 1)) // ambiguous
.addCalls(TestHelper.makeCall("NA12882", 0, 2)) // ambiguous
.addCalls(TestHelper.makeCall("NA12879", 0, 2)) // ambiguous
.addCalls(TestHelper.makeCall("NA12892", 0, 0))
.addCalls(TestHelper.makeCall("NA12893", 0, 0))
.addCalls(TestHelper.makeCall("NA12890", 0, 0))
.addCalls(TestHelper.makeCall("NA12883", 0, 0))
.addCalls(TestHelper.makeCall("NA12891", 0, 0)) // ambiguous
.addCalls(TestHelper.makeCall("NA12880", 0, 0))
.addCalls(TestHelper.makeCall("NA12892", 0, 2)) // ambiguous
.addCalls(TestHelper.makeCall("NA12878", 0, 2)) // ambiguous
.addCalls(TestHelper.makeCall("NA12877", 0, 0))
.addCalls(TestHelper.makeCall("NA12885", 0, 0))
.addCalls(TestHelper.makeCall("NA12889", 0, 0))
.addCalls(TestHelper.makeCall("NA12887", 0, 0))
.addCalls(TestHelper.makeCall("NA12881", 0, 0))
.addCalls(TestHelper.makeCall("NA12888", 0, 0))
.addCalls(TestHelper.makeCall("NA12886", 0, 0))
.addCalls(TestHelper.makeCall("NA12878", 0, 0)) // ambiguous
.addCalls(TestHelper.makeCall("NA12884", 0, 0)) // ambiguous
.addCalls(TestHelper.makeCall("NA12891", 0, 0))
.addCalls(TestHelper.makeCall("NA12892", 0, 0)) // ambiguous
.addCalls(TestHelper.makeCall("NA12890", 0, 0))
.putAllInfo(emptyInfo)
.build();

Expand Down
Expand Up @@ -67,7 +67,7 @@ public class MergeNonVariantSegmentsWithSnpsITCase {
public void testMerge() throws Exception {
ImmutableList<StreamVariantsRequest> requests =
ShardUtils.getVariantRequests(PROTOTYPE,
100, "chr17:41204796:41204797");
100, "chr17:41198773:41198774");
assertEquals(1, requests.size());

Iterator<StreamVariantsResponse> iter =
Expand All @@ -77,32 +77,18 @@ public void testMerge() throws Exception {
"variants(alternateBases,calls(callSetName,genotype),end,referenceBases,referenceName,start)");

// Platinum genomes has both a snp and an insertion at this genomic site.
Variant expectedOutput1 = TestHelper.makeVariant("chr17", 41204796, 41204797, "A", Arrays.asList("AAC"))
.addCalls(TestHelper.makeCall("NA12882", 1, 1))
.addCalls(TestHelper.makeCall("NA12879", 1, 1))
.addCalls(TestHelper.makeCall("NA12891", 0, 1))
Variant expectedOutput1 = TestHelper.makeVariant("chr17", 41198773, 41198774, "C", Arrays.asList("A"))
.addCalls(TestHelper.makeCall("NA12878", 0, 1))
.addCalls(TestHelper.makeCall("NA12884", 1, 1))
.build();

Variant expectedOutput2 = TestHelper.makeVariant("chr17", 41204796, 41204797, "A", Arrays.asList("C"))
.addCalls(TestHelper.makeCall("NA12882", 0, 1))
.addCalls(TestHelper.makeCall("NA12879", 0, 1))
.addCalls(TestHelper.makeCall("NA12892", 0, 0))
.addCalls(TestHelper.makeCall("NA12893", 0, 0))
.addCalls(TestHelper.makeCall("NA12890", 0, 0))
.addCalls(TestHelper.makeCall("NA12883", 0, 0))
.addCalls(TestHelper.makeCall("NA12891", 0, 0))
.addCalls(TestHelper.makeCall("NA12880", 0, 0))
.addCalls(TestHelper.makeCall("NA12877", 0, 0))
.addCalls(TestHelper.makeCall("NA12885", 0, 0))
.addCalls(TestHelper.makeCall("NA12889", 0, 0))
.addCalls(TestHelper.makeCall("NA12887", 0, 0))
.addCalls(TestHelper.makeCall("NA12881", 0, 0))
.addCalls(TestHelper.makeCall("NA12888", 0, 0))
.addCalls(TestHelper.makeCall("NA12886", 0, 0))
.addCalls(TestHelper.makeCall("NA12878", 0, 0))
.addCalls(TestHelper.makeCall("NA12884", 0, 0))
.addCalls(TestHelper.makeCall("NA12891", 0, 0))
.addCalls(TestHelper.makeCall("NA12892", 0, 0))
.addCalls(TestHelper.makeCall("NA12890", 0, 0))
.build();

Variant expectedOutput2 = TestHelper.makeVariant("chr17", 41198773, 41198774, "C", Arrays.asList("CA"))
.addCalls(TestHelper.makeCall("NA12892", 0, 1))
.addCalls(TestHelper.makeCall("NA12878", 0, 1))
.build();

VariantMergeStrategyTestHelper.mergeTest(requests.get(0).getStart(), iter.next().getVariantsList(),
Expand Down

0 comments on commit 73a9cc2

Please sign in to comment.