private static String observedStatusToJSONString(Feature feature) { if (feature.isPresent()) { return ApiConfiguration.JSON_FEATURE_OBSERVED_YES; } return ApiConfiguration.JSON_FEATURE_OBSERVED_NO; }
/** * Simple filter, which returns a subset of features of the passed in "features" parameter that have the status of * "status" parameter, or an empty list if the global setting disallows features with the status of { @param * status}. */ private List<Feature> filterFeaturesByPresentStatus(Set<? extends Feature> features, Boolean status) { List<Feature> filteredFeatures = new LinkedList<>(); for (Feature feature : features) { if (feature.isPresent() == status) { filteredFeatures.add(0, feature); } } return filteredFeatures; }
/** * Simple filter, which returns a subset of features of the passed in "features" parameter that have the status of * "status" parameter, or an empty list if the global setting disallows features with the status of { @param * status}. */ private List<Feature> filterFeaturesByPresentStatus(Set<? extends Feature> features, Boolean status) { List<Feature> filteredFeatures = new LinkedList<>(); boolean include = status ? this.positive : this.negative; if (include) { for (Feature feature : features) { if (feature.isPresent() == status) { filteredFeatures.add(0, feature); } } } return filteredFeatures; }
@Override public boolean isPresent() { return this.access.isOpenAccess() && this.match != null ? this.match.isPresent() : true; }
/** * Gets the type from the provided {@code feature}. * * @param feature the {@link Feature} object of interest * @return type as string */ private String getFeatureType(@Nonnull final Feature feature) { return feature.isPresent() ? feature.getType() : this.addNegativePrefix(feature); }
private String getCacheKey(Patient patient) { StringBuilder result = new StringBuilder(); for (Feature f : patient.getFeatures()) { if (StringUtils.isNotEmpty(f.getId())) { if (!f.isPresent()) { result.append('-'); } result.append(f.getId()); } } return result.toString(); }
private String getCacheKey(Patient patient) { StringBuilder result = new StringBuilder(); for (Feature f : patient.getFeatures()) { if (StringUtils.isNotEmpty(f.getId())) { if (!f.isPresent()) { result.append('-'); } result.append(f.getId()); } } return result.toString(); }
private void readPhenotypes(Patient patient) { List<Map<String, String>> predefined = new LinkedList<>(); List<Map<String, String>> freeText = new LinkedList<>(); Set<? extends Feature> features = patient.getFeatures(); for (Feature feature : features) { Map<String, String> item = new HashMap<>(); item.put(NAME_FIELD, feature.getName()); item.put(OBSERVED_FIELD, feature.isPresent() ? OBSERVED : NOT_OBSERVED); String id = feature.getId(); if (StringUtils.isEmpty(id)) { freeText.add(item); } else { item.put(ID_FIELD, id); predefined.add(item); } } Collections.sort(predefined, PHENOTYPES_COMPARATOR); Collections.sort(freeText, PHENOTYPES_COMPARATOR); this.phenotypes = new HashMap<>(); this.phenotypes.put(PREDEFINED, predefined); this.phenotypes.put(FREE_TEXT, freeText); }
/** * Converts and adds {@code features} to sets of present {@code retrievedPresentTerms terms} and absent * {@code retrievedAbsentTerms terms}. * * @param features a collection of {@link Feature} objects * @param retrievedPresentTerms a set of present {@link VocabularyTerm} objects * @param retrievedAbsentTerms a set of absent {@link VocabularyTerm} objects */ private void addTermsFromFeatures( @Nonnull final Collection<? extends Feature> features, @Nonnull final Set<VocabularyTerm> retrievedPresentTerms, @Nonnull final Set<VocabularyTerm> retrievedAbsentTerms) { for (final Feature feature : features) { final VocabularyTerm term = this.vocabularyManager.resolveTerm(feature.getValue()); if (term != null) { if (feature.isPresent()) { retrievedPresentTerms.add(term); } else { retrievedAbsentTerms.add(term); } } } } }
@Override public double getScore() { if (this.reference == null || this.match == null) { return Double.NaN; } double score = 0; if (StringUtils.equals(this.match.getId(), this.reference.getId())) { score = 1; } else { score = getRelativeScore(); } if (this.match.isPresent() != this.reference.isPresent()) { score = -score; } return adjustScoreWithMetadataScores(score); }
/** * Compute the information content of a patient's positive or negative symptoms. * * @param p the patient profile to score * @param presentFeatures whether the score for positive ({@code true}) or negative ({@code false}) features is * computed * @return the score (information content) and the number of features */ private Pair<Double, Integer> process(Patient p, boolean presentFeatures) { double score = 0; int count = 0; for (Feature f : p.getFeatures()) { if (StringUtils.isNotEmpty(f.getId()) && f.isPresent() == presentFeatures) { score += informationContent(f); count++; } } return new ImmutablePair<Double, Integer>(score, count); }
/** * Compute the information content of a patient's positive or negative symptoms. * * @param p the patient profile to score * @param presentFeatures whether the score for positive ({@code true}) or negative ({@code false}) features is * computed * @return the score (information content) and the number of features */ private Pair<Double, Integer> process(Patient p, boolean presentFeatures) { double score = 0; int count = 0; for (Feature f : p.getFeatures()) { if (StringUtils.isNotEmpty(f.getId()) && f.isPresent() == presentFeatures) { score += informationContent(f); count++; } } return new ImmutablePair<Double, Integer>(score, count); }
if (StringUtils.isNotEmpty(f.getId())) { JSONObject featureObj = new JSONObject(Collections.singletonMap("id", f.getId())); if (!f.isPresent()) { featureObj.put("isPresent", false);
if (StringUtils.isNotEmpty(f.getId())) { JSONObject featureObj = new JSONObject(Collections.singletonMap("id", f.getId())); if (!f.isPresent()) { featureObj.put("isPresent", false);
Feature feature = iterator.next(); String featureType = feature.getType(); if (!feature.isPresent()) { featureType = PhenoTipsFeature.NEGATIVE_PHENOTYPE_PREFIX + featureType;
x = 0; if (!Boolean.valueOf(feature.isPresent()).equals(lastStatus)) { DataCell cell = new DataCell(feature.isPresent() ? this.translationManager.translate("yes") : this.translationManager.translate("no"), cell.addStyle(StyleOption.YES_NO_SEPARATOR); lastStatus = feature.isPresent(); cell.addStyle(lastStatus ? StyleOption.YES : StyleOption.NO); section.addCell(cell);
x = 0; if (!Boolean.valueOf(feature.isPresent()).equals(lastStatus)) { DataCell cell = new DataCell(feature.isPresent() ? this.translationManager.translate("yes") : this.translationManager.translate("no"), cell.addStyle(StyleOption.YES_NO_SEPARATOR); lastStatus = feature.isPresent(); cell.addStyle(lastStatus ? StyleOption.YES : StyleOption.NO); section.addCell(cell);
x = 0; if (!Boolean.valueOf(feature.isPresent()).equals(lastStatus)) { lastSection = ""; DataCell cell = new DataCell(feature.isPresent() ? this.translationManager.translate("yes") : this.translationManager.translate("no"), cell.addStyle(StyleOption.YES_NO_SEPARATOR); lastStatus = feature.isPresent(); cell.addStyle(lastStatus ? StyleOption.YES : StyleOption.NO); section.addCell(cell);
String presence = (phenotype.isPresent() ? "" : "negative_"); String fieldName = presence + phenotype.getType(); String ancestorFieldName = "extended_" + presence + "phenotype";
result.element("name", this.match.getName()); result.element("type", this.match.getType()); if (!this.match.isPresent()) { result.element("isPresent", false);