private void validatePhenotypes(Family family) throws CatalogException { if (family.getPhenotypes() == null || family.getPhenotypes().isEmpty()) { if (ListUtils.isNotEmpty(family.getMembers())) { Map<String, Phenotype> phenotypeMap = new HashMap<>(); Set<String> familyPhenotypes = family.getPhenotypes().stream().map(Phenotype::getId).collect(Collectors.toSet()); if (!familyPhenotypes.containsAll(memberPhenotypes)) { throw new CatalogException("Some of the phenotypes are not present in any member of the family");
public static Pedigree getPedigreeFromFamily(Family family) { List<Individual> members = family.getMembers(); Map<String, Member> individualMap = new HashMap<>(); // Parse all the individuals for (Individual member : members) { Member individual = new Member( member.getId(), member.getName(), null, null, member.getMultiples(), Member.Sex.getEnum(member.getSex().toString()), member.getLifeStatus(), Member.AffectionStatus.getEnum(member.getAffectationStatus().toString()), member.getPhenotypes(), member.getAttributes()); individualMap.put(individual.getId(), individual); } // Fill parent information for (Individual member : members) { if (member.getFather() != null && StringUtils.isNotEmpty(member.getFather().getId())) { individualMap.get(member.getId()).setFather(individualMap.get(member.getFather().getId())); } if (member.getMother() != null && StringUtils.isNotEmpty(member.getMother().getId())) { individualMap.get(member.getId()).setMother(individualMap.get(member.getMother().getId())); } } List<Member> individuals = new ArrayList<>(individualMap.values()); return new Pedigree(family.getId(), individuals, family.getPhenotypes(), family.getAttributes()); }
familySolrModel.setStatus(family.getStatus().getName()); familySolrModel.setPhenotypes(SolrConverterUtil.populatePhenotypes(family.getPhenotypes()));
"Can not be used along with filter \"" + SAMPLE.key() + '"'); if (family.getPhenotypes().isEmpty()) { throw VariantQueryException.malformedParam(FAMILY, familyId, "Family doesn't have phenotypes"); if (isValidParam(query, FAMILY_PHENOTYPE)) { String phenotypeId = query.getString(FAMILY_PHENOTYPE.key()); phenotype = family.getPhenotypes() .stream() .filter(familyPhenotype -> familyPhenotype.getId().equals(phenotypeId)) if (phenotype == null) { throw VariantQueryException.malformedParam(FAMILY_PHENOTYPE, phenotypeId, "Available phenotypes: " + family.getPhenotypes() .stream() .map(Phenotype::getId) if (family.getPhenotypes().size() > 1) { throw VariantQueryException.missingParam(FAMILY_PHENOTYPE, "More than one phenotype found for the family \"" + familyId + "\". " + "Available phenotypes: " + family.getPhenotypes() .stream() .map(Phenotype::getId) .collect(Collectors.toList())); phenotype = family.getPhenotypes().get(0);
for (Phenotype phenotype : familyQueryResult.first().getPhenotypes()) { if (phenotype.getId().equals(disease)) { notFound = false;
@Test public void updateFamilyPhenotype() throws JsonProcessingException, CatalogException { QueryResult<Family> originalFamily = createDummyFamily("Martinez-Martinez"); Phenotype phenotype1 = new Phenotype("dis1", "New name", "New source"); Phenotype phenotype2 = new Phenotype("dis2", "New name", "New source"); Phenotype phenotype3 = new Phenotype("dis3", "New name", "New source"); Family family = new Family(); family.setPhenotypes(Arrays.asList(phenotype1, phenotype2, phenotype3)); ObjectMapper jsonObjectMapper = catalogManagerResource.generateNewObjectMapper(); ObjectMap params = new ObjectMap(jsonObjectMapper.writeValueAsString(family)); params = new ObjectMap(FamilyDBAdaptor.QueryParams.PHENOTYPES.key(), params.get(FamilyDBAdaptor.QueryParams.PHENOTYPES.key())); QueryResult<Family> updatedFamily = familyManager.update(STUDY, originalFamily.first().getName(), params, QueryOptions.empty(), sessionIdUser); assertEquals(3, updatedFamily.first().getPhenotypes().size()); // Only one id should be the same as in originalFamilyIds (father id) for (Phenotype phenotype : updatedFamily.first().getPhenotypes()) { assertEquals("New name", phenotype.getName()); assertEquals("New source", phenotype.getSource()); } }
public QueryResult<Family> create(String studyStr, Family family, QueryOptions options, String sessionId) throws CatalogException { String userId = catalogManager.getUserManager().getUserId(sessionId); Study study = catalogManager.getStudyManager().resolveId(studyStr, userId); authorizationManager.checkStudyPermission(study.getUid(), userId, StudyAclEntry.StudyPermissions.WRITE_FAMILIES); ParamUtils.checkObj(family, "family"); ParamUtils.checkAlias(family.getId(), "id"); family.setName(ParamUtils.defaultObject(family.getName(), family.getId())); family.setMembers(ParamUtils.defaultObject(family.getMembers(), Collections.emptyList())); family.setPhenotypes(ParamUtils.defaultObject(family.getPhenotypes(), Collections.emptyList())); family.setDisorders(ParamUtils.defaultObject(family.getDisorders(), Collections.emptyList())); family.setCreationDate(TimeUtils.getTime()); family.setDescription(ParamUtils.defaultString(family.getDescription(), "")); family.setStatus(new Family.FamilyStatus()); family.setAnnotationSets(ParamUtils.defaultObject(family.getAnnotationSets(), Collections.emptyList())); family.setRelease(catalogManager.getStudyManager().getCurrentRelease(study, userId)); family.setVersion(1); family.setAttributes(ParamUtils.defaultObject(family.getAttributes(), Collections.emptyMap())); List<VariableSet> variableSetList = validateNewAnnotationSetsAndExtractVariableSets(study.getUid(), family.getAnnotationSets()); autoCompleteFamilyMembers(family, study, sessionId); validateFamily(family); validateMultiples(family); validatePhenotypes(family); validateDisorders(family); createMissingMembers(family, study, sessionId); options = ParamUtils.defaultObject(options, QueryOptions::new); family.setUuid(UUIDUtils.generateOpenCGAUUID(UUIDUtils.Entity.FAMILY)); QueryResult<Family> queryResult = familyDBAdaptor.insert(study.getUid(), family, variableSetList, options); auditManager.recordCreation(AuditRecord.Resource.family, queryResult.first().getId(), userId, queryResult.first(), null, null); return queryResult; }
assertEquals(2, familyQueryResult.first().getPhenotypes().size()); assertEquals(2, familyQueryResult.first().getPhenotypes().size());
if (family.getPhenotypes() == null || family.getMembers().isEmpty()) { family.setPhenotypes(familyQueryResult.first().getPhenotypes());