Skip to content

Commit 94fc82c

Browse files
cmpichoblodgett
andauthored
SCRUM-3995 phenotype annotations on gene and allele page (#1235)
* SCRUM-3995 start of phenotype annotation indexer * small refactor * small refactor * small refactor * SCRUM-3995 create PhenotypeAnnotationIndexer * make phenotypeStatement sortable with case insensitive * create new field with sort directive for phenotype statement * remove unused code * SCRUM-4092 make all disease qualifier names be their original names including underscores * refactor implicated DAs * remove comments * add allele phenotype annotations and include inferred gene / asserted gene records * remove debugging code * rebased on stage, needed changes for the v0.36.1 version, fix downloads endpoint * add allele indexing to the phenotype annotation indexer * SCRUM-4869 populate associated gene to transcript object * Add allele indexing * SCRUM-4724 convert phenotype table on allele page * fix checkstyle issues * merging stage code and optimize classes * fix code style recommendations * refactor to remove unsued code * remove unused imports * more refactoring aroudn ESService classes * more refactoring * fix merging issues * fix merging issues * remove unused method * clear out method from child class * Removed tabs spaces issues * Cleaned up indexer config --------- Co-authored-by: Olin Blodgett <nilo@nilosplace.net>
1 parent 5f2f13d commit 94fc82c

27 files changed

+1343
-651
lines changed

agr_api/src/main/java/org/alliancegenome/api/controller/AlleleController.java

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.alliancegenome.api.controller;
22

3-
import java.time.LocalDateTime;
4-
3+
import jakarta.enterprise.context.RequestScoped;
4+
import jakarta.inject.Inject;
5+
import jakarta.ws.rs.core.Response;
6+
import lombok.extern.slf4j.Slf4j;
57
import org.alliancegenome.api.entity.AlleleDiseaseAnnotationDocument;
8+
import org.alliancegenome.api.entity.AllelePhenotypeAnnotationDocument;
69
import org.alliancegenome.api.rest.interfaces.AlleleRESTInterface;
7-
import org.alliancegenome.api.service.AlleleService;
8-
import org.alliancegenome.api.service.DiseaseESService;
9-
import org.alliancegenome.api.service.EntityType;
10-
import org.alliancegenome.api.service.VariantService;
10+
import org.alliancegenome.api.service.*;
1111
import org.alliancegenome.api.service.helper.APIServiceHelper;
1212
import org.alliancegenome.api.translators.tdf.DiseaseAnnotationToTdfTranslator;
1313
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
@@ -17,14 +17,10 @@
1717
import org.alliancegenome.core.translators.tdf.PhenotypeAnnotationToTdfTranslator;
1818
import org.alliancegenome.es.model.query.FieldFilter;
1919
import org.alliancegenome.es.model.query.Pagination;
20-
import org.alliancegenome.neo4j.entity.PhenotypeAnnotation;
2120
import org.alliancegenome.neo4j.entity.node.Allele;
2221
import org.alliancegenome.neo4j.entity.node.Variant;
2322

24-
import jakarta.enterprise.context.RequestScoped;
25-
import jakarta.inject.Inject;
26-
import jakarta.ws.rs.core.Response;
27-
import lombok.extern.slf4j.Slf4j;
23+
import java.time.LocalDateTime;
2824

2925
@Slf4j
3026
@RequestScoped
@@ -39,11 +35,13 @@ public class AlleleController implements AlleleRESTInterface {
3935
@Inject
4036
DiseaseESService diseaseESService;
4137

38+
@Inject
39+
PhenotypeESService phenotypeESService;
4240
//@Inject
4341
//private HttpRequest request;
4442

4543
private AlleleToTdfTranslator translator = new AlleleToTdfTranslator();
46-
private final PhenotypeAnnotationToTdfTranslator phenotypeAnnotationToTdfTranslator = new PhenotypeAnnotationToTdfTranslator();
44+
private PhenotypeAnnotationToTdfTranslator phenotypeTranslator = new PhenotypeAnnotationToTdfTranslator();
4745
private final DiseaseAnnotationToTdfTranslator diseaseToTdfTranslator = new DiseaseAnnotationToTdfTranslator();
4846

4947
@Override
@@ -106,25 +104,25 @@ public JsonResultResponse<Allele> getAllelesPerSpecies(String species, Integer l
106104
}
107105

108106
@Override
109-
public JsonResultResponse<PhenotypeAnnotation> getPhenotypePerAllele(String id, Integer limit, Integer page, String phenotype, String source, String reference, String sortBy) {
107+
public JsonResultResponse<AllelePhenotypeAnnotationDocument> getPhenotypePerAllele(
108+
String id,
109+
Integer limit,
110+
Integer page,
111+
String phenotype,
112+
String source,
113+
String reference,
114+
String sortBy) {
110115
long startTime = System.currentTimeMillis();
111116
Pagination pagination = new Pagination(page, limit, sortBy, null);
112-
pagination.addFieldFilter(FieldFilter.PHENOTYPE, phenotype);
113-
pagination.addFieldFilter(FieldFilter.SOURCE, source);
114-
pagination.addFieldFilter(FieldFilter.FREFERENCE, reference);
115-
if (pagination.hasErrors()) {
116-
RestErrorMessage message = new RestErrorMessage();
117-
message.setErrors(pagination.getErrors());
118-
throw new RestErrorException(message);
119-
}
120-
117+
pagination.addFilterOption("phenotypeStatement", phenotype);
118+
pagination.addFilterOption("pubmedPubModIDs", reference);
121119
try {
122-
JsonResultResponse<PhenotypeAnnotation> phenotypeAnnotation = alleleService.getPhenotype(id, pagination);
123-
phenotypeAnnotation.setHttpServletRequest(null);
124-
phenotypeAnnotation.calculateRequestDuration(startTime);
125-
return phenotypeAnnotation;
120+
JsonResultResponse<AllelePhenotypeAnnotationDocument> phenotypes = phenotypeESService.getAllelePhenotypeAnnotations(id, pagination, false);
121+
phenotypes.setHttpServletRequest(null);
122+
phenotypes.calculateRequestDuration(startTime);
123+
return phenotypes;
126124
} catch (Exception e) {
127-
log.error("Error while retrieving phenotype info", e);
125+
log.error("Error while retrieving phenotypes", e);
128126
RestErrorMessage error = new RestErrorMessage();
129127
error.addErrorMessage(e.getMessage());
130128
throw new RestErrorException(error);
@@ -133,34 +131,37 @@ public JsonResultResponse<PhenotypeAnnotation> getPhenotypePerAllele(String id,
133131

134132
@Override
135133
public Response getPhenotypesPerAlleleDownload(String id, String phenotype, String source, String reference, String sortBy) {
136-
JsonResultResponse<PhenotypeAnnotation> response = getPhenotypePerAllele(id,
137-
Integer.MAX_VALUE,
138-
1,
139-
phenotype,
140-
source,
141-
reference,
142-
sortBy);
143-
Response.ResponseBuilder responseBuilder = Response.ok(phenotypeAnnotationToTdfTranslator.getAllRowsForAlleles(response.getResults()));
134+
// retrieve all records
135+
JsonResultResponse<AllelePhenotypeAnnotationDocument> response =
136+
getPhenotypePerAllele(id,
137+
250000,
138+
1,
139+
phenotype,
140+
source,
141+
reference,
142+
sortBy);
143+
Response.ResponseBuilder responseBuilder = Response.ok(phenotypeTranslator.getAllRows(response.getResults()));
144144
APIServiceHelper.setDownloadHeader(id, EntityType.ALLELE, EntityType.PHENOTYPE, responseBuilder);
145145
return responseBuilder.build();
146146
}
147147

148148
@Override
149-
public JsonResultResponse<AlleleDiseaseAnnotationDocument> getDiseasePerAllele(String alleleID,
150-
String filterOptions,
151-
String filterReference,
152-
String diseaseTerm,
153-
String filterSource,
154-
String geneticEntity,
155-
String geneticEntityType,
156-
String associationType,
157-
String diseaseQualifier,
158-
String evidenceCode,
159-
Boolean debug,
160-
Integer limit,
161-
Integer page,
162-
String sortBy,
163-
String asc) {
149+
public JsonResultResponse<AlleleDiseaseAnnotationDocument> getDiseasePerAllele(
150+
String alleleID,
151+
String filterOptions,
152+
String filterReference,
153+
String diseaseTerm,
154+
String filterSource,
155+
String geneticEntity,
156+
String geneticEntityType,
157+
String associationType,
158+
String diseaseQualifier,
159+
String evidenceCode,
160+
Boolean debug,
161+
Integer limit,
162+
Integer page,
163+
String sortBy,
164+
String asc) {
164165

165166
LocalDateTime startDate = LocalDateTime.now();
166167
Pagination pagination = new Pagination(page, limit, sortBy, asc);

0 commit comments

Comments
 (0)