Package vcf
Class RefGT
java.lang.Object
vcf.RefGT
- All Implemented Interfaces:
GT
Class RefGT
stores a list of samples and a
haplotype pair for each sample.
Instances of class BasicRefGT
are immutable.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
allele
(int marker, int haplotype) Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.get
(int marker) Returns theRefGTRec
for the specified marker.boolean
isPhased()
Returnstrue
if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalse
otherwise.boolean
Returnstrue
if the markers are ordered by decreasing chromosome base position, and returnsfalse
otherwise.marker
(int marker) Returns the specified marker.markers()
Returns the list of markers in order of increasing chromosome position.int
nHaps()
Returns the number of haplotypes.int
nMarkers()
Returns the number of markers.int
nSamples()
Returns the number of samples.restrict
(int start, int end) Returns a newGT
instance restricted to genotype data for the specified markers.Returns aGT
instance restricted to genotype data for the specified markers.static RefGT
Returns aRefGT
instance restricted to genotype data for the specified markers.samples()
Returns the list of samples.
-
Constructor Details
-
RefGT
Constructs a newRefGT
instance.- Parameters:
markers
- the sequence of markerssamples
- the sequence of samplesrefVcfRecs
- the sequence of per-marker genotype data- Throws:
IllegalArgumentException
- ifmarkers.nMarkers() != refVcfRecs.length
IllegalArgumentException
- ifrefVcfRecs[k].samples().equals(samples) == false
for anyk
satisfying0 <= k && k < refVcfRecs.length
IllegalArgumentException
- ifrefVcfRecs[k].marker().equals(markers.marker(k)) == false
for anyk
satisfying0 <= k && k < refVcfRecs.length
IllegalArgumentException
- ifrefVcfRecs[k].isPhased() == false
for anyk
satisfying0 <= k && k < refVcfRecs.length
NullPointerException
- ifmarkers == null || samples == null || refVcfRecs == null || refVcfRecs[k] == null
for anyk
satisfying0 <= k && k <= refVcfRecs.length
-
RefGT
Constructs a newRefHapPairs
instance.- Parameters:
refVcfRecs
- the sequence of per-marker genotype data- Throws:
IllegalArgumentException
- ifrefVcfRecs.length == 0
IllegalArgumentException
- ifrefVcfRecs[k].samples().equals(samples) == false
for anyk
satisfying0 <= k && k < refVcfRecs.length
IllegalArgumentException
- ifrefVcfRecs[k].isPhased() == false
for anyk
satisfying0 <= k && k < refVcfRecs.length
NullPointerException
- ifsamples == null || refVcfRecs == null
NullPointerException
- if(refVcfRecs[k] == null)
for anyk
satisfying(0 <= k && k <= refVcfRecs.length)
-
-
Method Details
-
isReversed
public boolean isReversed()Description copied from interface:GT
Returnstrue
if the markers are ordered by decreasing chromosome base position, and returnsfalse
otherwise.- Specified by:
isReversed
in interfaceGT
- Returns:
true
if the markers are ordered by decreasing chromosome base position
-
nMarkers
public int nMarkers()Description copied from interface:GT
Returns the number of markers. -
marker
Description copied from interface:GT
Returns the specified marker. -
markers
Description copied from interface:GT
Returns the list of markers in order of increasing chromosome position. If(this.isReversed() == false)
then(this.markers().marker(j).equals(this.marker(j)) == true)
for all(0 <= j && j < this.nMarkers())
. If(this.isReversed() == true)
then(this.markers().marker(this.nMarkers() - 1 - j).equals(this.marker(j)) == true)
for all(0 <= j && j < this.nMarkers())
-
nHaps
public int nHaps()Description copied from interface:GT
Returns the number of haplotypes. The returned value is equal to2*this.nSamples()
. -
nSamples
public int nSamples()Description copied from interface:GT
Returns the number of samples. -
samples
Description copied from interface:GT
Returns the list of samples. -
isPhased
public boolean isPhased()Description copied from interface:GT
Returnstrue
if the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalse
otherwise. -
allele
public int allele(int marker, int haplotype) Description copied from interface:GT
Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing. The order of the two alleles is unspecified ifthis.isPhased() == false
. -
restrict
Returns aRefGT
instance restricted to genotype data for the specified markers.- Parameters:
refGT
- theRefGT
instance to be restrictedindices
- a list of distinct marker indices (fromthis.markers())
in increasing order- Returns:
- a
RefGT
instance restricted to genotype data for the specified markers - Throws:
IndexOutOfBoundsException
- if there existsj
such that(0 <= j && j < indices.length)
such that(indices[j] < 0 || indices[j] >= gt.nMarkers())
IllegalArgumentException
- if there existsj
such that(1 <= j && j < indices.length)
such that(indices[j] <= indice[j - 1])
NullPointerException
- ifgt == null || indices == null
-
restrict
Description copied from interface:GT
Returns aGT
instance restricted to genotype data for the specified markers. -
restrict
Description copied from interface:GT
Returns a newGT
instance restricted to genotype data for the specified markers. -
get
Returns theRefGTRec
for the specified marker.- Parameters:
marker
- the marker index- Returns:
- the
RefGTRec
for the specified marker - Throws:
IndexOutOfBoundsException
- ifmarker < 0 || marker >= this.nMarkers()
-