Package vcf

Class VcfIt<E extends MarkerContainer>

  • Type Parameters:
    E - the type parameter
    All Implemented Interfaces:
    FileIt<E>, SampleFileIt<E>, java.io.Closeable, java.lang.AutoCloseable, java.util.Iterator<E>

    public class VcfIt<E extends MarkerContainer>
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      static int MAX_EM_BUFFER_SIZE
      The default number of VCF records stored in a buffer, which is 1000.
      static java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toBitSetGT
      A function mapping a string VCF record with GT format fields to a GTRec object.
      static java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toGLRec
      A function mapping a string VCF record with GL format fields to a VcfRecord object.
      static java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toGTGLRec
      A function mapping a string VCF record with GT or GL format fields to a VcfRecord object.
      static java.util.function.BiFunction<VcfHeader,​java.lang.String,​VcfRec> toVcfRecord
      A function mapping a string VCF record with GT or GL format fields to a VcfRecord object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Terminates the iteration and releases any system resources that are held by this object.
      static <R extends GTRec>
      VcfIt<R>
      create​(FileIt<java.lang.String> strIt, Filter<java.lang.String> sampleFilter, Filter<Marker> markerFilter, java.util.function.BiFunction<VcfHeader,​java.lang.String,​R> recMapper)
      Create and returns a new VcfIt instance from the specified objects.
      static <R extends GTRec>
      VcfIt<R>
      create​(FileIt<java.lang.String> strIt, Filter<java.lang.String> sampleFilter, Filter<Marker> markerFilter, java.util.function.BiFunction<VcfHeader,​java.lang.String,​R> recMapper, int bufferSize)
      Create and returns a new VcfIt instance from the specified objects.
      static <R extends GTRec>
      VcfIt<R>
      create​(FileIt<java.lang.String> strIt, Filter<java.lang.String> sampleFilter, java.util.function.BiFunction<VcfHeader,​java.lang.String,​R> recMapper)
      Create and returns a new VcfIt instance from the specified objects.
      static <R extends GTRec>
      VcfIt<R>
      create​(FileIt<java.lang.String> strIt, java.util.function.BiFunction<VcfHeader,​java.lang.String,​R> recMapper)
      Create and returns a new VcfIt instance from the specified objects.
      java.io.File file()
      Returns the file from which the data are read, or null if the data are read from standard input or are computed data.
      boolean hasNext()
      Returns true if the iteration has more elements, and returns false otherwise.
      E next()
      Returns the next element in the iteration.
      void remove()
      The remove method is not supported by this iterator.
      Samples samples()
      Returns the list of samples.
      java.lang.String toString()
      Returns a string representation of this.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Field Detail

      • MAX_EM_BUFFER_SIZE

        public static final int MAX_EM_BUFFER_SIZE
        The default number of VCF records stored in a buffer, which is 1000.
        See Also:
        Constant Field Values
      • toBitSetGT

        public static final java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toBitSetGT
        A function mapping a string VCF record with GT format fields to a GTRec object.
      • toGLRec

        public static final java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toGLRec
        A function mapping a string VCF record with GL format fields to a VcfRecord object.
      • toGTGLRec

        public static final java.util.function.BiFunction<VcfHeader,​java.lang.String,​GTRec> toGTGLRec
        A function mapping a string VCF record with GT or GL format fields to a VcfRecord object.
      • toVcfRecord

        public static final java.util.function.BiFunction<VcfHeader,​java.lang.String,​VcfRec> toVcfRecord
        A function mapping a string VCF record with GT or GL format fields to a VcfRecord object.
    • Method Detail

      • create

        public static <R extends GTRecVcfIt<R> create​(FileIt<java.lang.String> strIt,
                                                        java.util.function.BiFunction<VcfHeader,​java.lang.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:
        java.lang.IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
        java.lang.NullPointerException - if strIt == null || recMapper == null
      • create

        public static <R extends GTRecVcfIt<R> create​(FileIt<java.lang.String> strIt,
                                                        Filter<java.lang.String> sampleFilter,
                                                        java.util.function.BiFunction<VcfHeader,​java.lang.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
        recMapper - a function mapping string VCF records to GTRec objects
        Returns:
        a new VcfIt instance
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
        java.lang.NullPointerException - if strIt == null || recMapper == null
      • create

        public static <R extends GTRecVcfIt<R> create​(FileIt<java.lang.String> strIt,
                                                        Filter<java.lang.String> sampleFilter,
                                                        Filter<Marker> markerFilter,
                                                        java.util.function.BiFunction<VcfHeader,​java.lang.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:
        java.lang.IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
        java.lang.NullPointerException - if strIt == null || recMapper == null
      • create

        public static <R extends GTRecVcfIt<R> create​(FileIt<java.lang.String> strIt,
                                                        Filter<java.lang.String> sampleFilter,
                                                        Filter<Marker> markerFilter,
                                                        java.util.function.BiFunction<VcfHeader,​java.lang.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 buffer size
        Returns:
        a new VcfIt instance
        Throws:
        java.lang.IllegalArgumentException - if a format error is detected in a line of a VCF file returned by strIt
        java.lang.IllegalArgumentException - if bufferSize < 1
        java.lang.NullPointerException - if strIt == null || recMapper == null
      • close

        public void close()
        Description copied from interface: FileIt
        Terminates the iteration and releases any system resources that are held by this object. After invoking close(), further invocations of close() have no effect.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface FileIt<E extends MarkerContainer>
      • hasNext

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

        public E next()
        Returns the next element in the iteration.
        Specified by:
        next in interface java.util.Iterator<E extends MarkerContainer>
        Returns:
        the next element in the iteration
        Throws:
        java.util.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 java.util.Iterator<E extends MarkerContainer>
        Throws:
        java.lang.UnsupportedOperationException - if this method is invoked
      • file

        public java.io.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 are computed data.
        Specified by:
        file in interface FileIt<E extends MarkerContainer>
        Returns:
        the file from which the data are read, or null if the data are read from standard input or are computed data
      • toString

        public java.lang.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 MarkerContainer>
        Overrides:
        toString in class java.lang.Object
        Returns:
        a string representation of this