public static OutputStream getOutputStream(String output, VariantOutputFormat outputFormat) throws IOException { boolean gzip = outputFormat.isGzip(); // output format has priority over output name OutputStream outputStream; if (isStandardOutput(output)) { // Unclosable OutputStream outputStream = new UnclosableOutputStream(System.out); } else { outputStream = new FileOutputStream(output); logger.debug("writing to %s", output); } // If compressed a GZip output stream is used if (gzip && outputFormat != VariantOutputFormat.AVRO_GZ) { outputStream = new GZIPOutputStream(outputStream); } else { outputStream = new BufferedOutputStream(outputStream); } logger.debug("using {} output stream", gzip ? "gzipped" : "plain"); return outputStream; }
.append(VariantExporterDriver.OUTPUT_FORMAT_PARAM, outputFormat.toString()); options.putAll(query); options.putAll(queryOptions);
/** * Transform the string to a valid output format. * If none, VCF by default. * * @param outputFormatStr Output format as String * @param output Output file * @return Valid VariantOutputFormat * @throws IllegalArgumentException if the outputFormatStr is not valid */ public static VariantOutputFormat toOutputFormat(String outputFormatStr, String output) { if (!StringUtils.isEmpty(outputFormatStr)) { outputFormatStr = outputFormatStr.replace('.', '_'); return VariantOutputFormat.valueOf(outputFormatStr.toUpperCase()); } else if (isStandardOutput(output)) { return VCF; } else { return VCF_GZ; } }
&& StringUtils.isEmpty(queryVariantsOptions.rank); if (returnVariants && !of.isMultiStudyOutput()) { if (VariantQueryUtils.isOutputMultiStudy(query, null, allStudyNames)) { String availableStudies = allStudyNames == null || allStudyNames.isEmpty()
output = output.substring(0, output.length() - 1); if (!output.endsWith(outputFormat.getExtension())) { String[] split = outputFormat.getExtension().split("\\."); int idx = 0; for (int i = 0; i < split.length; i++) {
private DataWriter<Variant> configureWriter(final TaskAttemptContext job, OutputStream fileOut) throws IOException { // job.getCounter(VcfDataWriter.class.getName(), "failed").increment(0); // init final Configuration conf = job.getConfiguration(); VariantOutputFormat outputFormat = VariantOutputFormat.valueOf(conf.get(OUTPUT_FORMAT_PARAM)); DataWriter<Variant> dataWriter; VariantTableHelper helper = new VariantTableHelper(conf); try (StudyConfigurationManager scm = new StudyConfigurationManager(new HBaseVariantStorageMetadataDBAdaptorFactory(helper))) { VariantWriterFactory writerFactory = new VariantWriterFactory(scm); Query query = VariantMapReduceUtil.getQueryFromConfig(conf); QueryOptions options = VariantMapReduceUtil.getQueryOptionsFromConfig(conf); dataWriter = writerFactory.newDataWriter(outputFormat, fileOut, query, options); // dataWriter.setConverterErrorListener((v, e) -> // job.getCounter(VcfDataWriter.class.getName(), "failed").increment(1)); dataWriter.open(); dataWriter.pre(); return dataWriter; } }
@Override protected void parseAndValidateParameters() throws IOException { super.parseAndValidateParameters(); outputFormat = VariantOutputFormat.valueOf(getConf().get(OUTPUT_FORMAT_PARAM, "avro").toUpperCase()); outFile = getConf().get(OUTPUT_PARAM); if (outFile == null || outFile.isEmpty()) { throw new IllegalArgumentException(outFile); } getQueryFromConfig(query, getConf()); getQueryOptionsFromConfig(options, getConf()); }