Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import org.alliancegenome.core.exceptions.RestErrorMessage;
import org.alliancegenome.core.translators.tdf.AlleleToTdfTranslator;
import org.alliancegenome.curation_api.model.document.es.AlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.TransgenicAlleleDocument;
import org.alliancegenome.api.entity.TransgenicAlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.VariantSummaryDocument;
import org.alliancegenome.es.model.query.FieldFilter;
import org.alliancegenome.es.model.query.Pagination;
Expand Down Expand Up @@ -67,8 +67,8 @@ public AlleleSummaryDocument getAllele(String id) {
}

@Override
public TransgenicAlleleDocument getAlleleConstructs(String alleleId) {
JsonResultResponse<TransgenicAlleleDocument> transgenicAlleles = alleleEsService.getTransgenicAlleles(alleleId);
public TransgenicAlleleSummaryDocument getAlleleConstructs(String alleleId) {
JsonResultResponse<TransgenicAlleleSummaryDocument> transgenicAlleles = alleleEsService.getTransgenicAlleles(alleleId);
if (transgenicAlleles == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.alliancegenome.api.entity.AllelePhenotypeAnnotationDocument;
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
import org.alliancegenome.curation_api.model.document.es.AlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.TransgenicAlleleDocument;
import org.alliancegenome.api.entity.TransgenicAlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.VariantSummaryDocument;
import org.alliancegenome.neo4j.view.PublicView;
import org.apache.commons.lang3.ObjectUtils.Null;
Expand Down Expand Up @@ -48,7 +48,7 @@ public interface AlleleRESTInterface {
@Operation(description = "Searches for transgenic alleles", summary = "Transgenic Alleles")
@APIResponses(value = {@APIResponse(responseCode = "404", description = "Missing transgenic alleles", content = @Content(mediaType = "text/plain")),
@APIResponse(responseCode = "200", description = "Search for alleles.", content = @Content(mediaType = "application/json", schema = @Schema(implementation = Null.class)))})
TransgenicAlleleDocument getAlleleConstructs(@Parameter(in = ParameterIn.PATH, name = "id", description = "Search for constructs for a given Allele by ID", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id);
TransgenicAlleleSummaryDocument getAlleleConstructs(@Parameter(in = ParameterIn.PATH, name = "id", description = "Search for constructs for a given Allele by ID", required = true, schema = @Schema(type = SchemaType.STRING)) @PathParam("id") String id);

@GET
@Path("/{id}/variants")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.alliancegenome.cache.repository.helper.JsonResultResponse;
import org.alliancegenome.curation_api.model.document.es.AlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.ESDocument;
import org.alliancegenome.curation_api.model.document.es.TransgenicAlleleDocument;
import org.alliancegenome.api.entity.TransgenicAlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.VariantSummaryDocument;
import org.alliancegenome.es.model.query.Pagination;
import org.elasticsearch.action.search.SearchResponse;
Expand Down Expand Up @@ -64,23 +64,23 @@ public class AlleleESService extends ESService {
put(null, defaultSortMap);
}};

public JsonResultResponse<TransgenicAlleleDocument> getTransgenicAlleles(String alleleId) {
public JsonResultResponse<TransgenicAlleleSummaryDocument> getTransgenicAlleles(String alleleId) {
BoolQueryBuilder bool = boolQuery();
BoolQueryBuilder bool2 = boolQuery();
bool.must(bool2);
// ToDo: Change this class such that the category is public
// TransgenicAlleleDocument.category
// TransgenicAlleleSummaryDocument.category
bool.filter(new TermQueryBuilder("category", "transgenic_allele_summary"));
bool2.should(new MatchQueryBuilder("allele.primaryExternalId.keyword", alleleId));

JsonResultResponse<TransgenicAlleleDocument> ret = new JsonResultResponse<>();
JsonResultResponse<TransgenicAlleleSummaryDocument> ret = new JsonResultResponse<>();

SearchResponse searchResponse = getSearchResponse(bool, new Pagination(), null, false);
ret.setTotal((int) searchResponse.getHits().getTotalHits().value);
List<TransgenicAlleleDocument> list = new ArrayList<>();
List<TransgenicAlleleSummaryDocument> list = new ArrayList<>();
Arrays.stream(searchResponse.getHits().getHits()).forEach(searchHit -> {
try {
TransgenicAlleleDocument object = mapper.readValue(searchHit.getSourceAsString(), TransgenicAlleleDocument.class);
TransgenicAlleleSummaryDocument object = mapper.readValue(searchHit.getSourceAsString(), TransgenicAlleleSummaryDocument.class);
list.add(object);
} catch (Exception e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,15 @@ public List<VariantSummaryDocument> convertContextToDocument(VariantContext ctx,
allele.setTaxon(taxon);
// If we want to show

// Sort PVCs by most severe consequence
consequences.sort(Comparator.comparingInt(pvc -> {
if (pvc.getVepConsequences() == null || pvc.getVepConsequences().isEmpty()) {
return Integer.MAX_VALUE;
}
return pvc.getVepConsequences().stream()
.mapToInt(c -> c.getSeverityOrder() != null ? c.getSeverityOrder() : Integer.MAX_VALUE)
.min().orElse(Integer.MAX_VALUE);
}));
cvgla.setPredictedVariantConsequences(consequences);
// Create the document for each consequence (full flattening)
VariantSummaryDocument doc = new VariantSummaryDocument();
Expand Down
Loading