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 @@ -6,9 +6,11 @@
import org.alliancegenome.core.config.ConfigHelper;
import org.alliancegenome.core.variant.converters.AlleleSearchResultConverter;
import org.alliancegenome.core.variant.converters.AlleleSequenceSummaryConverter;
import org.alliancegenome.core.variant.converters.AlleleToVariantSummaryConverter;
import org.alliancegenome.curation_api.interfaces.document.AlleleDocumentInterface;
import org.alliancegenome.curation_api.model.document.es.AlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.SequenceSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.VariantSummaryDocument;
import org.alliancegenome.es.model.AlleleSearchResultDocument;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.curation_api.view.CurationView;
Expand All @@ -30,6 +32,7 @@ public class AlleleSummaryCurationIndexer extends Indexer {
private final AlleleDocumentInterface alleleApi = RestProxyFactory.createProxy(AlleleDocumentInterface.class, ConfigHelper.getCurationApiUrl(), RestConfig.config);
private final AlleleSequenceSummaryConverter sequenceSummaryConverter = new AlleleSequenceSummaryConverter();
private final AlleleSearchResultConverter alleleSearchResultConverter = new AlleleSearchResultConverter();
private final AlleleToVariantSummaryConverter variantSummaryConverter = new AlleleToVariantSummaryConverter();

private List<List<Long>> idBatches;

Expand Down Expand Up @@ -79,6 +82,7 @@ protected void startSingleThread(LinkedBlockingDeque<String> queue) {
// Convert to derived documents first (consumes transport-only fields)
List<SequenceSummaryDocument> sequenceDocs = sequenceSummaryConverter.convert(response.getResults());
List<AlleleSearchResultDocument> searchDocs = alleleSearchResultConverter.convert(response.getResults());
List<VariantSummaryDocument> variantDocs = variantSummaryConverter.convert(response.getResults());
Comment thread
cmpich marked this conversation as resolved.

// Strip fields only needed by derived documents before indexing to ES
response.getResults().forEach(AlleleSummaryDocument::removeTransportFields);
Expand All @@ -87,6 +91,7 @@ protected void startSingleThread(LinkedBlockingDeque<String> queue) {
indexDocuments(response.getResults());
indexDocuments(sequenceDocs, CurationView.SequenceSummaryDocument.class);
indexDocuments(searchDocs);
indexDocuments(variantDocs);
} catch (Exception e) {
log.error("Error while indexing...", e);
ExceptionCatcher.report(e);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.alliancegenome.core.variant.converters;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import org.alliancegenome.curation_api.model.document.es.AlleleSummaryDocument;
import org.alliancegenome.curation_api.model.document.es.VariantSummaryDocument;
import org.alliancegenome.curation_api.model.entities.Variant;
import org.apache.commons.collections4.CollectionUtils;

/**
* Converts AlleleSummaryDocument objects into VariantSummaryDocument objects
* for LTP (Low Throughput) variants that come through the curation API allele endpoint.
* Produces one variant_summary document per allele x variant combination.
*/
public class AlleleToVariantSummaryConverter {

public List<VariantSummaryDocument> convert(List<AlleleSummaryDocument> alleleDocs) {
List<VariantSummaryDocument> result = new ArrayList<>();

for (AlleleSummaryDocument doc : alleleDocs) {
if (CollectionUtils.isEmpty(doc.getVariantList())) {
continue;
}

for (Variant variant : doc.getVariantList()) {
if (CollectionUtils.isEmpty(variant.getCuratedVariantGenomicLocations())) {
continue;
}

VariantSummaryDocument vsd = new VariantSummaryDocument();
vsd.setAllele(doc.getAllele());
vsd.setSymbol(doc.getSymbol());
vsd.setVariantList(List.of(variant));
vsd.setHasPhenotype(doc.getHasPhenotype() != null && doc.getHasPhenotype());
vsd.setHasDisease(doc.getHasDisease() != null && doc.getHasDisease());

if (doc.getGeneIds() != null) {
vsd.setGeneIds(new HashSet<>(doc.getGeneIds()));
}

result.add(vsd);
}
}

return result;
}
}
Loading