public Individual(String id, String name, Sex sex, String ethnicity, Population population, int release, List<AnnotationSet> annotationSets, Map<String, Object> attributes) { this(id, name, new Individual(), new Individual(), new Multiples(), new Location(), sex, null, ethnicity, population, "", release, 1, TimeUtils.getTime(), new Status(), LifeStatus.UNKNOWN, AffectationStatus.UNKNOWN, Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), false, annotationSets, attributes); }
@Test public void testCreateIndividualFatherNotFound() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", new Individual().setId("father").setUid(10), null, null, null, null, null, "", null, null, null, "", Collections.emptyList(), false, 1, Collections.emptyList(), Collections.emptyList(), null), null); }
@Test public void testCreateIndividualAlreadyExists() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", null, "", null, 1, Collections .emptyList(), null), null); thrown.expect(CatalogDBException.class); //Name already exists catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", null, "", null, 1, Collections .emptyList(), null), null); }
@Test public void testCreateIndividualStudyNotFound() throws Exception { thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.insert(-10, new Individual(), null); }
@Test public void testCreateIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual(), null); }
@Test public void createFamilyDuo() throws CatalogException { Family family = new Family() .setId("test") .setPhenotypes(Arrays.asList(new Phenotype("E00", "blabla", "blabla"))) .setMembers(Arrays.asList(new Individual().setId("proband").setSex(IndividualProperty.Sex.MALE), new Individual().setFather(new Individual().setId("proband")).setId("child") .setSex(IndividualProperty.Sex.FEMALE))); QueryResult<Family> familyQueryResult = familyManager.create(STUDY, family, QueryOptions.empty(), sessionIdUser); assertEquals(2, familyQueryResult.first().getMembers().size()); }
@Ignore @Test public void testModifyIndividualExistingName() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); catalogIndividualDBAdaptor.insert(studyId, new Individual("in2", "in2", IndividualProperty.Sex.UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("name", "in2"), QueryOptions.empty()); }
@Test public void testModifyIndividualBadGender() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("sex", "bad sex"), QueryOptions.empty()); }
@Test public void testModifyIndividualBadFatherId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); thrown.expect(CatalogDBException.class); catalogIndividualDBAdaptor.update(individualId, new ObjectMap("fatherId", 4000), QueryOptions.empty()); }
@Test @Ignore // TODO: This should be tested in the sample manager, not here !!! public void deleteSampleFail3Test() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> createResult = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); dbAdaptorFactory.getCatalogCohortDBAdaptor().insert(studyId, new Cohort("Cohort", Study.Type.COLLECTION, "", "", Collections.singletonList(createResult.first()), 1, null), null); thrown.expect(CatalogDBException.class); dbAdaptorFactory.getCatalogSampleDBAdaptor().delete(createResult.first().getUid()); }
@Test public void testGetIndividualNoExists() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Individual individual = new Individual("in1", "An Individual", IndividualProperty.Sex.MALE, "", new Individual .Population(), 1, Collections.emptyList(), null); catalogIndividualDBAdaptor.insert(studyId, individual, null).first(); catalogIndividualDBAdaptor.get(individual.getUid(), null).first(); thrown.expect(CatalogDBException.class); //Id not found catalogIndividualDBAdaptor.get(9999, null); }
@Test public void deleteSampleTest() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> createResult = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); dbAdaptorFactory.getCatalogSampleDBAdaptor().delete(createResult.first().getUid()); thrown.expect(CatalogDBException.class); thrown.expectMessage("does not exist"); catalogSampleDBAdaptor.get(createResult.first().getUid(), QueryOptions.empty()); }
@Test public void testGetStudyIdByIndividualId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual().setStatus(new Status()), null).first().getUid(); long studyIdByIndividualId = catalogIndividualDBAdaptor.getStudyId(individualId); assertEquals(studyId, studyIdByIndividualId); }
@Test public void testModifyIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); ObjectMap params = new ObjectMap("sex", "MALE"); catalogIndividualDBAdaptor.update(individualId, params, QueryOptions.empty()); Individual individual = catalogIndividualDBAdaptor.get(individualId, null).first(); assertEquals(IndividualProperty.Sex.MALE, individual.getSex()); }
@Test public void testGetIndividual() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Individual individual = new Individual("an_individual", "An Individual", IndividualProperty.Sex.MALE, "", new Individual.Population(), 1, Collections.emptyList(), null); individual = catalogIndividualDBAdaptor.insert(studyId, individual, null).first(); Individual individual2 = catalogIndividualDBAdaptor.get(individual.getUid(), null).first(); assertEquals(individual.toString(), individual2.toString()); }
@Test public void createSampleTest() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> result = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); assertEquals(hg0097.getId(), result.first().getId()); assertEquals(hg0097.getDescription(), result.first().getDescription()); assertTrue(result.first().getUid() > 0); }
@Test public void testModifyIndividualNegativeFatherId() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long individualId = catalogIndividualDBAdaptor.insert(studyId, new Individual("in1", "in1", IndividualProperty.Sex .UNKNOWN, "", null, 1, Collections.emptyList(), null), null).first().getUid(); Individual individual = catalogIndividualDBAdaptor.update(individualId, new ObjectMap(IndividualDBAdaptor.QueryParams.FATHER_UID.key(), -1), QueryOptions.empty()).first(); assertEquals(-1, individual.getFather().getUid()); }
@Test @Ignore public void deleteSampleFail2Test() throws Exception { long studyId = user3.getProjects().get(0).getStudies().get(0).getUid(); long fileId = dbAdaptorFactory.getCatalogFileDBAdaptor().getId(user3.getProjects().get(0).getStudies().get(0).getUid(), "data/file.vcf"); Sample hg0097 = new Sample("HG0097", "1000g", new Individual(), "A description", 1); QueryResult<Sample> createResult = dbAdaptorFactory.getCatalogSampleDBAdaptor().insert(studyId, hg0097, null); dbAdaptorFactory.getCatalogFileDBAdaptor().update(fileId, new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), createResult.first().getUid()), QueryOptions.empty()); dbAdaptorFactory.getCatalogSampleDBAdaptor().delete(createResult.first().getUid()); }
private QueryResult<ClinicalAnalysis> createDummyEnvironment(boolean createFamily) throws CatalogException { createDummyFamily(); ClinicalAnalysis clinicalAnalysis = new ClinicalAnalysis() .setId("analysis").setDescription("My description").setType(ClinicalAnalysis.Type.FAMILY) .setDueDate("20180510100000") .setProband(new Individual().setId("child1").setSamples(Arrays.asList(new Sample().setId("sample2")))); if (createFamily) { clinicalAnalysis.setFamily(new Family().setId("family")); } return catalogManager.getClinicalAnalysisManager().create(STUDY, clinicalAnalysis, QueryOptions.empty(), sessionIdUser); }
@Test public void testModifySample() throws CatalogException { String sampleId1 = catalogManager.getSampleManager() .create(studyFqn, new Sample().setId("SAMPLE_1"), new QueryOptions(), sessionIdUser).first().getId(); String individualId = catalogManager.getIndividualManager().create(studyFqn, new Individual().setId("Individual1"), new QueryOptions(), sessionIdUser).first().getId(); Sample sample = catalogManager.getSampleManager() .update(studyFqn, sampleId1, new ObjectMap(SampleDBAdaptor.QueryParams.INDIVIDUAL.key(), individualId), new QueryOptions("lazy", false), sessionIdUser).first(); assertEquals(individualId, ((Individual) sample.getAttributes().get("individual")).getId()); }