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 intThe default number of VCF records stored in a buffer.static final BiFunction<VcfHeader, String, GTRec> A function mapping a string VCF record with GT format fields to aGTRecobject.static final BiFunction<VcfHeader, String, GTRec> A function mapping a string VCF record with GT format fields to a memory-efficientGTRecobject.static final BiFunction<VcfHeader, String, VcfRec> A function mapping a string VCF record with GT or GL format fields to aVcfRecordobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Stops reading data elements and releases any system resources that are held by this object.create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, BiFunction<VcfHeader, String, R> recMapper) Create and returns a newVcfItinstance from the specified objects.create(FileIt<String> strIt, Filter<String> sampleFilter, Filter<Marker> markerFilter, BiFunction<VcfHeader, String, R> recMapper, int bufferSize) Create and returns a newVcfItinstance from the specified objects.Create and returns a newVcfItinstance from the specified objects.file()Returns the file from which the data are read, ornullif the data are read from standard input or if the data source is unknown.booleanhasNext()Returnstrueif the iteration has more elements, and returnsfalseotherwise.next()Returns the next element in the iteration.voidremove()Theremovemethod 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, waitMethods 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-efficientGTRecobject. 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 with GT format fields to aGTRecobject. Phase status is stored per-genotype. -
TO_VCF_REC
A function mapping a string VCF record with GT or GL format fields to aVcfRecordobject.
-
-
Method Details
-
create
public static <R extends GTRec> VcfIt<R> create(FileIt<String> strIt, BiFunction<VcfHeader, String, R> recMapper) Create and returns a newVcfItinstance 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 toGTRecobjects- Returns:
- a new
VcfItinstance - Throws:
IllegalArgumentException- if a format error is detected in a line of a VCF file returned bystrItNullPointerException- ifstrIt == 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 newVcfItinstance 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 ornullmarkerFilter- a marker filter ornullrecMapper- a function mapping string VCF records toGTRecobjects- Returns:
- a new
VcfItinstance - Throws:
IllegalArgumentException- if a format error is detected in a line of a VCF file returned bystrItNullPointerException- ifstrIt == 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 newVcfItinstance 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 ornullmarkerFilter- a marker filter ornullrecMapper- a function mapping string VCF records toGTRecobjectsbufferSize- the requested buffer size- Returns:
- a new
VcfItinstance - Throws:
IllegalArgumentException- if a format error is detected in a line of a VCF file returned bystrItIllegalArgumentException- ifbufferSize < 1NullPointerException- ifstrIt == null || mapFactory == null
-
close
public void close()Description copied from interface:FileItStops 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()Returnstrueif the iteration has more elements, and returnsfalseotherwise. -
next
Returns the next element in the iteration.- Specified by:
nextin interfaceIterator<E extends GTRec>- Returns:
- the next element in the iteration
- Throws:
NoSuchElementException- if the iteration has no more elements.
-
remove
public void remove()Theremovemethod is not supported by this iterator.- Specified by:
removein interfaceIterator<E extends GTRec>- Throws:
UnsupportedOperationException- if this method is invoked
-
file
Description copied from interface:FileItReturns the file from which the data are read, ornullif the data are read from standard input or if the data source is unknown. -
samples
Description copied from interface:SampleFileItReturns the list of samples.- Specified by:
samplesin interfaceSampleFileIt<E extends GTRec>- Returns:
- the list of samples
-
vcfHeader
Description copied from interface:VcfFileItReturns the VCF meta-information lines and header line -
toString
Description copied from interface:FileItReturns a string representation ofthis. The exact details of the representation are unspecified and subject to change.
-