Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Commit

Permalink
continuous data compliance finished (#248)
Browse files Browse the repository at this point in the history
* continuous data compliance finsihed

* Move parent pom to master
  • Loading branch information
ejacox authored and david4096 committed Feb 21, 2017
1 parent 02effbd commit a9f6440
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,18 @@ public interface URLMAPPING {

void setGetFeature(String getFeature);

String getSearchContinuousSets();

void setSearchContinuousSets(String searchContinuousSets);

String getGetContinuousSet();

void setGetContinuousSet(String getContinuousSet);

String getSearchContinuous();

void setSearchContinuous(String searchContinuous);


String getGetRnaQuantification();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public class URLMAPPINGImpl implements URLMAPPING {
defaultEndpoints.put("ctk.tgt.getFeatureSets", "featuresets/{id}");
defaultEndpoints.put("ctk.tgt.searchFeatures", "features/search");
defaultEndpoints.put("ctk.tgt.getFeatures", "features/{id}");
defaultEndpoints.put("ctk.tgt.searchContinuousSets", "continuoussets/search");
defaultEndpoints.put("ctk.tgt.getContinuousSets", "continuoussets/{id}");
defaultEndpoints.put("ctk.tgt.searchContinuous", "continuous/search");
defaultEndpoints.put("ctk.tgt.searchPhenotypeAssociationSets","phenotypeassociationsets/search");

defaultEndpoints.put("ctk.tgt.searchGenotypePhenotype", "featurephenotypeassociations/search");
Expand Down Expand Up @@ -547,6 +550,36 @@ public String getGetFeature() {
return endpoints.get("ctk.tgt.getFeatures");
}

@Override
public String getSearchContinuousSets() {
return endpoints.get("ctk.tgt.searchContinuousSets");
}

@Override
public void setSearchContinuousSets(String searchContinuousSets) {
endpoints.put("ctk.tgt.searchContinuousSets", searchContinuousSets);
}

@Override
public void setGetContinuousSet(String getContinuousSets) {
endpoints.put("ctk.tgt.getContinuousSets", getContinuousSets);
}

@Override
public String getGetContinuousSet() {
return endpoints.get("ctk.tgt.getContinuousSets");
}

@Override
public String getSearchContinuous() {
return endpoints.get("ctk.tgt.searchContinuous");
}

@Override
public void setSearchContinuous(String searchContinuous) {
endpoints.put("ctk.tgt.searchContinuouss", searchContinuous);
}

@Override
public String getGetRnaQuantification() { return endpoints.get("ctk.tgt.getRnaQuantification"); }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@
import ga4gh.SequenceAnnotationServiceOuterClass.SearchFeaturesResponse;
import ga4gh.SequenceAnnotations.Feature;
import ga4gh.SequenceAnnotations.FeatureSet;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousSetsRequest;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousSetsResponse;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousResponse;
import ga4gh.SequenceAnnotations.Continuous;
import ga4gh.SequenceAnnotations.ContinuousSet;
import ga4gh.VariantServiceOuterClass.*;
import ga4gh.Variants.CallSet;
import ga4gh.Variants.Variant;
Expand Down Expand Up @@ -515,7 +520,31 @@ public Feature getFeature(String id) throws InvalidProtocolBufferException, GAWr
return builder.build();
}

public SearchContinuousSetsResponse searchContinuousSets(SearchContinuousSetsRequest request) throws InvalidProtocolBufferException, GAWrapperException, UnirestException {
String path = urls.getSearchContinuousSets();
SearchContinuousSetsResponse.Builder responseBuilder = SearchContinuousSetsResponse.newBuilder();
new Post<>(urls.getUrlRoot(), path, request, responseBuilder, wireTracker).performQuery();
return responseBuilder.build();
}


public ContinuousSet getContinuousSet(String id) throws InvalidProtocolBufferException, UnirestException, GAWrapperException {
String path = urls.getGetContinuousSet();
ContinuousSet.Builder builder = ContinuousSet.newBuilder();
new Get<>(urls.getUrlRoot(), path, id, null, builder, wireTracker).performQuery();
return builder.build();
}

public SearchContinuousResponse searchContinuous(SequenceAnnotationServiceOuterClass.SearchContinuousRequest request)
throws InvalidProtocolBufferException, GAWrapperException, UnirestException {
String path = urls.getSearchContinuous();
SearchContinuousResponse.Builder responseBuilder = SearchContinuousResponse.newBuilder();
new Post<>(urls.getUrlRoot(), path, request, responseBuilder, wireTracker).performQuery();
return responseBuilder.build();
}

}

/**
* Inner class holding all biodata-related methods. Gathering them in an inner class like
* this makes it a little easier for someone writing tests to use their IDE's auto-complete
Expand Down
2 changes: 2 additions & 0 deletions ctk-transport/src/main/resources/defaulttransport.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ ctk.tgt.searchGenotypePhenotype=featurephenotypeassociations/search
ctk.tgt.searchPhenotypes=phenotypes/search
ctk.tgt.searchFeatures=features/search
ctk.tgt.searchFeatureSets=featuresets/search
ctk.tgt.searchContinuous=continuous/search
ctk.tgt.searchContinuousSets=continuoussets/search
ctk.tgt.searchPhenotypeAssociationSets=phenotypeassociationsets/search
2 changes: 2 additions & 0 deletions cts-java/src/main/resources/defaulttransport.properties
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ ctk.tgt.searchGenotypePhenotype=featurephenotypeassociations/search
ctk.tgt.searchPhenotypes=phenotypes/search
ctk.tgt.searchFeatures=features/search
ctk.tgt.searchFeatureSets=featuresets/search
ctk.tgt.searchContinuous=continuous/search
ctk.tgt.searchContinuousSets=continuoussets/search
ctk.tgt.searchPhenotypeAssociationSets=phenotypeassociationsets/search
67 changes: 67 additions & 0 deletions cts-java/src/test/java/org/ga4gh/cts/api/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import ga4gh.References.*;
import ga4gh.ReferenceServiceOuterClass.*;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchFeatureSetsRequest;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousSetsRequest;
import ga4gh.SequenceAnnotations.*;
import ga4gh.Variants.*;
import ga4gh.VariantServiceOuterClass.*;
Expand Down Expand Up @@ -794,6 +795,72 @@ public static FeatureSet getFeatureSetByName(Client client, String name) throws
}
return featureSets.get(0);
}

/**
* Search for and return all {@link ContinuousSet}s.
*
* @param client the connection to the server
* @return the {@link List} of results
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/
public static List<ContinuousSet> getAllContinuousSets(Client client) throws InvalidProtocolBufferException, UnirestException, GAWrapperException {

final List<ContinuousSet> result = new LinkedList<>();
String pageToken = "";
do {
final SearchContinuousSetsRequest req =
SearchContinuousSetsRequest.newBuilder()
.setDatasetId(TestData.getDatasetId())
.setPageSize(100)
.setPageToken(pageToken)
.build();
final SearchContinuousSetsResponse resp = client.sequenceAnnotations.searchContinuousSets(req);
pageToken = resp.getNextPageToken();
result.addAll(resp.getContinuousSetsList());
} while (!pageToken.equals(""));

return result;
}

/**
* Utility method to fetch the Id of a {@link ContinuousSet} for the compliance dataset.
* @param client the connection to the server
* @return the ID of a {@link ContinuousSet}
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/
public static String getContinuousSetId(Client client) throws InvalidProtocolBufferException, UnirestException, GAWrapperException {

// get all compliance continuous sets
final List<ContinuousSet> continuousSets = getAllContinuousSets(client);
return continuousSets.get(0).getId();
}

/**
* Given a name, return the continuous set corresponding to that name. When that name
* is not found returns the first continuous set found.
* @param client the connection to the server
* @param name the string name of the annotation set
* @return a {@link ContinuousSet} with the requested name
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/
public static ContinuousSet getContinuousSetByName(Client client, String name) throws InvalidProtocolBufferException, UnirestException, GAWrapperException {

// get all compliance continuous sets
final List<ContinuousSet> continuousSets = getAllContinuousSets(client);
for (ContinuousSet fs : continuousSets) {
if (fs.getName().equals(name)) {
return fs;
}
}
return continuousSets.get(0);
}

/**
* Sugar for getting the first Biosample result that matches the name search request.
* @param client
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package org.ga4gh.cts.api.sequenceAnnotations;

import com.google.protobuf.InvalidProtocolBufferException;

import com.mashape.unirest.http.exceptions.UnirestException;

import org.ga4gh.ctk.CtkLogs;
import org.ga4gh.ctk.transport.GAWrapperException;
import org.ga4gh.ctk.transport.URLMAPPING;
import org.ga4gh.ctk.transport.protocols.Client;
import org.ga4gh.cts.api.TestData;
import org.ga4gh.cts.api.Utils;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.util.List;
import java.util.function.Consumer;

import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousRequest;
import ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousResponse;
import ga4gh.SequenceAnnotations.Continuous;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Test searching continuous data.
*/
@Category(SequenceAnnotationTests.class)
public class ContinuousSearchIT implements CtkLogs {

private static Client client = new Client(URLMAPPING.getInstance());


/**
* Fetch continuous data between two positions in the reference. The number of values must
* equal what we're expecting by examination of the continuous data.
*
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/

@Test
public void checkExpectedNumberOfValues() throws InvalidProtocolBufferException, UnirestException, GAWrapperException {
final long start = 50083750;
final long end = 50083800;
final String referenceName = "chr19";
final int expectedNumberOfValues = 25;

final String id = Utils.getContinuousSetId(client);

final SearchContinuousRequest fReq =
SearchContinuousRequest.newBuilder()
.setContinuousSetId(id)
.setReferenceName(referenceName)
.setStart(start).setEnd(end)
.build();
final SearchContinuousResponse fResp = client.sequenceAnnotations.searchContinuous(fReq);
final List<Continuous> searchContinuous = fResp.getContinuousList();

assertThat(searchContinuous).isNotEmpty();
Continuous msg = searchContinuous.get(0);
assertThat(msg.getValuesList()).hasSize(expectedNumberOfValues);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.ga4gh.cts.api.sequenceAnnotations;

import com.google.protobuf.InvalidProtocolBufferException;

import com.mashape.unirest.http.exceptions.UnirestException;

import org.ga4gh.ctk.transport.GAWrapperException;
import org.ga4gh.ctk.transport.URLMAPPING;
import org.ga4gh.ctk.transport.protocols.Client;
import org.ga4gh.cts.api.Utils;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;

import java.util.List;

import ga4gh.SequenceAnnotations.ContinuousSet;
import junitparams.JUnitParamsRunner;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for <tt>GET /continuousSets/{id}</tt>.
*
* @author Maciek Smuga-Otto
*/
@Category(SequenceAnnotationTests.class)
@RunWith(JUnitParamsRunner.class)
public class ContinuousSetsGetByIdIT {

private static Client client = new Client(URLMAPPING.getInstance());

/**
* Verify that ContinuousSets that we obtain by way of {@link ga4gh.SequenceAnnotationServiceOuterClass.SearchContinuousSetsRequest }
* match the ones we get via <tt>GET /continuousSets/{id}</tt>.
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/
@Test
public void checkContinuousSetsGetResults() throws InvalidProtocolBufferException, UnirestException, GAWrapperException {
final int expectedNumberOfContinuousSets = 1;

final List<ContinuousSet> continuousSets = Utils.getAllContinuousSets(client);

assertThat(continuousSets).hasSize(expectedNumberOfContinuousSets);

for (final ContinuousSet continuousSetFromSearch : continuousSets) {
final ContinuousSet continuousSetFromGet = client.sequenceAnnotations.getContinuousSet(continuousSetFromSearch.getId());
assertThat(continuousSetFromGet).isNotNull();

assertThat(continuousSetFromGet).isEqualTo(continuousSetFromSearch);
}

}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.ga4gh.cts.api.sequenceAnnotations;

import com.google.protobuf.InvalidProtocolBufferException;

import com.mashape.unirest.http.exceptions.UnirestException;

import org.assertj.core.api.StrictAssertions;
import org.ga4gh.ctk.transport.GAWrapperException;
import org.ga4gh.ctk.transport.URLMAPPING;
import org.ga4gh.ctk.transport.protocols.Client;
import org.ga4gh.cts.api.Utils;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.util.List;

import ga4gh.SequenceAnnotations.ContinuousSet;

import static org.assertj.core.api.Assertions.assertThat;

/**
* Tests for <tt>POST /continuousSets/search</tt>.
*
* @author Maciek Smuga-Otto
*/
@Category(SequenceAnnotationTests.class)
public class ContinuousSetsSearchIT {


private static Client client = new Client(URLMAPPING.getInstance());

/**
* Check SequenceAnnotationSets contain some analysis data.
* @throws GAWrapperException if the server finds the request invalid in some way
* @throws UnirestException if there's a problem speaking HTTP to the server
* @throws InvalidProtocolBufferException if there's a problem processing the JSON response from the server
*/
@Test
public void checkSearchingContinuousSets() throws InvalidProtocolBufferException, UnirestException, GAWrapperException {

// Seek a list of SequenceAnnotationSets for the compliance dataset.
final List<ContinuousSet> continuousSets = Utils.getAllContinuousSets(client);

// check some are available
assertThat(continuousSets).isNotEmpty();

// Check the continuousSetId is as expected.
continuousSets.stream()
.forEach(sas -> StrictAssertions.assertThat(sas.getName()).isNotNull());
}


}


Binary file not shown.

0 comments on commit a9f6440

Please sign in to comment.