Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
PT-497: Add the possibility to reindex OMIM from the administration
Browse files Browse the repository at this point in the history
Protect against NPE when the OMIM-Phenotype mapping uses a more recent version of HPO than what's currently indexed
  • Loading branch information
sdumitriu committed Oct 6, 2015
1 parent 0ba45d9 commit 88cb93d
Showing 1 changed file with 13 additions and 8 deletions.
Expand Up @@ -123,7 +123,7 @@ public OmimSourceParser(Vocabulary hpo, String sourceURL)
loadSymptoms(true);
loadSymptoms(false);
loadGeneReviews();
} catch (CompressorException | IOException ex) {
} catch (NullPointerException | CompressorException | IOException ex) {
this.logger.error("Failed to prepare the OMIM index: {}", ex.getMessage(), ex);
}
}
Expand Down Expand Up @@ -206,28 +206,33 @@ private void loadSymptoms(boolean positive)
for (CSVRecord row : CSVFormat.TDF.parse(in)) {
if ("OMIM".equals(row.get(0))) {
omimId = row.get(1);
if (previousOmimId != null && !previousOmimId.equals(omimId)) {
addAncestors(previousOmimId, ancestors, positive);
}
addAncestors(previousOmimId, omimId, ancestors, positive);
previousOmimId = omimId;
SolrInputDocument term = this.data.get(omimId);
if (term != null) {
term.addField(positive ? "actual_symptom" : "actual_not_symptom", row.get(4));
}
for (VocabularyTerm vterm : this.hpo.getTerm(row.get(4)).getAncestorsAndSelf()) {
ancestors.add(vterm.getId());
VocabularyTerm vterm = this.hpo.getTerm(row.get(4));
if (vterm != null) {
for (VocabularyTerm ancestor : vterm.getAncestorsAndSelf()) {
ancestors.add(ancestor.getId());
}
}
}
}
addAncestors(omimId, null, ancestors, positive);
} catch (IOException ex) {
this.logger.error("Failed to load OMIM-HPO links: {}", ex.getMessage(), ex);
}
}

private void addAncestors(String omimId, Set<String> ancestors, boolean positive)
private void addAncestors(String previousOmimId, String newOmimId, Set<String> ancestors, boolean positive)
{
if (previousOmimId == null || previousOmimId.equals(newOmimId)) {
return;
}
final String symptomField = "symptom";
SolrInputDocument term = this.data.get(omimId);
SolrInputDocument term = this.data.get(previousOmimId);
if (!positive) {
ancestors.removeAll(term.getFieldValues(symptomField));
term.addField("not_symptom", ancestors);
Expand Down

0 comments on commit 88cb93d

Please sign in to comment.