Class VcfParser

java.lang.Object
org.pharmgkb.parser.vcf.VcfParser
All Implemented Interfaces:
Closeable, AutoCloseable

public class VcfParser extends Object implements Closeable
This class parses a VCF file.
  • Method Details

    • parseMetadata

      @Nonnull public VcfMetadata parseMetadata() throws IOException
      Parses metadata only. This method should be if only the metadata is needed; otherwise, parse() is preferred.
      Throws:
      IOException
    • getMetadata

      @Nullable public VcfMetadata getMetadata()
      Gets VCF metadata (if it has already been parsed).
    • parse

      public void parse() throws IOException
      Parses the entire VCF file (including the metadata).

      This is the preferred way to read a VCF file.

      Throws:
      IOException
    • parseNextLine

      public boolean parseNextLine() throws IOException, VcfFormatException
      Parses just the next data line available, also reading all the metadata if it has not been read. This is a specialized method; in general calling parse() to parse the entire stream is preferred.
      Returns:
      Whether another line may be available to read; false only if and only if this is the last line available
      Throws:
      IllegalStateException - If the stream was already fully parsed
      VcfFormatException - If a VCF formatting error is found
      IOException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • getLineNumber

      public int getLineNumber()