Package vcf

Class VcfWriter

java.lang.Object
vcf.VcfWriter

public final class VcfWriter extends Object

Class VcfWriter contains static methods for writing data in VCF 4.2 format.

Instances of class VcfWriter are not thread-safe.

  • Method Details

    • writeMetaLinesGT

      public static void writeMetaLinesGT(String[] sampleIds, String source, PrintWriter out)
      Writes VCF meta-information lines and header line to the specified PrintWriter. Only one FORMAT subfield, the GT subfield, is described in the meta-information lines.
      Parameters:
      sampleIds - the sample identifiers
      source - a description of the data source, or null if no description is to be printed
      out - the PrintWriter to which VCF meta-information lines will be written
      Throws:
      NullPointerException - if out == null
      NullPointerException - if sampleIds == null, or if sampleIds[j] == null for any j satisfying (0 <= j && j < <sampleIds.length)
    • writeMetaLines

      public static void writeMetaLines(String[] sampleIds, String source, boolean ds, boolean ap, boolean gp, boolean gl, PrintWriter out)
      Writes VCF meta-information lines and header line to the specified PrintWriter.
      Parameters:
      sampleIds - the sample identifiers
      source - a description of the data source, or null if no description is to be printed
      ds - { @code true} if the meta-information lines will describe the DS FORMAT subfield and false otherwise
      ap - true if the meta-information lines will describe the AP1 and AP2 FORMAT subfields and false otherwise
      gp - true if the meta-information lines will describe the GP FORMAT subfield and false otherwise
      gl - true if the meta-information lines will describe the GL FORMAT subfield and false otherwise
      out - the PrintWriter to which VCF meta-information lines will be written.
      Throws:
      NullPointerException - if out == null
      NullPointerException - if sampleIds == null, or if sampleIds[j] == null for any j satisfying (0 <= j && j < sampleIds.length)
    • appendRecords

      public static void appendRecords(GT phasedTarg, int start, int end, PrintWriter out)
      Writes the data in phased genotypes for the specified markers to the specified PrintWriter.
      Parameters:
      phasedTarg - the estimated haplotype allele probabilities
      start - the starting marker index (inclusive)
      end - the ending marker index (exclusive)
      out - the PrintWriter to which VCF records will be written
      Throws:
      IllegalArgumentException - if phasedTarg.isPhased() == false
      IndexOutOfBoundsException - if (start < 0 || start > end || end > phasedTarg.nMarkers())
      NullPointerException - if phasedTarg == null || out == null
    • appendRecords

      public static void appendRecords(Samples samples, GTRec[] recs, PrintWriter out)
      Writes the data in phased genotypes for the specified markers to the specified PrintWriter.
      Parameters:
      samples - the list of samples
      recs - the estimated haplotype allele probabilities
      out - the PrintWriter to which VCF records will be written
      Throws:
      IllegalArgumentException - if phasedTarg.isPhased() == false
      IndexOutOfBoundsException - if (start < 0 || start > end || end > phasedTarg.nMarkers())
      NullPointerException - if phasedTarg == null || out == null
    • printFixedFieldsGT

      public static void printFixedFieldsGT(Marker marker, PrintWriter out)
      Prints the first 9 VCF record fields for the specified marker to the specified PrintWriter. Only one VCF FORMAT subfield, the GT subfield, is printed.
      Parameters:
      marker - a marker
      out - the PrintWriter to which the first 9 VCF record fields will be written
      Throws:
      NullPointerException - if marker == null || out == null