Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RM-130: Update MME metrics to accommodate new gene statuses #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
<artifactId>matching-notification-api</artifactId>
<version>${patientNetwork.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>patient-data-default-impl</artifactId>
<version>${phenotips.version}</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ public Object compute()
Session session = null;
try {
session = this.sessionFactory.getSessionFactory().openSession();

String candidateStatuses = "";
GENE_STATUS_VALUES.stream()
.filter(status -> status.startsWith("candidate"))
.forEach(status -> candidateStatuses.concat("'" + status + "',"));

Query q = session.createQuery("select count (geneObj.name) from "
+ HQL_BASE_MME_PATIENT_FILTER_FROM
+ ", BaseObject geneObj, StringProperty geneStatusProp"
+ " where "
+ HQL_BASE_MME_PATIENT_FILTER_WHERE
+ " and geneObj.name = doc.fullName and geneObj.className = 'PhenoTips.GeneClass'"
+ " and geneStatusProp.id.id = geneObj.id and geneStatusProp.id.name = 'status'"
+ " and geneStatusProp.value in ('candidate', 'solved')");
+ " and geneStatusProp.value in (" + candidateStatuses + " 'solved')");
return q.uniqueResult();
} finally {
if (session != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ public Object compute()
try {
session = this.sessionFactory.getSessionFactory().openSession();

String candidateStatuses = "";
GENE_STATUS_VALUES.stream()
.filter(status -> status.startsWith("candidate"))
.forEach(status -> candidateStatuses.concat("'" + status + "',"));

Query q = session.createQuery(
"select count (distinct geneIDProp.value) from "
+ HQL_BASE_MME_PATIENT_FILTER_FROM
Expand All @@ -58,7 +63,7 @@ public Object compute()
+ HQL_BASE_MME_PATIENT_FILTER_WHERE
+ " and geneObj.name = doc.fullName and geneObj.className = 'PhenoTips.GeneClass'"
+ " and geneStatusProp.id.id = geneObj.id and geneStatusProp.id.name = 'status'"
+ " and geneStatusProp.value in ('candidate', 'solved')"
+ " and geneStatusProp.value in (" + candidateStatuses + " 'solved')"
+ " and geneIDProp.id.id = geneObj.id and geneIDProp.id.name = 'gene'");
return q.uniqueResult();
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public Object compute()
Session session = null;
try {
session = this.sessionFactory.getSessionFactory().openSession();

String candidateStatuses = "";
GENE_STATUS_VALUES.stream()
.filter(status -> status.startsWith("candidate"))
.forEach(status -> candidateStatuses.concat("'" + status + "',"));

Query q = session.createQuery("select count (distinct variantIDProp.value) from "
+ HQL_BASE_MME_PATIENT_FILTER_FROM
+ ", BaseObject geneObj, BaseObject variantObj, StringProperty geneStatusProp"
Expand All @@ -58,7 +64,7 @@ public Object compute()
+ " and geneObj.name = doc.fullName and geneObj.className = 'PhenoTips.GeneClass'"
+ " and variantObj.name = doc.fullName and variantObj.className = 'PhenoTips.GeneVariantClass'"
+ " and geneStatusProp.id.id = geneObj.id and geneStatusProp.id.name = 'status'"
+ " and geneStatusProp.value in ('candidate', 'solved')"
+ " and geneStatusProp.value in (" + candidateStatuses + " 'solved')"
+ " and variantIDProp.id.id = variantObj.id and variantIDProp.id.name = 'cdna'"
+ " and variantGeneProp.id.id = variantObj.id and variantGeneProp.id.name = 'gene'"
+ " and geneIDProp.id.id = geneObj.id and geneIDProp.id.name = 'gene'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public Object compute()
Session session = null;
try {
session = this.sessionFactory.getSessionFactory().openSession();

String candidateStatuses = "";
GENE_STATUS_VALUES.stream()
.filter(status -> status.startsWith("candidate"))
.forEach(status -> candidateStatuses.concat("'" + status + "',"));

Query q = session.createQuery("select count (variantObj.name) from "
+ HQL_BASE_MME_PATIENT_FILTER_FROM
+ ", BaseObject geneObj, BaseObject variantObj, StringProperty geneStatusProp"
Expand All @@ -58,7 +64,7 @@ public Object compute()
+ " and geneObj.name = doc.fullName and geneObj.className = 'PhenoTips.GeneClass'"
+ " and variantObj.name = doc.fullName and variantObj.className = 'PhenoTips.GeneVariantClass'"
+ " and geneStatusProp.id.id = geneObj.id and geneStatusProp.id.name = 'status'"
+ " and geneStatusProp.value in ('candidate', 'solved')"
+ " and geneStatusProp.value in (" + candidateStatuses + " 'solved')"
+ " and variantGeneProp.id.id = variantObj.id and variantGeneProp.id.name = 'gene'"
+ " and geneIDProp.id.id = geneObj.id and geneIDProp.id.name = 'gene'"
+ " and geneIDProp.value = variantGeneProp.value");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
*/
package org.phenotips.remote.metrics.spi;

import org.phenotips.data.internal.PhenoTipsGene;
import org.phenotips.remote.metrics.MetricsRequestHandler;

import org.xwiki.component.annotation.Role;

import java.util.List;

/**
* Provides a specific metric to be included in a {@link MetricsRequestHandler#getMetrics() metrics response}. The
* produced metric value will be included in the response JSON, inside the {@code metrics} map, under the same name as
Expand Down Expand Up @@ -50,6 +53,8 @@ public interface MetricProvider
+ " and visibilityProp.id.id = visibilityObj.id and visibilityProp.id.name = 'visibility'"
+ " and visibilityProp.value <> 'private'";

List<String> GENE_STATUS_VALUES = PhenoTipsGene.getStatusValues();

/**
* Compute and return a specific metric to be included in the response to a MME metrics query.
*
Expand Down