public class WindowWriter
extends java.lang.Object
implements java.io.Closeable
Class WindowWriter
writes VCF and IBD output data.
Instances of class WindowWriter
are not thread-safe.
Constructor and Description |
---|
WindowWriter(Samples samples,
java.lang.String outPrefix)
Constructs a new
WindowWriter object. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this
WindowWriter for writing. |
boolean |
isClosed()
Returns
true if this.close() method has
been previously invoked and returns false otherwise. |
void |
print(CurrentData cd,
AlleleProbs alProbs,
boolean imputed,
boolean gprobs)
Prints the data in
alProbs for markers
with index between cd.lastSplice() (inclusive) and
cd.nextSplice() (exclusive). |
void |
printGV(CurrentData cd,
GenotypeValues gv)
Prints VCF records with GT and GP format fields for markers with
index between
cd.lastSplice() (inclusive) and
cd.nextSplice() (exclusive). |
void |
printIbd(CurrentData cd,
java.util.Map<IntPair,java.util.List<IbdSegment>> ibdMap)
Prints IBD segments that end between the markers
with index between
cd.lastSplice() (inclusive) and
cd.nextSplice() (exclusive). |
Samples |
samples()
Returns the samples whose data is written by
this . |
public WindowWriter(Samples samples, java.lang.String outPrefix)
WindowWriter
object.samples
- the sample whose data will be printedoutPrefix
- the output file prefixjava.lang.IllegalArgumentException
- if outPrefix.length() == 0
java.lang.NullPointerException
- if
samples == null || outPrefix == null
public Samples samples()
this
.this
public boolean isClosed()
true
if this.close()
method has
been previously invoked and returns false
otherwise.true
if this.close()
method has
been previously invokedpublic void close()
WindowWriter
for writing. Calling the
print()
method after invoking close()
will
throw an IllegalStateException
.close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
public void printGV(CurrentData cd, GenotypeValues gv)
cd.lastSplice()
(inclusive) and
cd.nextSplice()
(exclusive).cd
- the input data for the current marker windowgv
- scaled genotype probabilities for the target samplesjava.lang.NullPointerException
- if cd == null || gv == null
public void print(CurrentData cd, AlleleProbs alProbs, boolean imputed, boolean gprobs)
alProbs
for markers
with index between cd.lastSplice()
(inclusive) and
cd.nextSplice()
(exclusive).cd
- the input data for the current marker windowalProbs
- the estimated haplotype allele probabilitiesimputed
- true
if there are imputed markers,
and false
otherwisegprobs
- true
if the GP field should be printed, and
false
otherwisejava.lang.IllegalStateException
- if this.isClosed() == true
java.lang.IllegalArgumentException
- if
this.samples().equals(cd.targetSamples()) == false
java.lang.IllegalArgumentException
- if
this.samples().equals(alProbs.samples()) == false
java.lang.IllegalArgumentException
- if
cd.markers().equals(alProbs.markers()) == false
java.lang.NullPointerException
- if cd == null || alProbs == null
public void printIbd(CurrentData cd, java.util.Map<IntPair,java.util.List<IbdSegment>> ibdMap)
cd.lastSplice()
(inclusive) and
cd.nextSplice()
(exclusive).
IBD segments that end on or after the marker with index
cd.nextSplice()
are saved so that they can be merged
with IBD segments from the next marker window.
It is the the caller's responsibility to ensure that the ordered haplotype pairs between adjacent consecutive markers windows are identical for each sample.
cd
- the input data for the current windowibdMap
- a map whose keys are pairs of haplotype indices and whose
values are lists of IBD segments involving the haplotype pair keyjava.lang.IllegalStateException
- if this.isClosed()==true
java.lang.IllegalArgumentException
- if
this.samples().equals(cd.targetSamples()) == false
java.lang.NullPointerException
- if cd == null || ibdMap == null