Skip to content

Commit a3e05b1

Browse files
authored
SCRUM-5881 use severity rank for sorting molecular consequences (#1550)
1 parent 3370bfa commit a3e05b1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

agr_java_core/src/main/java/org/alliancegenome/core/variant/converters/VariantSummaryConverter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.net.URLDecoder;
44
import java.nio.charset.StandardCharsets;
55
import java.util.ArrayList;
6+
import java.util.Comparator;
67
import java.util.HashSet;
78
import java.util.List;
89
import java.util.Map;
@@ -45,6 +46,7 @@ public class VariantSummaryConverter {
4546
// Header index positions (initialized once per header)
4647
private String[] header;
4748
private GeneDocumentCache geneCache;
49+
private Map<String, Integer> severityRanking;
4850
private Map<String, SOTerm> soTermCache = new ConcurrentHashMap<>();
4951
private Map<String, VocabularyTerm> vocabularyTermCache = new ConcurrentHashMap<>();
5052

@@ -71,9 +73,10 @@ public class VariantSummaryConverter {
7173
private int proteinPosIdx = -1;
7274
private int hgvsgIdx = -1;
7375

74-
public VariantSummaryConverter(String[] header, GeneDocumentCache geneCache) {
76+
public VariantSummaryConverter(String[] header, GeneDocumentCache geneCache, Map<String, Integer> severityRanking) {
7577
this.header = header;
7678
this.geneCache = geneCache;
79+
this.severityRanking = severityRanking;
7780
initializeHeaderIndices();
7881
}
7982

@@ -347,6 +350,9 @@ private Pair<List<PredictedVariantConsequence>, HashSet<String>> getConsequences
347350
ampIdx = csqField.indexOf('&', start);
348351
} while (ampIdx >= 0);
349352
soTerms.add(getSOTerm(csqField.substring(start)));
353+
soTerms.sort(Comparator.comparingInt(
354+
term -> term.getSeverityOrder() != null ? term.getSeverityOrder() : Integer.MAX_VALUE
355+
));
350356
consequence.setVepConsequences(soTerms);
351357
}
352358
}
@@ -559,6 +565,9 @@ private SOTerm getSOTerm(String name) {
559565
return soTermCache.computeIfAbsent(name, k -> {
560566
SOTerm term = new SOTerm();
561567
term.setName(k);
568+
if (severityRanking != null) {
569+
term.setSeverityOrder(severityRanking.get(k));
570+
}
562571
return term;
563572
});
564573
}

agr_variant_indexer/src/main/java/org/alliancegenome/indexer/variant/es/managers/SourceDocumentCreation.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.ArrayList;
55
import java.util.HashSet;
66
import java.util.List;
7+
import java.util.Map;
78
import java.util.concurrent.LinkedBlockingDeque;
89
import java.util.concurrent.TimeUnit;
910

@@ -38,6 +39,7 @@ public class SourceDocumentCreation extends Thread {
3839

3940
private final GeneDocumentCache geneCache;
4041
private final HashSet<String> variantsCache;
42+
private final Map<String, Integer> severityRanking;
4143
private String downloadPath;
4244
private DownloadSource source;
4345
private SpeciesType speciesType;
@@ -60,11 +62,12 @@ public class SourceDocumentCreation extends Thread {
6062

6163
private String messageHeader = "";
6264

63-
public SourceDocumentCreation(String downloadPath, DownloadSource source, GeneDocumentCache geneCache, HashSet<String> variantsCache) {
65+
public SourceDocumentCreation(String downloadPath, DownloadSource source, GeneDocumentCache geneCache, HashSet<String> variantsCache, Map<String, Integer> severityRanking) {
6466
this.downloadPath = downloadPath;
6567
this.source = source;
6668
this.geneCache = geneCache;
6769
this.variantsCache = variantsCache;
70+
this.severityRanking = severityRanking;
6871
speciesType = SpeciesType.getTypeByID(source.getTaxonId());
6972
messageHeader = speciesType.getModName() + " ";
7073
int vcQueueSize = source.getVcQueueSize() != null ? source.getVcQueueSize() : VariantConfigHelper.getSourceDocumentCreatorVCQueueSize();
@@ -198,7 +201,7 @@ public void run() {
198201
VCFInfoHeaderLine fileHeader = reader.getFileHeader().getInfoHeaderLine("CSQ");
199202
header = fileHeader.getDescription().split("Format: ")[1].split("\\|");
200203
// All files for a Mod have the same header so we only need one of them
201-
variantSummaryConverter = new VariantSummaryConverter(header, geneCache);
204+
variantSummaryConverter = new VariantSummaryConverter(header, geneCache, severityRanking);
202205
sequenceSummaryConverter = new SequenceSummaryConverter();
203206
variantSearchResultConverter = new VariantSearchResultConverter();
204207
try {

agr_variant_indexer/src/main/java/org/alliancegenome/indexer/variant/es/managers/SourceDocumentCreationManager.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import java.util.ArrayList;
55
import java.util.HashSet;
66
import java.util.List;
7+
import java.util.Map;
78

89
import org.alliancegenome.core.config.ConfigHelper;
910
import org.alliancegenome.core.filedownload.model.DownloadFileSet;
1011
import org.alliancegenome.core.filedownload.model.DownloadSource;
12+
import org.alliancegenome.curation_api.interfaces.crud.ontology.SoTermCrudInterface;
1113
import org.alliancegenome.curation_api.interfaces.document.VariantDocumentInterface;
1214
import org.alliancegenome.es.index.site.cache.GeneDocumentCache;
1315
import org.alliancegenome.es.rest.RestConfig;
@@ -24,6 +26,7 @@ public class SourceDocumentCreationManager extends Thread {
2426
private DownloadFileSet downloadSet;
2527

2628
private final VariantDocumentInterface variantApi = RestProxyFactory.createProxy(VariantDocumentInterface.class, ConfigHelper.getCurationApiUrl(), RestConfig.config);
29+
private final SoTermCrudInterface soTermApi = RestProxyFactory.createProxy(SoTermCrudInterface.class, ConfigHelper.getCurationApiUrl(), RestConfig.config);
2730

2831
public SourceDocumentCreationManager(DownloadFileSet downloadSet) {
2932
this.downloadSet = downloadSet;
@@ -56,10 +59,13 @@ public void run() {
5659
e.printStackTrace();
5760
}
5861

62+
log.info("Fetching SO term severity ranking from curation API...");
63+
Map<String, Integer> severityRanking = soTermApi.getSeverityRanking();
64+
log.info("Fetched severity ranking for {} SO terms", severityRanking.size());
5965
List<SourceDocumentCreation> creators = new ArrayList<>();
6066
for (DownloadSource source : downloadSet.getDownloadFileSources()) {
6167
if (source.getActive()) {
62-
SourceDocumentCreation creator = new SourceDocumentCreation(downloadSet.getDownloadPath(), source, geneCache, variantsCache);
68+
SourceDocumentCreation creator = new SourceDocumentCreation(downloadSet.getDownloadPath(), source, geneCache, variantsCache, severityRanking);
6369
creator.start();
6470
creators.add(creator);
6571
}

0 commit comments

Comments
 (0)