static void assertWritable(final File output, final boolean outputByReadGroup) { if (outputByReadGroup) { if (output != null) { IOUtil.assertDirectoryIsWritable(output); } } else { IOUtil.assertFileIsWritable(output); } }
static void assertWritable(final File output, final boolean outputByReadGroup) { if (outputByReadGroup) { if (output != null) { IOUtil.assertDirectoryIsWritable(output); } } else { IOUtil.assertFileIsWritable(output); } }
/** * Checks that a directory is non-null, extent, writable and a directory * otherwise a runtime exception is thrown. * * @param dir the dir to check for writability */ public static void assertDirectoryIsWritable(final File dir) { final Path asPath = IOUtil.toPath(dir); assertDirectoryIsWritable(asPath); }
/** * Checks that a directory is non-null, extent, writable and a directory * otherwise a runtime exception is thrown. * * @param dir the dir to check for writability */ public static void assertDirectoryIsWritable(final File dir) { final Path asPath = IOUtil.toPath(dir); assertDirectoryIsWritable(asPath); }
/** * Prepare to accumulate records * * @param codec For writing records to file and reading them back into RAM * @param maxRecordsInRam how many records to accumulate before spilling to disk * @param tmpDirs Where to write files of records that will not fit in RAM */ private DiskBackedQueue(final SortingCollection.Codec<E> codec, final int maxRecordsInRam, final List<Path> tmpDirs) { if (maxRecordsInRam < 0) { throw new IllegalArgumentException("maxRecordsInRamQueue must be >= 0"); } if (tmpDirs == null || tmpDirs.isEmpty()) { throw new IllegalArgumentException("At least one temp directory must be provided."); } for (final Path tmpDir : tmpDirs) IOUtil.assertDirectoryIsWritable(tmpDir); this.tmpDirs = tmpDirs; this.codec = codec; this.maxRecordsInRamQueue = (maxRecordsInRam == 0) ? 0 : maxRecordsInRam - 1; // the first of our ram records is stored as headRecord this.ramRecords = new ArrayDeque<E>(this.maxRecordsInRamQueue); }
/** * Prepare to accumulate records * * @param codec For writing records to file and reading them back into RAM * @param maxRecordsInRam how many records to accumulate before spilling to disk * @param tmpDirs Where to write files of records that will not fit in RAM */ private DiskBackedQueue(final SortingCollection.Codec<E> codec, final int maxRecordsInRam, final List<Path> tmpDirs) { if (maxRecordsInRam < 0) { throw new IllegalArgumentException("maxRecordsInRamQueue must be >= 0"); } if (tmpDirs == null || tmpDirs.isEmpty()) { throw new IllegalArgumentException("At least one temp directory must be provided."); } for (final Path tmpDir : tmpDirs) IOUtil.assertDirectoryIsWritable(tmpDir); this.tmpDirs = tmpDirs; this.codec = codec; this.maxRecordsInRamQueue = (maxRecordsInRam == 0) ? 0 : maxRecordsInRam - 1; // the first of our ram records is stored as headRecord this.ramRecords = new ArrayDeque<E>(this.maxRecordsInRamQueue); }
private void ensureArgs() { IOUtil.assertFileIsReadable(REFERENCE_SEQUENCE); for (File f : INPUT) { IOUtil.assertFileIsReadable(f); } if (WORKING_DIR == null) { WORKING_DIR = new File("."); } IOUtil.assertDirectoryIsWritable(WORKING_DIR); if (CONFIGURATION_FILE != null) { IOUtil.assertFileIsReadable(CONFIGURATION_FILE); } } public static void ensureIndexed(File fa) throws IOException {
@Test(dataProvider = "pathsForWritableDirectory") public void testAssertDirectoryIsWritablePath(final Path path, final boolean writable) { try { IOUtil.assertDirectoryIsWritable(path); } catch (SAMException e) { if (writable) { Assert.fail(e.getMessage()); } } }
@Test(dataProvider = "filesForWritableDirectory") public void testAssertDirectoryIsWritableFile(final File file, final boolean writable) { try { IOUtil.assertDirectoryIsWritable(file); } catch (SAMException e) { if (writable) { Assert.fail(e.getMessage()); } } }
/** * @return FastqRecordsWriter that contains one or more FastqWriters (amount depends on read structure), all using * outputPrefix to determine the filename(s). */ private FastqRecordsWriter buildWriter(final File outputPrefix) { final File outputDir = outputPrefix.getAbsoluteFile().getParentFile(); IOUtil.assertDirectoryIsWritable(outputDir); final String prefixString = outputPrefix.getName(); final String suffixString = COMPRESS_OUTPUTS ? "fastq.gz" : "fastq"; final FastqWriter[] templateWriters = new FastqWriter[readStructure.templates.length()]; final FastqWriter[] sampleBarcodeWriters = new FastqWriter[readStructure.sampleBarcodes.length()]; final FastqWriter[] molecularBarcodeWriters = new FastqWriter[readStructure.molecularBarcode.length()]; for (int i = 0; i < templateWriters.length; ++i) { final String filename = String.format("%s.%d.%s", prefixString, i + 1, suffixString); templateWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } for (int i = 0; i < sampleBarcodeWriters.length; ++i) { final String filename = String.format("%s.barcode_%d.%s", prefixString, i + 1, suffixString); sampleBarcodeWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } for (int i = 0; i < molecularBarcodeWriters.length; ++i) { final String filename = String.format("%s.index_%d.%s", prefixString, i + 1, suffixString); molecularBarcodeWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } return new FastqRecordsWriter(templateWriters, sampleBarcodeWriters, molecularBarcodeWriters); }
/** * @return FastqRecordsWriter that contains one or more FastqWriters (amount depends on read structure), all using * outputPrefix to determine the filename(s). */ private FastqRecordsWriter buildWriter(final File outputPrefix) { final File outputDir = outputPrefix.getAbsoluteFile().getParentFile(); IOUtil.assertDirectoryIsWritable(outputDir); final String prefixString = outputPrefix.getName(); final String suffixString = COMPRESS_OUTPUTS ? "fastq.gz" : "fastq"; final FastqWriter[] templateWriters = new FastqWriter[readStructure.templates.length()]; final FastqWriter[] sampleBarcodeWriters = new FastqWriter[readStructure.sampleBarcodes.length()]; final FastqWriter[] molecularBarcodeWriters = new FastqWriter[readStructure.molecularBarcode.length()]; for (int i = 0; i < templateWriters.length; ++i) { final String filename = String.format("%s.%d.%s", prefixString, i + 1, suffixString); templateWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } for (int i = 0; i < sampleBarcodeWriters.length; ++i) { final String filename = String.format("%s.barcode_%d.%s", prefixString, i + 1, suffixString); sampleBarcodeWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } for (int i = 0; i < molecularBarcodeWriters.length; ++i) { final String filename = String.format("%s.index_%d.%s", prefixString, i + 1, suffixString); molecularBarcodeWriters[i] = fastqWriterFactory.newWriter(new File(outputDir, filename)); } return new FastqRecordsWriter(templateWriters, sampleBarcodeWriters, molecularBarcodeWriters); }
@Override protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertDirectoryIsWritable(OUTPUT);
@Override protected int doWork() { IOUtil.assertFileIsReadable(INPUT); IOUtil.assertDirectoryIsWritable(OUTPUT);
return 1; IOUtil.assertDirectoryIsWritable(OUTPUT); final SamReaderFactory readerFactory = SamReaderFactory.makeDefault(); final SamReader reader = readerFactory.referenceSequence(REFERENCE_SEQUENCE).open(INPUT);
return 1; IOUtil.assertDirectoryIsWritable(OUTPUT); final SamReaderFactory readerFactory = SamReaderFactory.makeDefault(); final SamReader reader = readerFactory.referenceSequence(REFERENCE_SEQUENCE).open(INPUT);
IOUtil.assertFileIsWritable(OUTPUT); } else { IOUtil.assertDirectoryIsWritable(OUTPUT);
IOUtil.assertFileIsWritable(OUTPUT); } else { IOUtil.assertDirectoryIsWritable(OUTPUT);
OUTPUT_DIRECTORY.mkdirs(); IOUtil.assertDirectoryIsWritable(OUTPUT_DIRECTORY);
@Override protected int doWork() { /////////////////////////////////////////////////////////////////////// // Test and then load up the inputs /////////////////////////////////////////////////////////////////////// final boolean outputVcfs = VCF_DIR != null; IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsReadable(TRIOS); IOUtil.assertFileIsWritable(OUTPUT); if (outputVcfs) IOUtil.assertDirectoryIsWritable(VCF_DIR); LOG.info("Loading and filtering trios."); final MendelianViolationDetector.Result result = VariantProcessor.Builder .generatingAccumulatorsBy(this::buildDetector) .withInput(INPUT) .combiningResultsBy(MendelianViolationDetector.Result::merge) .multithreadingBy(THREAD_COUNT) .build() .process(); // Write out the metrics! final MetricsFile<MendelianViolationMetrics, ?> metricsFile = getMetricsFile(); for (final MendelianViolationMetrics m : result.metrics()) { m.calculateDerivedFields(); metricsFile.addMetric(m); } metricsFile.write(OUTPUT); writeAllViolations(result); return 0; }
@Override protected int doWork() { /////////////////////////////////////////////////////////////////////// // Test and then load up the inputs /////////////////////////////////////////////////////////////////////// final boolean outputVcfs = VCF_DIR != null; IOUtil.assertFileIsReadable(INPUT); IOUtil.assertFileIsReadable(TRIOS); IOUtil.assertFileIsWritable(OUTPUT); if (outputVcfs) IOUtil.assertDirectoryIsWritable(VCF_DIR); LOG.info("Loading and filtering trios."); final MendelianViolationDetector.Result result = VariantProcessor.Builder .generatingAccumulatorsBy(this::buildDetector) .withInput(INPUT) .combiningResultsBy(MendelianViolationDetector.Result::merge) .multithreadingBy(THREAD_COUNT) .build() .process(); // Write out the metrics! final MetricsFile<MendelianViolationMetrics, ?> metricsFile = getMetricsFile(); for (final MendelianViolationMetrics m : result.metrics()) { m.calculateDerivedFields(); metricsFile.addMetric(m); } metricsFile.write(OUTPUT); writeAllViolations(result); return 0; }