Skip to content

Commit

Permalink
[DT-773][risk=no] adding ability to use variantFilter to select varia…
Browse files Browse the repository at this point in the history
…nts. (#8418)

* DT-773 adding filter for variants

* DT-773 fixing compile issues.
  • Loading branch information
freemabd authored Mar 6, 2024
1 parent 635e3d0 commit e0ced94
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2498,7 +2498,8 @@ public void filterBigQueryConfig_WithoutTableName() {
@ParameterizedTest
@ValueSource(strings = {"1-101504524-G-A", "gene", "chr20:955-1000", "rs23346"})
public void findVariants(String searchTerm) {
VariantFilterRequest request = new VariantFilterRequest().searchTerm(searchTerm);
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm(searchTerm);
Variant expectedVariant =
new Variant()
.vid("1-101504524-G-A")
Expand All @@ -2515,11 +2516,11 @@ public void findVariants(String searchTerm) {

@Test
public void findVariantsFilterByConsequence() {
VariantFilterRequest request =
new VariantFilterRequest()
.searchTerm("gene")
.addConsequenceListItem("intron_variant")
.addConsequenceListItem("non_coding_transcript_variant");
VariantFilterRequest request = new VariantFilterRequest();
request
.searchTerm("gene")
.addConsequenceListItem("intron_variant")
.addConsequenceListItem("non_coding_transcript_variant");
Variant expectedVariant =
new Variant()
.vid("1-101504524-G-A")
Expand All @@ -2536,11 +2537,11 @@ public void findVariantsFilterByConsequence() {

@Test
public void findVariantsFilterByConsequenceNA() {
VariantFilterRequest request =
new VariantFilterRequest()
.searchTerm("gene3")
.addConsequenceListItem("n/a")
.addConsequenceListItem("intron_variant");
VariantFilterRequest request = new VariantFilterRequest();
request
.searchTerm("gene3")
.addConsequenceListItem("n/a")
.addConsequenceListItem("intron_variant");
Variant expectedVariant =
new Variant()
.vid("1-100550658-T-AA")
Expand All @@ -2557,11 +2558,11 @@ public void findVariantsFilterByConsequenceNA() {

@Test
public void findVariantsFilterByClinicalSignificance() {
VariantFilterRequest request =
new VariantFilterRequest()
.searchTerm("gene")
.addClinicalSignificanceListItem("likely pathogenic")
.addClinicalSignificanceListItem("pathogenic");
VariantFilterRequest request = new VariantFilterRequest();
request
.searchTerm("gene")
.addClinicalSignificanceListItem("likely pathogenic")
.addClinicalSignificanceListItem("pathogenic");
Variant expectedVariant =
new Variant()
.vid("1-101504524-G-A")
Expand All @@ -2578,11 +2579,11 @@ public void findVariantsFilterByClinicalSignificance() {

@Test
public void findVariantsFilterByClinicalSignificanceNA() {
VariantFilterRequest request =
new VariantFilterRequest()
.searchTerm("gene3")
.addClinicalSignificanceListItem("n/a")
.addClinicalSignificanceListItem("pathogenic");
VariantFilterRequest request = new VariantFilterRequest();
request
.searchTerm("gene3")
.addClinicalSignificanceListItem("n/a")
.addClinicalSignificanceListItem("pathogenic");
Variant expectedVariant =
new Variant()
.vid("1-100550658-T-AA")
Expand All @@ -2599,8 +2600,8 @@ public void findVariantsFilterByClinicalSignificanceNA() {

@Test
public void findVariantsFilterByGeneList() {
VariantFilterRequest request =
new VariantFilterRequest().searchTerm("gene").addGeneListItem("gene, gene2");
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm("gene").addGeneListItem("gene, gene2");
Variant expectedVariant =
new Variant()
.vid("1-101504524-G-A")
Expand All @@ -2617,8 +2618,8 @@ public void findVariantsFilterByGeneList() {

@Test
public void findVariantsFilterByGenesListNA() {
VariantFilterRequest request =
new VariantFilterRequest().searchTerm("rs23347").addGeneListItem("n/a");
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm("rs23347").addGeneListItem("n/a");
Variant expectedVariant =
new Variant()
.vid("1-100550658-T-AH")
Expand All @@ -2634,15 +2635,15 @@ public void findVariantsFilterByGenesListNA() {

@Test
public void findVariantsFilterByMinAndMax() {
VariantFilterRequest request =
new VariantFilterRequest()
.searchTerm("gene")
.countMin(4L)
.countMax(5L)
.numberMin(18242L)
.numberMax(18245L)
.frequencyMin(new BigDecimal("0.000277").setScale(6, RoundingMode.HALF_UP))
.frequencyMax(new BigDecimal(1).setScale(6, RoundingMode.HALF_UP));
VariantFilterRequest request = new VariantFilterRequest();
request
.searchTerm("gene")
.countMin(4L)
.countMax(5L)
.numberMin(18242L)
.numberMax(18245L)
.frequencyMin(new BigDecimal("0.000277").setScale(6, RoundingMode.HALF_UP))
.frequencyMax(new BigDecimal(1).setScale(6, RoundingMode.HALF_UP));
Variant expectedVariant =
new Variant()
.vid("1-101504524-G-A")
Expand All @@ -2659,8 +2660,9 @@ public void findVariantsFilterByMinAndMax() {

@Test
public void findVariantsSortByAlleleCount() {
VariantFilterRequest request =
new VariantFilterRequest().searchTerm("gene1").pageSize(1).sortBy("Allele Count");
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm("gene1");
request.pageSize(1).sortBy("Allele Count");
Variant expectedVariant =
new Variant()
.vid("1-100550658-T-H")
Expand Down Expand Up @@ -2692,7 +2694,9 @@ private void assertFindVariantsResponse(

@Test
public void findVariants_Pagination() {
VariantFilterRequest request = new VariantFilterRequest().searchTerm("gene1").pageSize(1);
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm("gene1");
request.pageSize(1);
VariantListResponse response =
controller.findVariants(WORKSPACE_NAMESPACE, WORKSPACE_ID, request).getBody();
List<Variant> items = Objects.requireNonNull(response).getItems();
Expand Down Expand Up @@ -2739,20 +2743,20 @@ public void findVariants_Pagination() {

@Test
public void findVariantFilters() {
VariantFilterRequest request = new VariantFilterRequest().searchTerm("chr20:1000-5000");
VariantFilterResponse expectedVariantFilter =
new VariantFilterResponse()
.geneList(Arrays.asList("gene, gene2", "gene3"))
.consequenceList(
Arrays.asList("intron_variant", "n/a", "non_coding_transcript_variant"))
.clinicalSignificanceList(Arrays.asList("likely pathogenic", "n/a", "pathogenic"))
.countMin(5L)
.countMax(7L)
.numberMin(18226L)
.numberMax(18242L)
.frequencyMin(new BigDecimal(0))
.frequencyMax(new BigDecimal(1))
.sortByList(VariantQueryBuilder.VatColumns.getDisplayNameList());
VariantFilterRequest request = new VariantFilterRequest();
request.searchTerm("chr20:1000-5000");
VariantFilterResponse expectedVariantFilter = new VariantFilterResponse();
expectedVariantFilter
.geneList(Arrays.asList("gene, gene2", "gene3"))
.consequenceList(Arrays.asList("intron_variant", "n/a", "non_coding_transcript_variant"))
.clinicalSignificanceList(Arrays.asList("likely pathogenic", "n/a", "pathogenic"))
.countMin(5L)
.countMax(7L)
.numberMin(18226L)
.numberMax(18242L)
.frequencyMin(new BigDecimal(0))
.frequencyMax(new BigDecimal(1));
expectedVariantFilter.sortByList(VariantQueryBuilder.VatColumns.getDisplayNameList());
assertFindVariantFiltersResponse(request, expectedVariantFilter);
}

Expand Down
101 changes: 46 additions & 55 deletions api/src/main/resources/workbench-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10953,6 +10953,8 @@ components:
variantId:
type: string
description: The variant id of SNP Indel Variants.
variantFilter:
$ref: '#/components/schemas/VariantFilter'
attributes:
type: array
description: |
Expand Down Expand Up @@ -11237,20 +11239,9 @@ components:
format: int64
conceptName:
type: string
VariantFilterRequest:
BaseVariantFilter:
type: object
required:
- searchTerm
properties:
searchTerm:
type: string
description: The term used to search variants.
pageToken:
type: string
description: Used for retrieving additional pages of results.
pageSize:
type: integer
description: page size of results (default is 25)
geneList:
type: array
description: List of string gene names
Expand Down Expand Up @@ -11288,54 +11279,54 @@ components:
frequencyMax:
type: number
description: Allele number max(floating point)
sortBy:
type: string
description: sort column by
VariantFilterResponse:
participantCountRange:
$ref: '#/components/schemas/ParticipantCountFilter'
VariantFilter:
allOf:
- $ref: '#/components/schemas/BaseVariantFilter'
- type: object
required:
- searchTerm
properties:
searchTerm:
type: string
description: The term used to search variants.
VariantFilterRequest:
allOf:
- $ref: '#/components/schemas/VariantFilter'
- type: object
properties:
pageToken:
type: string
description: Used for retrieving additional pages of results.
pageSize:
type: integer
description: page size of results (default is 25)
sortBy:
type: string
description: sort column by
ParticipantCountFilter:
required:
- operator
- operands
type: object
properties:
geneList:
type: array
description: List of string gene names
items:
type: string
consequenceList:
type: array
description: List of string consequence names
items:
type: string
clinicalSignificanceList:
type: array
description: List of string clinical significance names
items:
type: string
countMin:
type: integer
format: int64
description: Allele count min
countMax:
type: integer
format: int64
description: Allele count max
numberMin:
type: integer
format: int64
description: Allele number min
numberMax:
type: integer
format: int64
description: Allele number max
frequencyMin:
type: number
description: Allele frequency min(floating point)
frequencyMax:
type: number
description: Allele number max(floating point)
sortByList:
operator:
$ref: '#/components/schemas/Operator'
operands:
type: array
description: List of string column names
items:
type: string
VariantFilterResponse:
allOf:
- $ref: '#/components/schemas/BaseVariantFilter'
- type: object
properties:
sortByList:
type: array
description: List of string column names
items:
type: string
VariantListResponse:
required:
- items
Expand Down

0 comments on commit e0ced94

Please sign in to comment.