- java.lang.Object
-
- vcf.VcfIt<E>
-
- 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 GTRec> extends java.lang.Object implements SampleFileIt<E>
Class
VcfIt
represents an iterator whosenext()
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
DEFAULT_BUFFER_SIZE
The default number of VCF records stored in a buffer.static java.util.function.BiFunction<VcfHeader,java.lang.String,GTRec>
TO_BASIC_GT_REC
A function mapping a string VCF record with GT format fields to aGTRec
object.static java.util.function.BiFunction<VcfHeader,java.lang.String,GTRec>
TO_LOWMEM_GT_REC
A function mapping a string VCF record with GT format fields to a memory-efficientGTRec
object.static java.util.function.BiFunction<VcfHeader,java.lang.String,VcfRec>
TO_VCF_REC
A function mapping a string VCF record with GT or GL format fields to aVcfRecord
object.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Stops reading data elements 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 newVcfIt
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 newVcfIt
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 newVcfIt
instance from the specified objects.java.io.File
file()
Returns the file from which the data are read, ornull
if the data are read from standard input or if the data source is unknown.boolean
hasNext()
Returnstrue
if the iteration has more elements, and returnsfalse
otherwise.E
next()
Returns the next element in the iteration.void
remove()
Theremove
method is not supported by this iterator.Samples
samples()
Returns the list of samples.java.lang.String
toString()
Returns a string representation ofthis
.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default number of VCF records stored in a buffer.- See Also:
- Constant Field Values
-
TO_LOWMEM_GT_REC
public static final java.util.function.BiFunction<VcfHeader,java.lang.String,GTRec> TO_LOWMEM_GT_REC
A function mapping a string VCF record with GT format fields to a memory-efficientGTRec
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 java.util.function.BiFunction<VcfHeader,java.lang.String,GTRec> TO_BASIC_GT_REC
A function mapping a string VCF record with GT format fields to aGTRec
object. Phase status is stored per-genotype.
-
-
Method Detail
-
create
public 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 newVcfIt
instance from the specified objects.- Type Parameters:
R
- the type returned by the returnedVcfIt
- Parameters:
strIt
- an iterator that returns lines of a VCF filerecMapper
- a function mapping string VCF records toGTRec
objects- Returns:
- a new
VcfIt
instance - Throws:
java.lang.IllegalArgumentException
- if a format error is detected in a line of a VCF file returned bystrIt
java.lang.NullPointerException
- ifstrIt == null || mapFactory == null
-
create
public 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 newVcfIt
instance from the specified objects.- Type Parameters:
R
- the type returned by the returnedVcfIt
- Parameters:
strIt
- an iterator that returns lines of a VCF filesampleFilter
- a sample filter ornull
markerFilter
- a marker filter ornull
recMapper
- a function mapping string VCF records toGTRec
objects- Returns:
- a new
VcfIt
instance - Throws:
java.lang.IllegalArgumentException
- if a format error is detected in a line of a VCF file returned bystrIt
java.lang.NullPointerException
- ifstrIt == null || mapFactory == null
-
create
public 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 newVcfIt
instance from the specified objects.- Type Parameters:
R
- the type returned by the returnedVcfIt
- Parameters:
strIt
- an iterator that returns lines of a VCF filesampleFilter
- a sample filter ornull
markerFilter
- a marker filter ornull
recMapper
- a function mapping string VCF records toGTRec
objectsbufferSize
- the requested 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 bystrIt
java.lang.IllegalArgumentException
- ifbufferSize < 1
java.lang.NullPointerException
- ifstrIt == 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 thehasNext()
andnext()
methods after invokingclose()
. After invokingclose()
, further invocations ofclose()
have no effect.
-
hasNext
public boolean hasNext()
Returnstrue
if the iteration has more elements, and returnsfalse
otherwise.
-
next
public E next()
Returns the next element in the iteration.
-
remove
public void remove()
Theremove
method is not supported by this iterator.
-
file
public java.io.File file()
Description copied from interface:FileIt
Returns the file from which the data are read, ornull
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 interfaceSampleFileIt<E extends GTRec>
- Returns:
- the list of samples
-
toString
public java.lang.String toString()
Description copied from interface:FileIt
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.
-
-