Class ShardingVCFWriter

java.lang.Object
org.broadinstitute.hellbender.utils.variant.writers.ShardingVCFWriter
All Implemented Interfaces:
htsjdk.variant.variantcontext.writer.VariantContextWriter, Closeable, AutoCloseable

public class ShardingVCFWriter extends Object implements htsjdk.variant.variantcontext.writer.VariantContextWriter
Variant writer tha splits output to multiple VCFs given the maximum records per file. Before using add(htsjdk.variant.variantcontext.VariantContext), the header should be set using either setHeader(htsjdk.variant.vcf.VCFHeader) or writeHeader(htsjdk.variant.vcf.VCFHeader), which may only be called once and will determine whether headers are written to all shards.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    ShardingVCFWriter(Path basePath, int maxVariantsPerShard, htsjdk.samtools.SAMSequenceDictionary dictionary, boolean createMD5, htsjdk.variant.variantcontext.writer.Options... options)
    Create a new sharding VCF writer
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(htsjdk.variant.variantcontext.VariantContext vc)
    Adds variant to writer.
    boolean
     
    void
     
    protected htsjdk.variant.variantcontext.writer.VariantContextWriter
    Creates a writer for a new shard
    protected void
    Initializes a new sharded file.
    static String
    getShardFilename(Path basePath, int shardIndex)
    Gets filepath for the given shard and base path
    protected void
    Initializes shard header depending on which header function (set or write) was used
    void
    setHeader(htsjdk.variant.vcf.VCFHeader header)
    Defines header for the writer.
    void
    writeHeader(htsjdk.variant.vcf.VCFHeader header)
    Defines header for the writer that will be written to all shards.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • ShardingVCFWriter

      public ShardingVCFWriter(Path basePath, int maxVariantsPerShard, htsjdk.samtools.SAMSequenceDictionary dictionary, boolean createMD5, htsjdk.variant.variantcontext.writer.Options... options)
      Create a new sharding VCF writer
      Parameters:
      basePath - base path of the output VCFs. The shard designation and file extension will be added.
      maxVariantsPerShard - max number of records per file (last shard may have less)
      dictionary - sequence dictionary for this writer
      createMD5 - enable MD5 file creation
      options - vcf writer options
  • Method Details

    • createNextShard

      protected void createNextShard()
      Initializes a new sharded file.
    • initializeShardHeader

      protected void initializeShardHeader()
      Initializes shard header depending on which header function (set or write) was used
    • createNewWriter

      protected htsjdk.variant.variantcontext.writer.VariantContextWriter createNewWriter()
      Creates a writer for a new shard
      Returns:
      the new writer
    • getShardFilename

      public static String getShardFilename(Path basePath, int shardIndex)
      Gets filepath for the given shard and base path
      Parameters:
      basePath - path without extension
      shardIndex -
      Returns:
      path as String
    • setHeader

      public void setHeader(htsjdk.variant.vcf.VCFHeader header)
      Defines header for the writer. The header will not be written to any shards. May only be called once and only if writeHeader(htsjdk.variant.vcf.VCFHeader) has not been called.
      Specified by:
      setHeader in interface htsjdk.variant.variantcontext.writer.VariantContextWriter
      Parameters:
      header - header to use
    • writeHeader

      public void writeHeader(htsjdk.variant.vcf.VCFHeader header)
      Defines header for the writer that will be written to all shards. May only be called once and only if setHeader(htsjdk.variant.vcf.VCFHeader) has not been called.
      Specified by:
      writeHeader in interface htsjdk.variant.variantcontext.writer.VariantContextWriter
      Parameters:
      header - header to use
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface htsjdk.variant.variantcontext.writer.VariantContextWriter
    • checkError

      public boolean checkError()
      Specified by:
      checkError in interface htsjdk.variant.variantcontext.writer.VariantContextWriter
    • add

      public void add(htsjdk.variant.variantcontext.VariantContext vc)
      Adds variant to writer. Note that a header must be assigned first.
      Specified by:
      add in interface htsjdk.variant.variantcontext.writer.VariantContextWriter
      Parameters:
      vc - variant to write