java.lang.Object
vcf.VcfIt<E>
- Type Parameters:
E
- the type parameter
- All Implemented Interfaces:
FileIt<E>
,SampleFileIt<E>
,VcfFileIt<E>
,Closeable
,AutoCloseable
,Iterator<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
FieldsModifier and TypeFieldDescriptionstatic final int
The default number of VCF records stored in a buffer.static final TriFunction
<VcfHeader, String, MarkerParser, GTRec> A function mapping a string VCF record to aBasicGTRec
object.static final TriFunction
<VcfHeader, String, MarkerParser, GTRec> A function mapping a string VCF record with GT format fields to a memory-efficientGTRec
object.static final TriFunction
<VcfHeader, String, MarkerParser, VcfRec> A function mapping a string VCF record to aVcfRec
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the input stream and releases any system resources that are associated with it.create
(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, TriFunction<VcfHeader, String, MarkerParser, R> recMapper) Create and returns a newVcfIt
instance from the specified objects.create
(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, TriFunction<VcfHeader, String, MarkerParser, R> recMapper, int bufferSize) Create and returns a newVcfIt
instance from the specified objects.create
(FileIt<String> strIt, TriFunction<VcfHeader, String, MarkerParser, R> recMapper) Create and returns a newVcfIt
instance from the specified objects.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.static String[]
Returns an array containing VCF meta-information lines, the VCF header line, and the first VCF data line.next()
Returns the next element in the iteration.void
remove()
Theremove
method is not supported by this iterator.samples()
Returns the list of samples.toString()
Returns a string representation ofthis
.Returns the VCF meta-information lines and header lineMethods 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 Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default number of VCF records stored in a buffer.- See Also:
-
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
A function mapping a string VCF record to aBasicGTRec
object. Phase status is stored per-genotype. -
TO_VCF_REC
A function mapping a string VCF record to aVcfRec
object.
-
-
Method Details
-
head
Returns an array containing VCF meta-information lines, the VCF header line, and the first VCF data line. The returned array will contain all initial lines that begin with the '#' character and the next line.- Parameters:
src
- a string describing the source of the VCF fileit
- an iterator that returns the lines of a VCF file- Returns:
- an array containing VCF meta-information lines, the VCF header line, and the first VCF data line
- Throws:
NullPointerException
- ifit == null
IllegalArgumentException
- if all lines returned by the iterator begin with the '#' character
-
create
public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, TriFunction<VcfHeader, String, MarkerParser, 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:
IllegalArgumentException
- if a format error is detected in a line of a VCF file returned bystrIt
NullPointerException
- ifstrIt == null || mapFactory == null
-
create
public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, TriFunction<VcfHeader, String, MarkerParser, 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:
IllegalArgumentException
- if a format error is detected in a line of a VCF file returned bystrIt
NullPointerException
- ifstrIt == null || mapFactory == null
-
create
public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, TriFunction<VcfHeader, String, MarkerParser, 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:
IllegalArgumentException
- if a format error is detected in a line of a VCF file returned bystrIt
IllegalArgumentException
- ifbufferSize < 1
NullPointerException
- ifstrIt == null || mapFactory == null
-
close
public void close()Description copied from interface:FileIt
Closes the input stream and releases any system resources that are associated with it. If the input stream is already closed then invoking this method has no effect. -
hasNext
public boolean hasNext()Returnstrue
if the iteration has more elements, and returnsfalse
otherwise. -
next
Returns the next element in the iteration.- Specified by:
next
in interfaceIterator<E extends GTRec>
- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException
- if the iteration has no more elements.
-
remove
public void remove()Theremove
method is not supported by this iterator.- Specified by:
remove
in interfaceIterator<E extends GTRec>
- Throws:
UnsupportedOperationException
- if this method is invoked
-
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
Description copied from interface:SampleFileIt
Returns the list of samples.- Specified by:
samples
in interfaceSampleFileIt<E extends GTRec>
- Returns:
- the list of samples
-
vcfHeader
Description copied from interface:VcfFileIt
Returns the VCF meta-information lines and header line -
toString
Description copied from interface:FileIt
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.
-