@Test public void createFamilyRepeatedMember() throws CatalogException { Phenotype phenotype1 = new Phenotype("dis1", "Phenotype 1", "HPO"); Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); // We create a new father and mother with the same information to mimic the behaviour of the webservices. Otherwise, we would be // ingesting references to exactly the same object and this test would not work exactly the same way. Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relChild1 = new Individual().setId("child1") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Family family = new Family("Martinez-Martinez", "Martinez-Martinez", Arrays.asList(phenotype1, phenotype2), null, Arrays.asList(relFather, relMother, relChild1, relChild2, relChild1), "", -1, Collections.emptyList(), Collections.emptyMap ()); QueryResult<Family> familyQueryResult = familyManager.create(STUDY, family, QueryOptions.empty(), sessionIdUser); assertEquals(4, familyQueryResult.first().getMembers().size()); }
@Test public void createFamilyPhenotypeNotPassed() throws CatalogException { Phenotype phenotype1 = new Phenotype("dis1", "Phenotype 1", "HPO"); Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); // We create a new father and mother with the same information to mimic the behaviour of the webservices. Otherwise, we would be // ingesting references to exactly the same object and this test would not work exactly the same way. Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relChild1 = new Individual().setId("child1") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis3", "dis3", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Family family = new Family("Martinez-Martinez", "Martinez-Martinez", Arrays.asList(phenotype1, phenotype2), null, Arrays.asList(relFather, relMother, relChild1, relChild2), "", 4, Collections.emptyList(), Collections.emptyMap()); thrown.expect(CatalogException.class); thrown.expectMessage("not present in any member of the family"); familyManager.create(STUDY, family, QueryOptions.empty(), sessionIdUser); }
@Test public void createFamilyMissingMember() throws CatalogException { Phenotype phenotype1 = new Phenotype("dis1", "Phenotype 1", "HPO"); Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); // We create a new father and mother with the same information to mimic the behaviour of the webservices. Otherwise, we would be // ingesting references to exactly the same object and this test would not work exactly the same way. Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relChild1 = new Individual().setId("child1") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Collections.singletonList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Family family = new Family("Martinez-Martinez", "Martinez-Martinez", Arrays.asList(phenotype1, phenotype2), null, Arrays.asList(relFather, relChild1, relChild2), "", 3, Collections.emptyList(), Collections.emptyMap()); thrown.expect(CatalogException.class); thrown.expectMessage("not present in the members list"); familyManager.create(STUDY, family, QueryOptions.empty(), sessionIdUser); }
Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild3 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother)
Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild3 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother)
Phenotype phenotype2 = new Phenotype("dis2", "Phenotype 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild3 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother)
Phenotype disease2 = new Phenotype("dis2", "Disease 2", "HPO"); Individual father = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual mother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relMother = new Individual().setId("mother").setPhenotypes(Arrays.asList(new Phenotype("dis2", "dis2", "OT"))); .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild2 = new Individual().setId("child2") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Individual relChild3 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))) .setFather(father) .setMother(mother)
individual.setAffectationStatus(ParamUtils.defaultObject(individual.getAffectationStatus(), IndividualProperty.AffectationStatus.UNKNOWN)); individual.setPhenotypes(ParamUtils.defaultObject(individual.getPhenotypes(), Collections.emptyList())); individual.setAnnotationSets(ParamUtils.defaultObject(individual.getAnnotationSets(), Collections.emptyList())); individual.setAttributes(ParamUtils.defaultObject(individual.getAttributes(), Collections.emptyMap()));
@Test public void updateFamilyMissingMember() throws CatalogException, JsonProcessingException { QueryResult<Family> originalFamily = createDummyFamily("Martinez-Martinez"); Individual father = new Individual().setId("father"); Individual mother = new Individual().setId("mother2"); // We create a new father and mother with the same information to mimic the behaviour of the webservices. Otherwise, we would be // ingesting references to exactly the same object and this test would not work exactly the same way. Individual relFather = new Individual().setId("father").setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"))); Individual relChild1 = new Individual().setId("child3") .setPhenotypes(Arrays.asList(new Phenotype("dis1", "dis1", "OT"), new Phenotype("dis2", "dis2", "OT"))) .setFather(father) .setMother(mother) .setParentalConsanguinity(true); Family family = new Family(); family.setMembers(Arrays.asList(relChild1, relFather)); ObjectMapper jsonObjectMapper = catalogManagerResource.generateNewObjectMapper(); ObjectMap params = new ObjectMap(jsonObjectMapper.writeValueAsString(family)); params = new ObjectMap(FamilyDBAdaptor.QueryParams.MEMBERS.key(), params.get(FamilyDBAdaptor.QueryParams.MEMBERS.key())); thrown.expect(CatalogException.class); thrown.expectMessage("not present in the members list"); familyManager.update(STUDY, originalFamily.first().getName(), params, QueryOptions.empty(), sessionIdUser); }
individuals.add(catalog.getIndividualManager().create("s1", new Individual("individual1", "individual1", IndividualProperty.Sex.MALE, null, null, 0, Collections.emptyList(), Collections.emptyMap()), null, sessionId).first()); individuals.add(catalog.getIndividualManager().create("s1", new Individual("individual2", "individual2", IndividualProperty.Sex.FEMALE, null, null, 0, Collections.emptyList(), Collections.emptyMap()), null, sessionId).first()); individuals.add(catalog.getIndividualManager().create("s1", new Individual("individual3", "individual3", IndividualProperty.Sex.MALE, null, null, 0, Collections.emptyList(), Collections.emptyMap()).setFather(individuals.get(0)).setMother(individuals.get(1)).setPhenotypes(Collections.singletonList(phenotype)), null, sessionId).first()); individuals.add(catalog.getIndividualManager().create("s1", new Individual("individual4", "individual4", IndividualProperty.Sex.FEMALE, null, null, 0, Collections.emptyList(), Collections.emptyMap()).setFather(individuals.get(0)).setMother(individuals.get(1)), null, sessionId).first()); catalog.getFamilyManager().create("s1", new Family("f1", "f1", Collections.singletonList(phenotype), null, individuals, null, 3, null, null), null, sessionId);