Package vcf

Class VcfIt<E extends GTRec>

java.lang.Object
vcf.VcfIt<E>
Type Parameters:
E - the type parameter
All Implemented Interfaces:
FileIt<E>, SampleFileIt<E>, Closeable, AutoCloseable, Iterator<E>

public class VcfIt<E extends GTRec> extends Object implements SampleFileIt<E>

Class VcfIt represents an iterator whose next() method returns an object storing data from a VCF record.

Instances of class VcfIt are not thread-safe.

Methods of this class will terminate the Java Virtual Machine with an error message if an I/O error or file format error is detected.

  • Field Details

    • DEFAULT_BUFFER_SIZE

      public static final int DEFAULT_BUFFER_SIZE
      The default number of VCF records stored in a buffer.
      See Also:
    • TO_LOWMEM_GT_REC

      public static final BiFunction<VcfHeader,String,GTRec> TO_LOWMEM_GT_REC
      A function mapping a string VCF record with GT format fields to a memory-efficient GTRec object. Phase status is stored per record. All genotypes are considered to be unphased if any genotype is unphased or if any allele is missing.
    • TO_BASIC_GT_REC

      public static final BiFunction<VcfHeader,String,GTRec> TO_BASIC_GT_REC
      A function mapping a string VCF record with GT format fields to a GTRec object. Phase status is stored per-genotype.
    • TO_VCF_REC

      public static final BiFunction<VcfHeader,String,VcfRec> TO_VCF_REC
      A function mapping a string VCF record with GT or GL format fields to a VcfRecord object.
  • Method Details

    • create

      public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, BiFunction<VcfHeader,String,R> recMapper)
      Create and returns a new VcfIt instance from the specified objects.
      Type Parameters:
      R - the type returned by the returned VcfIt
      Parameters:
      strIt - an iterator that returns lines of a VCF file
      recMapper - a function mapping string VCF records to GTRec objects
      Returns:
      a new VcfIt instance
      Throws:
      IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
      NullPointerException - if strIt == null || mapFactory == null
    • create

      public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, BiFunction<VcfHeader,String,R> recMapper)
      Create and returns a new VcfIt instance from the specified objects.
      Type Parameters:
      R - the type returned by the returned VcfIt
      Parameters:
      strIt - an iterator that returns lines of a VCF file
      sampleFilter - a sample filter or null
      markerFilter - a marker filter or null
      recMapper - a function mapping string VCF records to GTRec objects
      Returns:
      a new VcfIt instance
      Throws:
      IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
      NullPointerException - if strIt == null || mapFactory == null
    • create

      public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, BiFunction<VcfHeader,String,R> recMapper, int bufferSize)
      Create and returns a new VcfIt instance from the specified objects.
      Type Parameters:
      R - the type returned by the returned VcfIt
      Parameters:
      strIt - an iterator that returns lines of a VCF file
      sampleFilter - a sample filter or null
      markerFilter - a marker filter or null
      recMapper - a function mapping string VCF records to GTRec objects
      bufferSize - the requested buffer size
      Returns:
      a new VcfIt instance
      Throws:
      IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
      IllegalArgumentException - if bufferSize < 1
      NullPointerException - if strIt == null || mapFactory == null
    • close

      public void close()
      Description copied from interface: FileIt
      Stops reading data elements and releases any system resources that are held by this object. Buffered data elements may remain accessible via the hasNext() and next() methods after invoking close(). After invoking close(), further invocations of close() have no effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface FileIt<E extends GTRec>
    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements, and returns false otherwise.
      Specified by:
      hasNext in interface Iterator<E extends GTRec>
      Returns:
      true if the iteration has more elements
    • next

      public E next()
      Returns the next element in the iteration.
      Specified by:
      next in interface Iterator<E extends GTRec>
      Returns:
      the next element in the iteration
      Throws:
      NoSuchElementException - if the iteration has no more elements.
    • remove

      public void remove()
      The remove method is not supported by this iterator.
      Specified by:
      remove in interface Iterator<E extends GTRec>
      Throws:
      UnsupportedOperationException - if this method is invoked
    • file

      public File file()
      Description copied from interface: FileIt
      Returns the file from which the data are read, or null if the data are read from standard input or if the data source is unknown.
      Specified by:
      file in interface FileIt<E extends GTRec>
      Returns:
      the file from which the data are read, or null if the data are read from standard input or if the data source is unknown
    • samples

      public Samples samples()
      Description copied from interface: SampleFileIt
      Returns the list of samples.
      Specified by:
      samples in interface SampleFileIt<E extends GTRec>
      Returns:
      the list of samples
    • toString

      public String toString()
      Description copied from interface: FileIt
      Returns a string representation of this. The exact details of the representation are unspecified and subject to change.
      Specified by:
      toString in interface FileIt<E extends GTRec>
      Overrides:
      toString in class Object
      Returns:
      a string representation of this