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() |
java.lang.String |
outPrefix()
Returns the output file prefix.
|
void |
print(AlleleProbs alProbs,
boolean[] isImputed,
int start,
int end,
boolean dose,
boolean gprobs,
int nThreads)
Prints the data in
alProbs for markers
with index between cd.lastSplice() (inclusive) and
cd.nextSplice() (exclusive) to the output
VCF file: this.outPrefix() + ".vcf.gz" . |
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 java.lang.String outPrefix()
public Samples samples()
this
.this
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(AlleleProbs alProbs, boolean[] isImputed, int start, int end, boolean dose, boolean gprobs, int nThreads)
alProbs
for markers
with index between cd.lastSplice()
(inclusive) and
cd.nextSplice()
(exclusive) to the output
VCF file: this.outPrefix() + ".vcf.gz"
.alProbs
- the estimated haplotype allele probabilitiesisImputed
- an array of length alProbs.nMarkers()
whose j
-th element is true
if the corresponding
marker is imputed, and false
otherwisestart
- the starting marker index (inclusive)end
- the ending marker index (exclusive)dose
- true
if the output FORMAT fields should contain
a DS subfield, and false
otherwisegprobs
- true
if the output FORMAT fields should contain
a GP subfield, and false
otherwisenThreads
- the number of parallel threads to usejava.lang.IllegalArgumentException
- if
isImputed.length != alProbs.nMarkers()
java.lang.IllegalArgumentException
- if nThreads < 1
java.lang.IndexOutOfBoundsException
- if
start < 0 || end > alProbs.nMarkers() || start > end
java.lang.NullPointerException
- if
alProbs == null || isImputed == 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.IllegalArgumentException
- if
this.samples().equals(cd.targetSamples()) == false
java.lang.NullPointerException
- if cd == null || ibdMap == null
public void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable