/** * 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; } }
@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()); }
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; } }