/** * Gets the {@link VocabularyTerm} associated with the provided {@code categoryId}. If {@code categoryId} refers to * a non-standard category, will set "phenotypic abnormality" ("HP:0000118") as the default. * * @param categoryId the ID of a category of interest * @return a {@link VocabularyTerm} associated with the provided {@code categoryId} or {@link VocabularyTerm} for * "HP:0000118" */ private VocabularyTerm getCategoryTerm(final String categoryId) { final VocabularyTerm categoryTerm = this.ontologyService.getTerm(categoryId); return categoryTerm != null ? categoryTerm : this.ontologyService.getTerm("HP:0000118"); }
/** * Gets the {@link VocabularyTerm} associated with the provided {@code categoryId}. If {@code categoryId} refers to * a non-standard category, will set "phenotypic abnormality" ("HP:0000118") as the default. * * @param categoryId the ID of a category of interest * @return a {@link VocabularyTerm} associated with the provided {@code categoryId} or {@link VocabularyTerm} for * "HP:0000001" */ private VocabularyTerm getCategoryTerm(final String categoryId) { final VocabularyTerm categoryTerm = this.ontologyService.getTerm(categoryId); return categoryTerm != null ? categoryTerm : this.ontologyService.getTerm(ROOT_ID); }
private VocabularyTerm getTerm(String gene) { // lazy-initialize HGNC if (this.hgnc == null) { this.hgnc = getHGNCVocabulary(); if (this.hgnc == null) { return null; } } return this.hgnc.getTerm(gene); }
private VocabularyTerm getTerm(String gene) { // lazy-initialize HGNC if (this.hgnc == null) { this.hgnc = getHGNCVocabulary(); if (this.hgnc == null) { return null; } } return this.hgnc.getTerm(gene); }
private String getLabelFromOntology(String id) { if (!id.startsWith("HP:")) { return id; } VocabularyTerm phObj = this.ontologyService.getTerm(id); if (phObj != null) { return phObj.getTranslatedName(); } return id; }
private VocabularyTerm getTerm(String gene) { // lazy-initialize HGNC if (this.hgnc == null) { this.hgnc = getHGNCVocabulary(); if (this.hgnc == null) { return null; } } return this.hgnc.getTerm(gene); }
@Override public VocabularyTerm resolveTerm(String termId) { Vocabulary vocabulary = getVocabularyForTerm(termId); if (vocabulary != null) { return vocabulary.getTerm(termId); } return null; }
private VocabularyTerm getTerm(String gene) { // lazy-initialize HGNC if (this.hgnc == null) { this.hgnc = getHGNCVocabulary(); if (this.hgnc == null) { return null; } } return this.hgnc.getTerm(gene); }
private String getLabelFromOntology(String id) { if (!id.startsWith("HP:")) { return id; } VocabularyTerm phObj = this.ontologyService.getTerm(id); if (phObj != null) { return phObj.getTranslatedName(); } return id; }
/** * Gets EnsemblID corresponding to the HGNC symbol. * * @param geneSymbol the string representation of a gene symbol (e.g. NOD2). * @return the string representation of the corresponding Ensembl ID. */ private String getEnsemblId(String geneSymbol) { final VocabularyTerm term = this.hgnc.getTerm(geneSymbol); @SuppressWarnings("unchecked") final List<String> ensemblIdList = term != null ? (List<String>) term.get("ensembl_gene_id") : null; final String ensemblId = ensemblIdList != null && !ensemblIdList.isEmpty() ? ensemblIdList.get(0) : null; // Retain information as is if we can't find Ensembl ID. return ensemblId != null ? ensemblId : geneSymbol; } }
/** * Gets EnsemblID corresponding to the HGNC symbol. * * @param geneSymbol the string representation of a gene symbol (e.g. NOD2). * @return the string representation of the corresponding Ensembl ID. */ private String getEnsemblId(String geneSymbol) { final VocabularyTerm term = this.hgnc.getTerm(geneSymbol); @SuppressWarnings("unchecked") final List<String> ensemblIdList = term != null ? (List<String>) term.get("ensembl_gene_id") : null; final String ensemblId = ensemblIdList != null && !ensemblIdList.isEmpty() ? ensemblIdList.get(0) : null; // Retain information as is if we can't find Ensembl ID. return ensemblId != null ? ensemblId : geneSymbol; } }
/** * Gets EnsemblID corresponding to the HGNC symbol. * * @param geneSymbol the string representation of a gene symbol (e.g. NOD2). * @return the string representation of the corresponding Ensembl ID. */ private String getEnsemblId(final String geneSymbol) { final VocabularyTerm term = this.hgnc.getTerm(geneSymbol); @SuppressWarnings("unchecked") final List<String> ensemblIdList = term != null ? (List<String>) term.get("ensembl_gene_id") : null; final String ensemblId = ensemblIdList != null && !ensemblIdList.isEmpty() ? ensemblIdList.get(0) : null; // Retain information as is if we can't find Ensembl ID. return ensemblId != null ? ensemblId : geneSymbol; } }
private Set<String> getGeneSymbols(Set<String> set, String status) { Set<String> result = new HashSet<>(); Vocabulary hgnc = VOCABULARY_MANAGER.getVocabulary("HGNC"); for (String geneEnsemblId : set) { VocabularyTerm term = hgnc.getTerm(geneEnsemblId); String symbol = (term != null) ? (String) term.get("symbol") : null; symbol = StringUtils.isBlank(symbol) ? geneEnsemblId : symbol; symbol = StringUtils.isBlank(status) ? symbol : symbol + " (" + status + ")"; result.add(symbol); } return result; }
/** * Gets EnsemblID corresponding to the HGNC symbol. * * @param geneSymbol the string representation of a gene symbol (e.g. NOD2). * @return the string representation of the corresponding Ensembl ID. */ private String getEnsemblId(final String geneSymbol) { final VocabularyTerm term = this.hgnc.getTerm(geneSymbol); @SuppressWarnings("unchecked") final List<String> ensemblIdList = term != null ? (List<String>) term.get("ensembl_gene_id") : null; final String ensemblId = ensemblIdList != null && !ensemblIdList.isEmpty() ? ensemblIdList.get(0) : null; // Retain information as is if we can't find Ensembl ID. return ensemblId != null ? ensemblId : geneSymbol; } }
private static JSONObject exchangeDisorders(JSONObject pedigreePatient, JSONObject phenotipsPatientJSON, Vocabulary omimService, Logger logger) { String disordersKey = "disorders"; JSONArray internalTerms = new JSONArray(); JSONArray externalTerms = pedigreePatient.optJSONArray(disordersKey); if (externalTerms != null) { for (Object termIdObj : externalTerms) { try { VocabularyTerm term = omimService.getTerm(termIdObj.toString()); if (term != null) { internalTerms.put(term.toJSON()); } } catch (Exception ex) { logger.error("Could not convert disorder {} from pedigree JSON to patient JSON", termIdObj); } } } phenotipsPatientJSON.put(disordersKey, internalTerms); return phenotipsPatientJSON; }
@SuppressWarnings("unchecked") private List<String> getCategoriesFromOntology(String value) { if (!value.startsWith("HP:")) { return Collections.emptyList(); } VocabularyTerm termObj = this.ontologyService.getTerm(value); if (termObj != null && termObj.get(INDEXED_CATEGORY_KEY) != null && List.class.isAssignableFrom(termObj.get(INDEXED_CATEGORY_KEY).getClass())) { return (List<String>) termObj.get(INDEXED_CATEGORY_KEY); } return new LinkedList<>(); }
@SuppressWarnings("unchecked") private List<String> getCategoriesFromOntology(String value) { if (!value.startsWith("HP:")) { return Collections.emptyList(); } VocabularyTerm termObj = this.ontologyService.getTerm(value); if (termObj != null && termObj.get(INDEXED_CATEGORY_KEY) != null && List.class.isAssignableFrom(termObj.get(INDEXED_CATEGORY_KEY).getClass())) { return (List<String>) termObj.get(INDEXED_CATEGORY_KEY); } return new LinkedList<>(); }
/** * 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; } }
@Override public Response getTerm(String vocabularyId, String termId) { if (StringUtils.isEmpty(vocabularyId) || StringUtils.isEmpty(termId)) { return Response.status(Response.Status.BAD_REQUEST).build(); } Vocabulary vocabulary = this.vm.getVocabulary(vocabularyId); if (vocabulary == null) { return Response.status(Response.Status.NOT_FOUND).build(); } VocabularyTerm term = vocabulary.getTerm(termId); if (term == null) { return Response.status(Response.Status.NOT_FOUND).build(); } JSONObject rep = term.toJSON(); rep.put("links", this.autolinker.get().forResource(getClass(), this.uriInfo).build()); return Response.ok(rep, MediaType.APPLICATION_JSON_TYPE).build(); } }
/** * Given an HPO id, finds categories to which the id belongs to. * * @param value must start with "HP:" * @return a list of categories as HPO ids, excluding the passed in id, or an empty list if the categories could not * be determined */ @SuppressWarnings("unchecked") private List<String> getCategoriesFromOntology(String value) { if (!value.startsWith("HP:")) { return Collections.emptyList(); } VocabularyTerm termObj = this.ontologyService.getTerm(value); if (termObj != null && termObj.get(PropertyDisplayer.INDEXED_CATEGORY_KEY) != null && List.class.isAssignableFrom(termObj.get(PropertyDisplayer.INDEXED_CATEGORY_KEY).getClass())) { return (List<String>) termObj.get(PropertyDisplayer.INDEXED_CATEGORY_KEY); } return new LinkedList<>(); }