/** * Get the HPO IDs of the specified phenotype and all its ancestors. * * @param id the HPO identifier to search for, in the {@code HP:1234567} format * @return the full set of ancestors-or-self IDs, or an empty set if the requested ID was not found in the index */ public Set<String> getAllAncestorsAndSelfIDs(final String id) { Set<String> parents = new HashSet<>(); VocabularyTerm crt = this.hpo.getTerm(id); Set<VocabularyTerm> ancenstors = crt.getAncestorsAndSelf(); for (VocabularyTerm term : ancenstors) { parents.add(term.getId()); } return parents; } }
/** * Fills in an extended phenotype field using the base phenotype field. * * @param baseFieldName the name of the field holding the basic list of phenotypes * @param extendedFieldName the name of the target field that will hold the extended list of phenotypes * @param patientRecordObj the object to update */ private void updateField(String baseFieldName, String extendedFieldName, BaseObject patientRecordObj) { @SuppressWarnings("unchecked") List<String> phenotypes = patientRecordObj.getListValue(baseFieldName); Set<String> extendedPhenotypes = new TreeSet<>(); Set<String> sortedPhenotypes = new TreeSet<>(); for (String phenotype : phenotypes) { sortedPhenotypes.add(phenotype); VocabularyTerm phenotypeTerm = this.vocabularyManager.resolveTerm(phenotype); if (phenotypeTerm != null) { for (VocabularyTerm term : phenotypeTerm.getAncestorsAndSelf()) { extendedPhenotypes.add(term.getId()); } } else { extendedPhenotypes.add(phenotype); } } patientRecordObj.setDBStringListValue(extendedFieldName, new ArrayList<>(extendedPhenotypes)); patientRecordObj.setDBStringListValue(baseFieldName, new ArrayList<>(sortedPhenotypes)); } }
/** * Fills in an extended phenotype field using the base phenotype field. * * @param baseFieldName the name of the field holding the basic list of phenotypes * @param extendedFieldName the name of the target field that will hold the extended list of phenotypes * @param patientRecordObj the object to update */ private void updateField(String baseFieldName, String extendedFieldName, BaseObject patientRecordObj) { @SuppressWarnings("unchecked") List<String> phenotypes = patientRecordObj.getListValue(baseFieldName); Set<String> extendedPhenotypes = new TreeSet<>(); Set<String> sortedPhenotypes = new TreeSet<>(); for (String phenotype : phenotypes) { sortedPhenotypes.add(phenotype); VocabularyTerm phenotypeTerm = this.vocabularyManager.resolveTerm(phenotype); if (phenotypeTerm != null) { for (VocabularyTerm term : phenotypeTerm.getAncestorsAndSelf()) { extendedPhenotypes.add(term.getId()); } } else { extendedPhenotypes.add(phenotype); } } patientRecordObj.setDBStringListValue(extendedFieldName, new ArrayList<>(extendedPhenotypes)); patientRecordObj.setDBStringListValue(baseFieldName, new ArrayList<>(sortedPhenotypes)); } }
VocabularyTerm newTerm = R54595PhenoTips1151DataMigration.this.vocabularies.resolveTerm(translation.getValue()); for (VocabularyTerm ancestor : newTerm.getAncestorsAndSelf()) { if (!extendedValues.contains(ancestor.getId())) { extendedValues.add(ancestor.getId());
VocabularyTerm newTerm = R54595PhenoTips1151DataMigration.this.vocabularies.resolveTerm(translation.getValue()); for (VocabularyTerm ancestor : newTerm.getAncestorsAndSelf()) { if (!extendedValues.contains(ancestor.getId())) { extendedValues.add(ancestor.getId());
for (VocabularyTerm ancestor : term.getAncestorsAndSelf()) { input.addField(ancestorFieldName, ancestor.getId());