Skip to content

Commit

Permalink
Update GenericAssayFilter to support NA's
Browse files Browse the repository at this point in the history
  • Loading branch information
haynescd committed Oct 9, 2024
1 parent b61739a commit 842a868
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public ResponseEntity<List<GenomicDataCountItem>> fetchGenomicDataCounts(
}

@PreAuthorize("hasPermission(#involvedCancerStudies, 'Collection<CancerStudyId>', T(org.cbioportal.utils.security.AccessLevel).READ)")
@RequestMapping(value = "/column-store/generic-assay-data-counts/fetch", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/column-store/generic-assay-data-counts/fetch", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(description = "Fetch generic assay data counts by study view filter")
@ApiResponse(responseCode = "200", description = "OK",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = GenericAssayDataCountItem.class))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@
<choose>
<when test="dataFilterValue.value == 'NA'">
empty(attribute_value)
OR
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="attribute_value"/>
</include> = 'NA'
</when>
<otherwise>
(
Expand Down Expand Up @@ -541,13 +545,11 @@
</foreach>
</sql>

<sql id="selectAllNumericalGenericAssays">
SELECT sample_unique_id, value
<sql id="selectAllGenericAssays">
SELECT sample_unique_id, value, datatype
FROM generic_assay_data_derived
WHERE profile_type = #{genericAssayDataFilter.profileType}
AND entity_stable_id = #{genericAssayDataFilter.stableId}
<!-- It needs to include all numerical data types. Currently it's only LIMIT-VALUE -->
AND datatype = 'LIMIT-VALUE'
</sql>

<!-- TODO: update the database scheme to include the data_type column -->
Expand All @@ -569,8 +571,9 @@
<if test="userSelectsNA">
SELECT DISTINCT sd.sample_unique_id
FROM sample_derived sd
LEFT JOIN (<include refid="selectAllNumericalGenericAssays"/>) AS generic_numerical_query ON sd.sample_unique_id = generic_numerical_query.sample_unique_id
WHERE value IS null OR
LEFT JOIN (<include refid="selectAllGenericAssays"/>) AS generic_numerical_query ON sd.sample_unique_id = generic_numerical_query.sample_unique_id
WHERE datatype = 'LIMIT-VALUE'
AND value IS null OR
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="value"/>
</include> = 'NA'
Expand All @@ -582,8 +585,10 @@
<!-- if non-NA is selected, prepare non-NA samples -->
<if test="userSelectsNumericalValue">
SELECT DISTINCT sample_unique_id
FROM (<include refid="selectAllNumericalGenericAssays"/>) AS generic_numerical_query
FROM (<include refid="selectAllGenericAssays"/>) AS generic_numerical_query
WHERE
datatype = 'LIMIT-VALUE'
AND
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="value"/>
</include> != 'NA'
Expand Down Expand Up @@ -639,18 +644,29 @@

<sql id="categoricalGenericAssayDataCountFilter">
SELECT ${unique_id}
FROM ${table_name}
WHERE entity_stable_id = '${genericAssayDataFilter.stableId}' AND
profile_type='${genericAssayDataFilter.profileType}'
<foreach item="dataFilterValue" collection="genericAssayDataFilter.values" open=" AND ((" separator=") OR (" close="))">
<trim prefix="" prefixOverrides="AND">
AND (
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="value"/>
</include>
) ILIKE '${dataFilterValue.value}'
</trim>
</foreach>
FROM sample_derived sd
LEFT JOIN (<include refid="selectAllGenericAssays"/>) AS generic_assay_query
ON sd.sample_unique_id = generic_assay_query.sample_unique_id
<where>
datatype != 'LIMIT-VALUE'
<foreach item="dataFilterValue" collection="genericAssayDataFilter.values" open=" AND ((" separator=") OR (" close="))">
<choose>
<when test="dataFilterValue.value == 'NA'">
value IS null OR
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="value"/>
</include> = 'NA'
</when>
<otherwise>
(
<include refid="normalizeAttributeValue">
<property name="attribute_value" value="value"/>
</include>
) ILIKE '${dataFilterValue.value}'
</otherwise>
</choose>
</foreach>
</where>
</sql>

<sql id="applyMutationDataFilter">
Expand Down

0 comments on commit 842a868

Please sign in to comment.