/** * encodes a {@link VariantContext} as a VCF line * * Depending on the use case it may be more efficient to {@link #write(Appendable, VariantContext)} directly * instead of creating an intermediate string. * * @return the VCF line */ public String encode(final VariantContext context) { try { final StringBuilder stringBuilder = new StringBuilder(1000); write(stringBuilder, context); return stringBuilder.toString(); } catch (final IOException error) { throw new RuntimeIOException("Cannot encode variant", error); } }
/** * encodes a {@link VariantContext} as a VCF line * * Depending on the use case it may be more efficient to {@link #write(Appendable, VariantContext)} directly * instead of creating an intermediate string. * * @return the VCF line */ public String encode(final VariantContext context) { try { final StringBuilder stringBuilder = new StringBuilder(1000); write(stringBuilder, context); return stringBuilder.toString(); } catch (final IOException error) { throw new RuntimeIOException("Cannot encode variant", error); } }
/** * Add a record to the file */ @Override public void add(final VariantContext context) { try { super.add(context); if (this.mHeader == null) { throw new IllegalStateException("Unable to write the VCF: header is missing, " + "try to call writeHeader or setHeader first."); } if (this.doNotWriteGenotypes) { this.vcfEncoder.write(this.writer, new VariantContextBuilder(context).noGenotypes().make()); } else { this.vcfEncoder.write(this.writer, context); } write("\n"); writeAndResetBuffer(); outputHasBeenWritten = true; } catch (IOException e) { throw new RuntimeIOException("Unable to write the VCF object to " + getStreamName(), e); } }
/** * Add a record to the file */ @Override public void add(final VariantContext context) { try { super.add(context); if (this.mHeader == null) { throw new IllegalStateException("Unable to write the VCF: header is missing, " + "try to call writeHeader or setHeader first."); } if (this.doNotWriteGenotypes) { this.vcfEncoder.write(this.writer, new VariantContextBuilder(context).noGenotypes().make()); } else { this.vcfEncoder.write(this.writer, context); } write("\n"); writeAndResetBuffer(); outputHasBeenWritten = true; } catch (IOException e) { throw new RuntimeIOException("Unable to write the VCF object to " + getStreamName(), e); } }