Skip to content

Commit 8d42342

Browse files
committed
merge SCRUM-3995 int stage
2 parents d63c3fd + 2ac5447 commit 8d42342

26 files changed

+1793
-239
lines changed

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

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import java.time.LocalDateTime;
44

55
import org.alliancegenome.api.entity.AlleleDiseaseAnnotationDocument;
6+
import org.alliancegenome.api.entity.AllelePhenotypeAnnotationDocument;
7+
import org.alliancegenome.api.entity.GenePhenotypeAnnotationDocument;
68
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;
9+
import org.alliancegenome.api.service.*;
1110
import org.alliancegenome.api.service.helper.APIServiceHelper;
1211
import org.alliancegenome.api.translators.tdf.DiseaseAnnotationToTdfTranslator;
1312
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
@@ -39,10 +38,13 @@ public class AlleleController implements AlleleRESTInterface {
3938
@Inject
4039
DiseaseESService diseaseESService;
4140

41+
@Inject
42+
PhenotypeESService phenotypeESService;
4243
//@Inject
4344
//private HttpRequest request;
4445

4546
private AlleleToTdfTranslator translator = new AlleleToTdfTranslator();
47+
private PhenotypeAnnotationToTdfTranslator phenotypeTranslator = new PhenotypeAnnotationToTdfTranslator();
4648
private final PhenotypeAnnotationToTdfTranslator phenotypeAnnotationToTdfTranslator = new PhenotypeAnnotationToTdfTranslator();
4749
private final DiseaseAnnotationToTdfTranslator diseaseToTdfTranslator = new DiseaseAnnotationToTdfTranslator();
4850

@@ -106,25 +108,24 @@ public JsonResultResponse<Allele> getAllelesPerSpecies(String species, Integer l
106108
}
107109

108110
@Override
109-
public JsonResultResponse<PhenotypeAnnotation> getPhenotypePerAllele(String id, Integer limit, Integer page, String phenotype, String source, String reference, String sortBy) {
111+
public JsonResultResponse<AllelePhenotypeAnnotationDocument> getPhenotypePerAllele(String id,
112+
Integer limit,
113+
Integer page,
114+
String phenotype,
115+
String source,
116+
String reference,
117+
String sortBy) {
110118
long startTime = System.currentTimeMillis();
111119
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-
120+
pagination.addFilterOption("phenotypeStatement", phenotype);
121+
pagination.addFilterOption("pubmedPubModIDs", reference);
121122
try {
122-
JsonResultResponse<PhenotypeAnnotation> phenotypeAnnotation = alleleService.getPhenotype(id, pagination);
123-
phenotypeAnnotation.setHttpServletRequest(null);
124-
phenotypeAnnotation.calculateRequestDuration(startTime);
125-
return phenotypeAnnotation;
123+
JsonResultResponse<AllelePhenotypeAnnotationDocument> phenotypes = phenotypeESService.getAllelePhenotypeAnnotations(id, pagination, false);
124+
phenotypes.setHttpServletRequest(null);
125+
phenotypes.calculateRequestDuration(startTime);
126+
return phenotypes;
126127
} catch (Exception e) {
127-
log.error("Error while retrieving phenotype info", e);
128+
log.error("Error while retrieving phenotypes", e);
128129
RestErrorMessage error = new RestErrorMessage();
129130
error.addErrorMessage(e.getMessage());
130131
throw new RestErrorException(error);
@@ -133,15 +134,17 @@ public JsonResultResponse<PhenotypeAnnotation> getPhenotypePerAllele(String id,
133134

134135
@Override
135136
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()));
144-
APIServiceHelper.setDownloadHeader(id, EntityType.ALLELE, EntityType.PHENOTYPE, responseBuilder);
137+
// retrieve all records
138+
JsonResultResponse<AllelePhenotypeAnnotationDocument> response =
139+
getPhenotypePerAllele(id,
140+
250000,
141+
1,
142+
phenotype,
143+
source,
144+
reference,
145+
sortBy);
146+
Response.ResponseBuilder responseBuilder = Response.ok(phenotypeTranslator.getAllRows(response.getResults()));
147+
APIServiceHelper.setDownloadHeader(id, EntityType.GENE, EntityType.PHENOTYPE, responseBuilder);
145148
return responseBuilder.build();
146149
}
147150

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

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import org.alliancegenome.api.service.ExpressionService;
2121
import org.alliancegenome.api.service.GeneService;
2222
import org.alliancegenome.api.service.GeneToGeneParalogyESService;
23+
import org.alliancegenome.api.entity.GenePhenotypeAnnotationDocument;
24+
import org.alliancegenome.api.rest.interfaces.GeneRESTInterface;
25+
import org.alliancegenome.api.service.*;
2326
import org.alliancegenome.api.service.helper.APIServiceHelper;
2427
import org.alliancegenome.api.translators.tdf.DiseaseAnnotationToTdfTranslator;
2528
import org.alliancegenome.cache.repository.ExpressionCacheRepository;
@@ -79,6 +82,7 @@ public class GeneController implements GeneRESTInterface {
7982

8083
@Inject
8184
GeneToGeneParalogyESService geneToGeneParalogyESService;
85+
PhenotypeESService phenotypeESService;
8286

8387
private static final PhenotypeAnnotationToTdfTranslator translator = new PhenotypeAnnotationToTdfTranslator();
8488
private static final AlleleToTdfTranslator alleleTanslator = new AlleleToTdfTranslator();
@@ -372,10 +376,18 @@ public Response getInteractionsDownload(String id, String sortBy, String asc,
372376
}
373377

374378
@Override
375-
public JsonResultResponse<PhenotypeAnnotation> getPhenotypeAnnotations(String id, Integer limit, Integer page, String sortBy, String geneticEntity, String geneticEntityType, String phenotype, String reference, String asc) {
379+
public JsonResultResponse<GenePhenotypeAnnotationDocument> getPhenotypeAnnotations(String id, Integer limit, Integer page, String sortBy,
380+
String geneticEntity,
381+
String geneticEntityType,
382+
String phenotype,
383+
String reference,
384+
String asc) {
376385
long startTime = System.currentTimeMillis();
386+
Pagination pagination = new Pagination(page, limit, sortBy, asc);
387+
pagination.addFilterOption("phenotypeStatement", phenotype);
388+
pagination.addFilterOption("pubmedPubModIDs", reference);
377389
try {
378-
JsonResultResponse<PhenotypeAnnotation> phenotypes = getPhenotypeAnnotationDocumentJsonResultResponse(id, limit, page, sortBy, geneticEntity, geneticEntityType, phenotype, reference, asc);
390+
JsonResultResponse<GenePhenotypeAnnotationDocument> phenotypes = phenotypeESService.getGenePhenotypeAnnotations(id, pagination, false);
379391
phenotypes.setHttpServletRequest(null);
380392
phenotypes.calculateRequestDuration(startTime);
381393
return phenotypes;
@@ -397,8 +409,8 @@ public Response getPhenotypeAnnotationsDownloadFile(
397409
String reference,
398410
String asc) {
399411
// retrieve all records
400-
JsonResultResponse<PhenotypeAnnotation> response =
401-
getPhenotypeAnnotationDocumentJsonResultResponse(id, Integer.MAX_VALUE, 1, sortBy,
412+
JsonResultResponse<GenePhenotypeAnnotationDocument> response =
413+
getPhenotypeAnnotations(id, 250000, 1, sortBy,
402414
geneticEntity,
403415
geneticEntityType,
404416
phenotype,
@@ -485,20 +497,6 @@ public JsonResultResponse<PrimaryAnnotatedEntity> getPrimaryAnnotatedEntityForMo
485497
}
486498
}
487499

488-
private JsonResultResponse<PhenotypeAnnotation> getPhenotypeAnnotationDocumentJsonResultResponse(String id, Integer limit, Integer page, String sortBy, String geneticEntity, String geneticEntityType, String phenotype, String reference, String asc) {
489-
if (sortBy.isEmpty()) {
490-
sortBy = FieldFilter.PHENOTYPE.getName();
491-
}
492-
Pagination pagination = new Pagination(page, limit, sortBy, asc);
493-
pagination.addFieldFilter(FieldFilter.GENETIC_ENTITY, geneticEntity);
494-
pagination.addFieldFilter(FieldFilter.GENETIC_ENTITY_TYPE, geneticEntityType);
495-
pagination.addFieldFilter(FieldFilter.PHENOTYPE, phenotype);
496-
pagination.addFieldFilter(FieldFilter.FREFERENCE, reference);
497-
JsonResultResponse<PhenotypeAnnotation> phenotypeAnnotations = geneService.getPhenotypeAnnotations(id, pagination);
498-
phenotypeAnnotations.addAnnotationSummarySupplementalData(getPhenotypeSummary(id));
499-
return phenotypeAnnotations;
500-
}
501-
502500
private JsonResultResponse<DiseaseAnnotation> getDiseaseAnnotationDocumentJsonResultResponse(String id, Integer limit, Integer page, String sortBy, String geneticEntity, String geneticEntityType, String disease, String reference, String asc) {
503501
if (sortBy.isEmpty()) {
504502
sortBy = FieldFilter.DISEASE.getName();

agr_api/src/main/java/org/alliancegenome/api/rest/interfaces/AlleleRESTInterface.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.alliancegenome.api.rest.interfaces;
22

33
import org.alliancegenome.api.entity.AlleleDiseaseAnnotationDocument;
4+
import org.alliancegenome.api.entity.AllelePhenotypeAnnotationDocument;
45
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
56
import org.alliancegenome.neo4j.entity.DiseaseAnnotation;
67
import org.alliancegenome.neo4j.entity.PhenotypeAnnotation;
@@ -84,13 +85,12 @@ JsonResultResponse<Allele> getAllelesPerSpecies(
8485
@Operation(summary = "Retrieve all phenotypes of a given allele")
8586
@APIResponses(value = { @APIResponse(responseCode = "404", description = "Missing phenotypes", content = @Content(mediaType = "text/plain")),
8687
@APIResponse(responseCode = "200", description = "Phenotypes for a given Allele.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Null.class))) })
87-
@JsonView(value = { View.PhenotypeAPI.class })
88-
JsonResultResponse<PhenotypeAnnotation> getPhenotypePerAllele(@Parameter(in = ParameterIn.PATH, name = "id", description = "Search for Phenotypes for a given Allele by ID", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id,
89-
@Parameter(in = ParameterIn.QUERY, name = "limit", description = "Number of rows returned", schema = @Schema(type = SchemaType.INTEGER)) @DefaultValue("20") @QueryParam("limit") Integer limit,
90-
@Parameter(in = ParameterIn.QUERY, name = "page", description = "Page number", schema = @Schema(type = SchemaType.INTEGER)) @DefaultValue("1") @QueryParam("page") Integer page,
91-
@Parameter(in = ParameterIn.QUERY, name = "filter.termName", description = "termName annotation") @QueryParam("filter.termName") String phenotype, @Parameter(in = ParameterIn.QUERY, name = "filter.source", description = "Source") @QueryParam("filter.source") String source,
92-
@Parameter(in = ParameterIn.QUERY, name = "filter.reference", description = "Reference number: PUBMED or a Pub ID from the MOD") @QueryParam("filter.reference") String reference,
93-
@Parameter(in = ParameterIn.QUERY, name = "sortBy", description = "Field name by which to sort", schema = @Schema(type = SchemaType.STRING)) @DefaultValue("symbol") @QueryParam("sortBy") String sortBy
88+
JsonResultResponse<AllelePhenotypeAnnotationDocument> getPhenotypePerAllele(@Parameter(in = ParameterIn.PATH, name = "id", description = "Search for Phenotypes for a given Allele by ID", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id,
89+
@Parameter(in = ParameterIn.QUERY, name = "limit", description = "Number of rows returned", schema = @Schema(type = SchemaType.INTEGER)) @DefaultValue("20") @QueryParam("limit") Integer limit,
90+
@Parameter(in = ParameterIn.QUERY, name = "page", description = "Page number", schema = @Schema(type = SchemaType.INTEGER)) @DefaultValue("1") @QueryParam("page") Integer page,
91+
@Parameter(in = ParameterIn.QUERY, name = "filter.termName", description = "termName annotation") @QueryParam("filter.termName") String phenotype, @Parameter(in = ParameterIn.QUERY, name = "filter.source", description = "Source") @QueryParam("filter.source") String source,
92+
@Parameter(in = ParameterIn.QUERY, name = "filter.reference", description = "Reference number: PUBMED or a Pub ID from the MOD") @QueryParam("filter.reference") String reference,
93+
@Parameter(in = ParameterIn.QUERY, name = "sortBy", description = "Field name by which to sort", schema = @Schema(type = SchemaType.STRING)) @DefaultValue("symbol") @QueryParam("sortBy") String sortBy
9494

9595
);
9696

agr_api/src/main/java/org/alliancegenome/api/rest/interfaces/GeneRESTInterface.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.alliancegenome.api.entity.AlleleVariantSequence;
99
import org.alliancegenome.api.entity.DiseaseRibbonSummary;
1010
import org.alliancegenome.api.entity.GeneToGeneParalogyDocument;
11+
import org.alliancegenome.api.entity.GenePhenotypeAnnotationDocument;
1112
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
1213
import org.alliancegenome.neo4j.entity.DiseaseAnnotation;
1314
import org.alliancegenome.neo4j.entity.DiseaseSummary;
@@ -243,7 +244,6 @@ Response getAllelesPerGeneDownload(
243244

244245
@GET
245246
@Path("/{id}/phenotypes")
246-
@JsonView(value = {View.PhenotypeAPI.class})
247247
@Operation(summary = "Retrieve phenotype term name annotations for a given gene")
248248
@APIResponses(
249249
value = {
@@ -255,8 +255,8 @@ Response getAllelesPerGeneDownload(
255255
responseCode = "200",
256256
description = "Phenotype annotations for a gene.",
257257
content = @Content(mediaType = "application/json",
258-
schema = @Schema(implementation = Null.class)))})
259-
JsonResultResponse<PhenotypeAnnotation> getPhenotypeAnnotations(
258+
schema = @Schema(implementation = PhenotypeAnnotation.class)))})
259+
JsonResultResponse<GenePhenotypeAnnotationDocument> getPhenotypeAnnotations(
260260
@Parameter(in = ParameterIn.PATH, name = "id", description = "Gene by ID: e.g. ZFIN:ZDB-GENE-990415-8", required = true, schema = @Schema(type = SchemaType.STRING))
261261
@PathParam("id") String id,
262262
@Parameter(in = ParameterIn.QUERY, name = "limit", description = "Number of rows returned", schema = @Schema(type = SchemaType.INTEGER))

0 commit comments

Comments
 (0)