private void checkAlignmentBioformat(File file) throws CatalogException { if (!file.getBioformat().equals(File.Bioformat.ALIGNMENT)) { throw new CatalogException("File " + file.getName() + " not supported. Expecting an alignment file."); } }
@Test public void testComplexAdd() throws IOException, CatalogException, URISyntaxException { CatalogIOManager ioManager = catalogManager.getCatalogIOManagerFactory().getDefault(); URI fileUri = getClass().getResource("/biofiles/variant-test-file.vcf.gz").toURI(); ioManager.copyFile(fileUri, directory.resolve("file1.vcf.gz").toUri()); CatalogManagerTest.createDebugFile(directory.resolve("file1.vcf.variants.json").toString()); CatalogManagerTest.createDebugFile(directory.resolve("file1.vcf.variants.json.gz").toString()); CatalogManagerTest.createDebugFile(directory.resolve("file1.vcf.variants.json.snappy").toString()); CatalogManagerTest.createDebugFile(directory.resolve("file2.bam").toString()); CatalogManagerTest.createDebugFile(directory.resolve("file2.sam.gz").toString()); FileScanner fileScanner = new FileScanner(catalogManager); List<File> files = fileScanner.scan(folder, directory.toUri(), FileScanner.FileScannerPolicy.REPLACE, true, true, sessionIdUser); Map<String, File> map = files.stream().collect(Collectors.toMap(File::getName, (f) -> f)); assertEquals(6, files.size()); files.forEach((file) -> assertEquals(File.FileStatus.READY, file.getStatus().getName())); assertEquals(File.Bioformat.VARIANT, map.get("file1.vcf.gz").getBioformat()); assertEquals(File.Bioformat.VARIANT, map.get("file1.vcf.variants.json").getBioformat()); assertEquals(File.Bioformat.VARIANT, map.get("file1.vcf.variants.json.gz").getBioformat()); assertEquals(File.Bioformat.VARIANT, map.get("file1.vcf.variants.json.snappy").getBioformat()); assertEquals(File.Bioformat.ALIGNMENT, map.get("file2.bam").getBioformat()); assertEquals(File.Bioformat.ALIGNMENT, map.get("file2.sam.gz").getBioformat()); assertEquals(File.Format.VCF, map.get("file1.vcf.gz").getFormat()); assertEquals(File.Format.JSON, map.get("file1.vcf.variants.json").getFormat()); assertEquals(File.Format.JSON, map.get("file1.vcf.variants.json.gz").getFormat()); assertEquals(File.Format.JSON, map.get("file1.vcf.variants.json.snappy").getFormat()); assertEquals(File.Format.BAM, map.get("file2.bam").getFormat()); assertEquals(File.Format.SAM, map.get("file2.sam.gz").getFormat()); }
if (inputFile.getBioformat().equals(File.Bioformat.VARIANT)) { Path metaFile = outdir.resolve(inputFile.getName() + "." + VariantReaderUtils.METADATA_FILE_FORMAT_GZ); if (!metaFile.toFile().exists()) {
switch (fileModifyParams.containsKey(FileDBAdaptor.QueryParams.BIOFORMAT.key()) ? (File.Bioformat) fileModifyParams.get(FileDBAdaptor.QueryParams.BIOFORMAT.key()) : file.getBioformat()) { case VARIANT: { Object variantSourceObj = null;
@Test public void testIndex() throws Exception { URI uri = getClass().getResource("/biofiles/variant-test-file.vcf.gz").toURI(); File file = fileManager.link(studyFqn, uri, "", null, sessionIdUser).first(); assertEquals(4, file.getSamples().size()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); Job job = fileManager.index(studyFqn, Collections.singletonList(file.getName()), "VCF", null, sessionIdUser).first(); assertEquals(file.getUid(), job.getInput().get(0).getUid()); }
fileSolrModel.setFormat(file.getFormat().name()); if (file.getBioformat() != null) { fileSolrModel.setBioformat(file.getBioformat().name());
fileInfo.setFilePath(path); fileInfo.setName(file.getName()); fileInfo.setBioformat(file.getBioformat()); fileInfo.setFormat(file.getFormat());
@Test public void testGetMetadataFromVcf() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), vcfFileUri, new File().setPath(folder.getPath() + VCF_FILE_NAME), false, false, sessionIdUser).first(); assertTrue(file.getSize() > 0); file = FileMetadataReader.get(catalogManager). setMetadataInformation(file, null, null, sessionIdUser, false); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); assertEquals(expectedSampleNames, ((Map<String, Object>) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")); catalogManager.getSampleManager().get(study.getFqn(), new Query(SampleDBAdaptor.QueryParams.ID.key(), file.getSamples().stream().map(Sample::getId).collect(Collectors.toList())), new QueryOptions(), sessionIdUser).getResult(); assertTrue(expectedSampleNames.containsAll(file.getSamples().stream().map(Sample::getId).collect(Collectors.toSet()))); }
@Test public void testCreate() throws CatalogException { QueryResult<File> fileQueryResult = FileMetadataReader.get(catalogManager). create(study.getFqn(), vcfFileUri, folder.getPath() + VCF_FILE_NAME, "", false, null, sessionIdUser); File file = fileQueryResult.first(); assertEquals(File.FileStatus.STAGE, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); assertEquals(21499, file.getSize()); new FileUtils(catalogManager).upload(vcfFileUri, file, null, sessionIdUser, false, false, true, true, Integer.MAX_VALUE); file = catalogManager.getFileManager().get(study.getFqn(), file.getPath(), null, sessionIdUser).first(); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertNotNull(((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")); assertEquals(4, ((List) ((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("sampleIds")).size()); assertNotNull(((Map) file.getAttributes().get(VARIANT_FILE_METADATA)).get("header")); assertEquals(4, file.getSamples().size()); assertEquals(21499, file.getSize()); }
assert (fileSolrModel.getType().equals(file.getType().name())); assert (fileSolrModel.getFormat().equals(file.getFormat().name())); assert (fileSolrModel.getBioformat().equals(file.getBioformat().name())); assert (fileSolrModel.getRelease() == file.getRelease());
@Test public void testGetMetadataFromBam() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), bamFileUri, new File().setPath(folder.getPath() + BAM_FILE_NAME), false, false, sessionIdUser).first(); assertTrue(file.getSize() > 0); file = FileMetadataReader.get(catalogManager). setMetadataInformation(file, null, null, sessionIdUser, false); assertEquals(File.FileStatus.READY, file.getStatus().getName()); // assertEquals(File.Format.GZIP, file.getFormat()); assertEquals(File.Bioformat.ALIGNMENT, file.getBioformat()); assertNotNull(file.getAttributes().get("alignmentHeader")); assertEquals(1, file.getSamples().size()); assertEquals("HG00096", catalogManager.getSampleManager().get(study.getFqn(), file.getSamples().get(0).getId(), null, sessionIdUser).first().getId()); }
@Test public void testDoNotOverwriteSampleIds() throws CatalogException, FileNotFoundException { File file = catalogManager.getFileManager().upload(study.getFqn(), vcfFileUri, new File().setPath(folder.getPath() + VCF_FILE_NAME), false, false, sessionIdUser).first(); assertEquals(File.FileStatus.READY, file.getStatus().getName()); assertEquals(File.Format.VCF, file.getFormat()); assertEquals(File.Bioformat.VARIANT, file.getBioformat()); assertNotNull(file.getAttributes().get(VARIANT_FILE_METADATA)); assertEquals(4, file.getSamples().size()); //Add a sampleId String sampleId = catalogManager.getSampleManager().create(study.getFqn(), new Sample().setId("Bad_Sample"), null, sessionIdUser) .first().getId(); catalogManager.getFileManager().update(study.getFqn(), file.getPath(), new ObjectMap(FileDBAdaptor.QueryParams.SAMPLES.key(), Collections.singletonList(sampleId)), new QueryOptions(), sessionIdUser); file = catalogManager.getFileManager().get(study.getFqn(), file.getPath(), null, sessionIdUser).first(); assertEquals(5, file.getSamples().size()); assertEquals(sampleId, file.getSamples().get(4).getId()); }
file.setType(ParamUtils.defaultObject(file.getType(), File.Type.FILE)); file.setFormat(ParamUtils.defaultObject(file.getFormat(), File.Format.PLAIN)); file.setBioformat(ParamUtils.defaultObject(file.getBioformat(), File.Bioformat.NONE)); file.setDescription(ParamUtils.defaultString(file.getDescription(), "")); file.setRelatedFiles(ParamUtils.defaultObject(file.getRelatedFiles(), ArrayList::new));
file.setFormat(format); if (bioformat != File.Bioformat.NONE && !bioformat.equals(file.getBioformat())) { modifyParams.put(FileDBAdaptor.QueryParams.BIOFORMAT.key(), bioformat); file.setBioformat(bioformat);