use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.
the class AnalysisServiceTest method testReadSequencingRead.
@Test
public void testReadSequencingRead() {
val json = getJsonStringFromClasspath("documents/sequencingread-read-test.json");
val analysisRaw = fromJson(json, SequencingReadAnalysis.class);
val analysisId = service.create(DEFAULT_STUDY_ID, analysisRaw, false);
val a = (SequencingReadAnalysis) service.read(analysisId);
// Asserting Analysis
assertThat(a.getAnalysisState()).isEqualTo("UNPUBLISHED");
assertThat(a.getAnalysisType()).isEqualTo("sequencingRead");
assertThat(a.getStudy()).isEqualTo(DEFAULT_STUDY_ID);
assertInfoKVPair(a, "description1", "description1 for this sequencingRead analysis an01");
assertInfoKVPair(a, "description2", "description2 for this sequencingRead analysis an01");
val experiment = a.getExperiment();
assertThat(experiment.getAnalysisId()).isEqualTo(analysisId);
assertThat(experiment.getLibraryStrategy()).isEqualTo("WXS");
assertThat(experiment.getPairedEnd()).isFalse();
assertThat(experiment.getInsertSize()).isEqualTo(92736);
assertThat(experiment.getAligned()).isTrue();
assertThat(experiment.getAlignmentTool()).isEqualTo("myCool Sequence ReadingTool");
assertThat(experiment.getReferenceGenome()).isEqualTo("someSeq Genome");
assertInfoKVPair(experiment, "extraExperimentInfo", "some more data for a sequencingRead experiment ex02");
val sampleMap = Maps.<String, CompositeEntity>newHashMap();
// Asserting Sample
assertThat(a.getSample()).hasSize(2);
val sample0 = a.getSample().get(0);
sampleMap.put(sample0.getSampleId(), sample0);
assertThat(sample0.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fr01");
assertThat(sample0.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample0, "extraSampleInfo", "some more data for a sequencingRead sample_fr01");
val donor00 = sample0.getDonor();
assertThat(donor00.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor00.getDonorGender()).isEqualTo("male");
assertThat(donor00.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fr01");
assertInfoKVPair(donor00, "extraDonorInfo", "some more data for a sequencingRead donor_fr01");
val specimen00 = sample0.getSpecimen();
assertThat(specimen00.getDonorId()).isEqualTo(donor00.getDonorId());
assertThat(specimen00.getSpecimenClass()).isEqualTo("Tumour");
assertThat(specimen00.getSpecimenType()).isEqualTo("Primary tumour - other");
assertThat(sample0.getSpecimenId()).isEqualTo(specimen00.getSpecimenId());
assertInfoKVPair(specimen00, "extraSpecimenInfo_0", "first for a sequencingRead specimen_fr01");
assertInfoKVPair(specimen00, "extraSpecimenInfo_1", "second data for a sequencingRead specimen_fr01");
val sample1 = a.getSample().get(1);
sampleMap.put(sample1.getSampleId(), sample1);
assertThat(sample1.getSampleSubmitterId()).isEqualTo("internal_sample_98024759826836_fr02");
assertThat(sample1.getSampleType()).isEqualTo("Total RNA");
assertInfoKVPair(sample1, "extraSampleInfo", "some more data for a sequencingRead sample_fr02");
val donor01 = sample1.getDonor();
assertThat(donor01.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(donor01.getDonorGender()).isEqualTo("female");
assertThat(donor01.getDonorSubmitterId()).isEqualTo("internal_donor_123456789-00_fr02");
assertInfoKVPair(donor01, "extraDonorInfo_0", "first data for a sequencingRead donor_fr02");
assertInfoKVPair(donor01, "extraDonorInfo_1", "second data for a sequencingRead donor_fr02");
val specimen01 = sample1.getSpecimen();
assertThat(specimen01.getDonorId()).isEqualTo(donor01.getDonorId());
assertThat(specimen01.getSpecimenClass()).isEqualTo("Tumour");
assertThat(specimen01.getSpecimenType()).isEqualTo("Primary tumour - other");
assertThat(sample1.getSpecimenId()).isEqualTo(specimen01.getSpecimenId());
assertInfoKVPair(specimen01, "extraSpecimenInfo", "some more data for a sequencingRead specimen_fr02");
assertThat(a.getFile()).hasSize(3);
val file0 = a.getFile().get(0);
val file1 = a.getFile().get(1);
val file2 = a.getFile().get(2);
assertThat(file0.getAnalysisId()).isEqualTo(analysisId);
assertThat(file1.getAnalysisId()).isEqualTo(analysisId);
assertThat(file2.getAnalysisId()).isEqualTo(analysisId);
assertThat(file0.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(file1.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
assertThat(file2.getStudyId()).isEqualTo(DEFAULT_STUDY_ID);
val fileName0 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn1.MUSE_1-0rc-vcf.20170711.bam";
val fileName1 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn2.MUSE_1-0rc-vcf.20170711.bam";
val fileName2 = "a3bc0998a-3521-43fd-fa10-a834f3874e46-fn3.MUSE_1-0rc-vcf.20170711.bam.bai";
val fileMap = Maps.<String, File>newHashMap();
for (val file : a.getFile()) {
fileMap.put(file.getFileName(), file);
if (file.getFileName().equals(fileName0)) {
assertThat(file.getFileName()).isEqualTo(fileName0);
assertThat(file.getFileSize()).isEqualTo(1212121);
assertThat(file.getFileMd5sum()).isEqualTo("e2324667df8085eddfe95742047e153f");
assertThat(file.getFileAccess()).isEqualTo("controlled");
assertThat(file.getFileType()).isEqualTo("BAM");
assertInfoKVPair(file, "extraFileInfo_0", "first data for sequencingRead file_fn1");
assertInfoKVPair(file, "extraFileInfo_1", "second data for sequencingRead file_fn1");
} else if (file.getFileName().equals(fileName1)) {
assertThat(file.getFileName()).isEqualTo(fileName1);
assertThat(file.getFileSize()).isEqualTo(34343);
assertThat(file.getFileMd5sum()).isEqualTo("8b5379a29aac642d6fe1808826bd9e49");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("BAM");
assertInfoKVPair(file, "extraFileInfo", "some more data for sequencingRead file_fn2");
} else if (file.getFileName().equals(fileName2)) {
assertThat(file.getFileName()).isEqualTo(fileName2);
assertThat(file.getFileSize()).isEqualTo(4840);
assertThat(file.getFileMd5sum()).isEqualTo("61da923f32863a9c5fa3d2a0e19bdee3");
assertThat(file.getFileAccess()).isEqualTo("open");
assertThat(file.getFileType()).isEqualTo("BAI");
assertInfoKVPair(file, "extraFileInfo", "some more data for sequencingRead file_fn3");
} else {
fail(format("the fileName %s is not recognized", file.getFileName()));
}
}
// Test the readFiles method
for (val file : service.readFiles(analysisId)) {
assertThat(fileMap).containsKeys(file.getFileName());
assertThat(file).isEqualTo(fileMap.get(file.getFileName()));
}
// Test readSample method
for (val compositeEntity : service.readSamples(analysisId)) {
assertThat(sampleMap).containsKeys(compositeEntity.getSampleId());
assertThat(compositeEntity).isEqualTo(sampleMap.get(compositeEntity.getSampleId()));
}
assertThat(service.readSequencingRead(analysisId)).isEqualTo(experiment);
}
use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.
the class EntityTest method testFile.
@Test
public void testFile() {
val file1 = new File();
file1.setAnalysisId("a1");
file1.setFileAccess(CONTROLLED);
file1.setFileMd5sum("b1");
file1.setFileName("c1");
file1.setFileSize(13L);
file1.setFileType(FILE_TYPES.get(0));
file1.setObjectId("d1");
file1.setStudyId("e1");
val file1_same = File.create("d1", "a1", "c1", "e1", 13L, FILE_TYPES.get(0), "b1", CONTROLLED);
assertEntitiesEqual(file1, file1_same, true);
val file2 = File.create("d2", "a2", "c2", "e2", 14L, FILE_TYPES.get(1), "b2", CONTROLLED);
assertEntitiesNotEqual(file1, file2);
file1.setInfo("key1", "f5c9381090a53c54358feb2ba5b7a3d7");
file1_same.setInfo("key2", "6329334b-dcd5-53c8-98fd-9812ac386d30");
assertEntitiesNotEqual(file1, file1_same);
// Test getters
assertThat(file1.getAnalysisId()).isEqualTo("a1");
assertThat(file1.getFileAccess()).isEqualTo(CONTROLLED.toString());
assertThat(file1.getFileMd5sum()).isEqualTo("b1");
assertThat(file1.getFileName()).isEqualTo("c1");
assertThat(file1.getFileType()).isEqualTo(FILE_TYPES.get(0));
assertThat(file1.getObjectId()).isEqualTo("d1");
assertThat(file1.getStudyId()).isEqualTo("e1");
assertInfoKVPair(file1, "key1", "f5c9381090a53c54358feb2ba5b7a3d7");
}
use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.
the class FileServiceTest method testFileExists.
@Test
public void testFileExists() {
val existingFileId = DEFAULT_FILE_ID;
assertThat(fileService.isFileExist(existingFileId)).isTrue();
fileService.checkFileExists(existingFileId);
val file = new File();
file.setObjectId(existingFileId);
fileService.checkFileExists(file);
val randomFile = createRandomFile(DEFAULT_STUDY_ID, DEFAULT_ANALYSIS_ID);
assertThat(fileService.isFileExist(randomFile.getObjectId())).isFalse();
assertSongError(() -> fileService.checkFileExists(randomFile.getObjectId()), FILE_NOT_FOUND);
assertSongError(() -> fileService.checkFileExists(randomFile), FILE_NOT_FOUND);
}
use of org.icgc.dcc.song.server.model.entity.File in project SONG by overture-stack.
the class AnalysisService method publish.
public ResponseEntity<String> publish(@NonNull String accessToken, @NonNull String id) {
val files = readFiles(id);
val missingFileIds = files.stream().filter(f -> !confirmUploaded(accessToken, f.getObjectId())).collect(toImmutableList());
val isMissingFiles = missingFileIds.size() > 0;
checkServer(!isMissingFiles, getClass(), UNPUBLISHED_FILE_IDS, "The following file ids must be published before analysisId %s can be published: %s", id, COMMA.join(missingFileIds));
checkedUpdateState(id, PUBLISHED);
sender.send(String.format("{\"analysis_id\": %s, \"state\": \"PUBLISHED\"}", id));
return ok("AnalysisId %s successfully published", id);
}
Aggregations