- java.lang.Object
-
- vcf.WindowIt<E>
-
- Type Parameters:
E
- the type of elements in the window corresponding to this window iterator.
- All Implemented Interfaces:
FileIt<Window<E>>
,SampleFileIt<Window<E>>
,java.io.Closeable
,java.lang.AutoCloseable
,java.util.Iterator<Window<E>>
public class WindowIt<E extends GTRec> extends java.lang.Object implements SampleFileIt<Window<E>>
Class
WindowIt
represents a sliding window of VCF recList.Instances of class
WindowIt
are not thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases any I/O resources controlled by this object.java.io.File
file()
Returns the file from which VCF recList are read, or returnsnull
if the source is standard input.GeneticMap
genMap()
Returns the genetic map.boolean
hasNext()
Returnstrue
if the sliding window of VCF recList can advance and returnsfalse
otherwise.static <E extends GTRec>
WindowIt<E>newInstance(java.util.function.Supplier<SampleFileIt<E>> supplier, GeneticMap genMap, float windowCM, float overlapCM)
Constructs and returns a newWindowIt
instance for the specified data.Window<E>
next()
Advances the sliding window of VCF recList, and returns the advanced window as aRefGTRec[]
object.Samples
samples()
Returns the list of samples.java.lang.String
toString()
Returns a string representation ofthis
.
-
-
-
Method Detail
-
newInstance
public static <E extends GTRec> WindowIt<E> newInstance(java.util.function.Supplier<SampleFileIt<E>> supplier, GeneticMap genMap, float windowCM, float overlapCM)
Constructs and returns a newWindowIt
instance for the specified data.- Type Parameters:
E
- the type of elements in windows for the returned window iterator.- Parameters:
supplier
- the object which supplies theSampleFileIt
which reads input datagenMap
- the genetic mapwindowCM
- the requested window length in cMoverlapCM
- the requested overlap in cM between consecutive windows on the same chromosome- Returns:
- a new
WindowIt
instance for the specified data - Throws:
java.lang.IllegalArgumentException
- if a format error is detected in the input filejava.lang.IllegalArgumentException
- ifoverlap < 0 || Float.isFinite(overlap) == false
java.lang.IllegalArgumentException
- ifwindow <= overlap || Float.isFinite(window) == false
java.lang.NullPointerException
- ifit == null || genMap == null
-
genMap
public GeneticMap genMap()
Returns the genetic map.- Returns:
- the genetic map
-
hasNext
public boolean hasNext()
Returnstrue
if the sliding window of VCF recList can advance and returnsfalse
otherwise.
-
next
public Window<E> next()
Advances the sliding window of VCF recList, and returns the advanced window as aRefGTRec[]
object.- Specified by:
next
in interfacejava.util.Iterator<E extends GTRec>
- Returns:
- the advanced window of VCF recList
- Throws:
java.lang.IllegalArgumentException
- if a format error in the input data is detectedjava.lang.IllegalArgumentException
- ifwindowCm <= this.overlap() || Float.isFinite(windowCm) == false
java.lang.IllegalStateException
- ifthis.canAdvanceWindow() == false
-
file
public java.io.File file()
Returns the file from which VCF recList are read, or returnsnull
if the source is standard input.
-
samples
public Samples samples()
Returns the list of samples.- Specified by:
samples
in interfaceSampleFileIt<E extends GTRec>
- Returns:
- the list of samples
-
close
public void close()
Releases any I/O resources controlled by this object.
-
toString
public java.lang.String toString()
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.
-
-