Skip to content

Commit

Permalink
Merge pull request ga4gh#165 from david4096/newvann
Browse files Browse the repository at this point in the history
New test for effect search, update schemas
  • Loading branch information
david4096 committed Feb 8, 2016
2 parents 6cec7de + 7cb5f54 commit 79a923f
Show file tree
Hide file tree
Showing 10 changed files with 190 additions and 59 deletions.
12 changes: 12 additions & 0 deletions ctk-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filesets>
<fileset>
<directory>src/main/assertj-assertions</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
Expand Down
10 changes: 7 additions & 3 deletions ctk-schemas/src/main/resources/avro/alleleAnnotationmethods.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@ record SearchVariantAnnotationsRequest {
// union { null, array<string> } featureIds = null;

/**
Only return variant annotations including these effects (SO terms). Exact
matching across all fields of the OntologyTerm is required. If null, return
all variant annotations.
This filter allows variant, transcript combinations to be extracted by effect
type(s).
Only return variant annotations including any of these effects and only return
transcript effects including any of these effects. Exact matching across all
fields of the Sequence Ontology OntologyTerm is required.
(A transcript effect may have multiple SO effects which will all be reported.)
If null, return all variant annotations.
*/
union { null, array<org.ga4gh.models.OntologyTerm> } effects = null;

Expand Down
54 changes: 35 additions & 19 deletions ctk-schemas/src/main/resources/avro/metadata.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,36 @@ import idl "common.avdl";
An ontology term describing an attribute. (e.g. the phenotype attribute
'polydactyly' from HPO)
*/
record OntologyTerm {
/**
The source of the onotology term.
(e.g. `Ontology for Biomedical Investigation`)
*/
string ontologySource;

/**
The ID defined by the external onotology source.
(e.g. `http://purl.obolibrary.org/obo/OBI_0001271`)
*/
string id;

/** The name of the onotology term. (e.g. `RNA-seq assay`) */
union { null, string } name = null;
}

record OntologyTerm {
/**
Ontology source identifier - the identifier, a CURIE (preferred) or
PURL for an ontology source e.g. http://purl.obolibrary.org/obo/hp.obo
It differs from the standard GA4GH schema's :ref:`id <apidesign_object_ids>`
in that it is a URI pointing to an information resource outside of the scope
of the schema or its resource implementation.
*/
string id;

/**
Ontology term - the representation the id is pointing to.
*/
union { null, string } term = null;

/**
Ontology source name - the name of ontology from which the term is obtained
e.g. 'Human Phenotype Ontology'
*/
union { null, string } sourceName = null;

/**
Ontology source version - the version of the ontology from which the
OntologyTerm is obtained; e.g. 2.6.1.
There is no standard for ontology versioning and some frequently
released ontologies may use a datestamp, or build number.
*/
union { null, string } sourceVersion = null;
}

/**
An experimental preparation of a sample.
Expand Down Expand Up @@ -141,13 +155,15 @@ An analysis contains an interpretation of one or several experiments.
information about the methodology used.
*/
record Analysis {
/** The analysis UUID. This is globally unique. */

/**
Formats of id | name | description | accessions are described in the
documentation on general attributes and formats.
*/
string id;

/** The name of the analysis. */
union { null, string } name = null;

/** A description of the analysis. */
union { null, string } description = null;

/**
Expand Down
13 changes: 13 additions & 0 deletions cts-java/src/test/java/org/ga4gh/cts/api/TestData.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ private TestData() {
*/
public static final String VARIANT_ANNOTATION_REFERENCE_NAME = "1";


/**
* The names of the variant annotation sets used for variant annotation in the standard test data.
*/
public static final List<String> VARIANT_ANNOTATION_SET_NAMES =
Arrays.asList("WASH7P_annotation", "OR4F_annotation");

/**
* The names of known-good read groups.
*/
Expand Down Expand Up @@ -134,6 +141,12 @@ private TestData() {
*/
public static final String ALIGNED_SEQUENCE_CONTENTS_PATTERN = "[ACTGN]+";


/**
* The call set name is used to test searching by call set name functionality.
*/
public static final String CALL_SET_NAME = "HG00096";

/**
* Return the ID of the compliance dataset on the server being tested.
* By default this is the value of {@link #DEFAULT_DATASET_ID}, but
Expand Down
21 changes: 21 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 @@ -571,4 +571,25 @@ public static String getVariantAnnotationSetId(Client client) throws AvroRemoteE
final List<VariantAnnotationSet> variantAnnotationSets = getAllVariantAnnotationSets(client);
return variantAnnotationSets.get(0).getId();
}


/**
* Given a name return the variant annotation set corresponding to that name. When that name
* is not found returns the first annotation set found.
* @param client the connection to the server
* @param name the string name of the annotation set
* @return a {@link VariantAnnotationSet} with the requested name
* @throws AvroRemoteException if the server throws an exception or there's an I/O error
*/
public static VariantAnnotationSet getVariantAnnotationSetByName(Client client, String name) throws AvroRemoteException {

// get all compliance variant annotation sets
final List<VariantAnnotationSet> variantAnnotationSets = getAllVariantAnnotationSets(client);
for (VariantAnnotationSet vas : variantAnnotationSets) {
if (vas.getName().equals(name)) {
return vas;
}
}
return variantAnnotationSets.get(0);
}
}
29 changes: 9 additions & 20 deletions cts-java/src/test/java/org/ga4gh/cts/api/reads/ReadsSearchIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,23 @@ public class ReadsSearchIT implements CtkLogs {
* @throws AvroRemoteException if there's a communication problem or server exception ({@link GAException})
*/
@Test
public void searchReadsWithUninterestingRangeProducesZeroReads() throws AvroRemoteException {

public void searchRangeWithNoReadsReturnsZeroResults() throws AvroRemoteException {
final String refId = Utils.getValidReferenceId(client);

final long emptyRangeStart = 150;
final long emptyRangeEnd = 160;

final SearchReadGroupSetsRequest req =
SearchReadGroupSetsRequest.newBuilder()
.setDatasetId(TestData.getDatasetId())
.build();
final SearchReadGroupSetsResponse resp = client.reads.searchReadGroupSets(req);

final List<ReadGroupSet> readGroupSets = resp.getReadGroupSets();
final long emptyRangeStart = 0; // is this range actually empty?
final long emptyRangeEnd = 100;

final SearchReadsRequest srReq =
SearchReadsRequest.newBuilder()
.setReferenceId(refId)
.setReadGroupIds(aSingle(Utils.getReadGroupId(client)))
.setStart(emptyRangeStart)
.setEnd(emptyRangeEnd)
.build();
.setReferenceId(refId)
.setReadGroupIds(aSingle(Utils.getReadGroupId(client)))
.setStart(emptyRangeStart)
.setEnd(emptyRangeEnd)
.build();
final SearchReadsResponse srResp = client.reads.searchReads(srReq);

final List<ReadAlignment> alignments = srResp.getAlignments();
assertThat(alignments).isNotEmpty();

assertThat(alignments).doesNotContain(Utils.nullReadAlignment);
assertThat(alignments).isEmpty();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public void checkVariantAnnotationAnalysis() throws AvroRemoteException {
// Check the Analysis record within the VariantAnnotationSet matches the test data
final String name = "compliance1";
final String description = "variant annotation test data";
final String created = "2015-11-18";
final String created = "2015-11-18T00:00:00.000000Z";
final String software = "SnpEff";

assertThat(vSet.getAnalysis().getName()).isEqualTo(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public void checkPagingOneByOneThroughVariantAnnotations() throws AvroRemoteExce
final long end = 11008;

// Find a compliance variantAnnotationSet id.
final String variantAnnotationSetId = Utils.getVariantAnnotationSetId(client);

final String variantAnnotationSetId = Utils.getVariantAnnotationSetByName(client, TestData.VARIANT_ANNOTATION_SET_NAMES.get(0)).getId();
final List<VariantAnnotation> listOfVariantAnnotations = Utils.getAllVariantAnnotationsInRange(client, variantAnnotationSetId, start, end);

// We will remove VariantAnnotations from this Set and assert at the end that we have zero
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,12 @@
import org.ga4gh.cts.api.TestData;
import org.ga4gh.cts.api.Utils;
import org.ga4gh.methods.*;
import org.ga4gh.models.Variant;
import org.ga4gh.models.VariantSet;
import org.ga4gh.models.VariantAnnotationSet;
import org.ga4gh.models.VariantAnnotation;
import org.ga4gh.models.TranscriptEffect;
import org.ga4gh.models.HGVSAnnotation;
import org.ga4gh.models.AlleleLocation;
import org.ga4gh.models.AnalysisResult;
import org.ga4gh.models.Impact;
import org.ga4gh.models.*;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import java.net.HttpURLConnection;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;

Expand Down Expand Up @@ -72,7 +65,8 @@ private void checkAllTranscriptEffects(List<VariantAnnotation> variantAnnotation
public void checkSearchingVariantAnnotations() throws AvroRemoteException {

// Obtain a VariantAnnotationSet from the compliance dataset.
final String variantAnnotationSetId = Utils.getVariantAnnotationSetId(client);
final String variantAnnotationSetId =
Utils.getVariantAnnotationSetByName(client, TestData.VARIANT_ANNOTATION_SET_NAMES.get(0)).getId();


// Seek variant annotation records for the extracted VariantAnnotationSet.
Expand Down Expand Up @@ -186,7 +180,8 @@ public void checkTranscriptEffects() throws AvroRemoteException {
public void checkSearchingSingleVariantAnnotation() throws AvroRemoteException {

// Obtain a VariantAnnotationSet from the compliance dataset.
final String variantAnnotationSetId = Utils.getVariantAnnotationSetId(client);
final String variantAnnotationSetId =
Utils.getVariantAnnotationSetByName(client, TestData.VARIANT_ANNOTATION_SET_NAMES.get(1)).getId();
final long single_start = 69540;
final long single_end = 69541;

Expand Down Expand Up @@ -235,7 +230,8 @@ public void checkSearchingSingleVariantAnnotation() throws AvroRemoteException {
public void checkVariantAnnotationVariants() throws AvroRemoteException {

// Obtain a VariantAnnotationSet from the compliance dataset.
final String variantAnnotationSetId = Utils.getVariantAnnotationSetId(client);
final String variantAnnotationSetId =
Utils.getVariantAnnotationSetByName(client, TestData.VARIANT_ANNOTATION_SET_NAMES.get(0)).getId();

// Seek variant annotation records for the extracted VariantAnnotationSet.
final SearchVariantAnnotationsRequest req =
Expand All @@ -247,7 +243,7 @@ public void checkVariantAnnotationVariants() throws AvroRemoteException {
.build();

final SearchVariantAnnotationsResponse resp = client.variantAnnotations.searchVariantAnnotations(req);

assertThat(resp.getVariantAnnotations()).isNotEmpty();
//Check a valid variant id is returned for each record.
for( VariantAnnotation variantAnn : resp.getVariantAnnotations() ){
final String variantId = variantAnn.getVariantId();
Expand All @@ -256,6 +252,40 @@ public void checkVariantAnnotationVariants() throws AvroRemoteException {
Variant v = client.variants.getVariant(variantId);
assertThat(v).isNotNull();
assertThat(v.getId()).isEqualTo(variantId);
assertThat(v.getStart()).isGreaterThanOrEqualTo(start);
}
}

/**
* Check whether filtering by effect ID finds the expected annotations.
*
*@throws AvroRemoteException if there's a communication problem or server exception ({@link GAException})
*/
@Test
public void checkFilteringByEffectTerm() throws AvroRemoteException {

final OntologyTerm term = new OntologyTerm("SO:0001819", "synonymous_variant", "source", "0");
// Obtain a VariantAnnotationSet from the compliance dataset.
final String variantAnnotationSetId =
Utils.getVariantAnnotationSetByName(client, TestData.VARIANT_ANNOTATION_SET_NAMES.get(1)).getId();

// Seek variant annotation records for the extracted VariantAnnotationSet.
final SearchVariantAnnotationsRequest req =
SearchVariantAnnotationsRequest.newBuilder()
.setVariantAnnotationSetId(variantAnnotationSetId)
.setReferenceName(TestData.VARIANT_ANNOTATION_REFERENCE_NAME)
.setStart(0)
.setEnd(100000)
.setEffects(Arrays.asList(term))
.build();

final SearchVariantAnnotationsResponse resp = client.variantAnnotations.searchVariantAnnotations(req);

// There are 7 records with the "synonymous_variant" term in the test data.
assertThat(resp.getVariantAnnotations()).hasSize(7);
//Check the transcript effect field is not empty for each annotation.
for( VariantAnnotation variantAnn : resp.getVariantAnnotations() ){
assertThat(variantAnn.getTranscriptEffects()).isNotEmpty();
}
}

Expand Down
Loading

0 comments on commit 79a923f

Please sign in to comment.