Package vcf
Class XRefGT
java.lang.Object
vcf.XRefGT
- All Implemented Interfaces:
GT
Class XRefGT
represents phased, non-missing genotypes for a list
of samples that are stored in column-major (i.e. haplotype-major) order.
Instances of class XRefGT
are immutable.
-
Method Summary
Modifier and TypeMethodDescriptionint
allele
(int marker, int hap) Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.static XRefGT
Returns a newXRefGT
instance from the specified data.void
Copies the specified bit sequence to the specifiedbitList
static XRefGT
from
(Samples samples, AtomicReferenceArray<SamplePhase> phase) Returns a newXRefGT
instance from the specified data.static XRefGT
fromPhasedGT
(GT gt, int nThreads) Returns a newXRefGT
instance from the specified data.int
hash
(int hap, int start, int end) Returns a hash code for the specified alleles.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 markerIndex) 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.samples()
Returns the list of samples.toString()
-
Method Details
-
combine
Returns a newXRefGT
instance from the specified data. The order of samples and haplotypes is preserved. Samples in the firstXRefGT
parameter are placed before samples in the secondXRefGT
parameter in the returnedXRefGT
instance.- Parameters:
first
- phased genotype data for a list of samplessecond
- phased genotype data for a list of samples- Returns:
- a new
XRefGT
instance - Throws:
NullPointerException
- iffirst == null || second == null
IllegalArgumentException
- if the lists of samples in the two specifiedXRefGT
parameters are not disjointIllegalArgumentException
- iffirst.markers().equals(second.markers()) == false
-
from
Returns a newXRefGT
instance from the specified data.- Parameters:
samples
- the list of samplesphase
- the phased genotypes- Returns:
- a new
XRefGT
instance - Throws:
IllegalArgumentException
- ifphase.length()==0 || samples.size() != phase.length()
IllegalArgumentException
- if if there existsj
such that(0 <= j && j < phase.length() && phase.get(j).markers().equals(phase.get(j).markers())==false
NullPointerException
- ifsamples == null || phase == null
NullPointerException
- if there existsj
such that(0 <= j && j < phase.length() && phase.get(j) == null)
-
fromPhasedGT
Returns a newXRefGT
instance from the specified data. The returnedXRefGT
instance will represent the same genotypes, the same list of markers, and same list of samples as the specified genotype data,- Parameters:
gt
- phased, nonmissing genotype datanThreads
- the maximum number of computational threads for object construction- Returns:
- an
XRefGT
instance - Throws:
IllegalArgumentException
- ifgt.isPhased() == false
IllegalArgumentException
- ifnThreads < 1
NullPointerException
- ifrefGT == null
-
hash
public int hash(int hap, int start, int end) Returns a hash code for the specified alleles.- Parameters:
hap
- a haplotypestart
- the first marker (inclusive)end
- the last marker (exclusive)- Returns:
- a hash code for the specified alleles
- Throws:
IndexOutOfBoundsException
- ifhap < 0 || hap >= this.nHaps()
IndexOutOfBoundsException
- ifstart < 0 || start > to || end >= this.nMarkers()
-
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 hap) 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
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. -
copyTo
Copies the specified bit sequence to the specifiedbitList
- Parameters:
hap
- the haplotype indexstart
- the start markerend
- the end markerbitList
- the destinationbitList
- Throws:
IllegalArgumentException
- ifstart > end
IndexOutOfBoundsException
- ifhap < 0 || hap >= this.nHaps()
IndexOutOfBoundsException
- ifstart < 0 || end > this.markers()
IndexOutOfBoundsException
- ifend <= this.markers() && bitList.size() < this.markers().sumHaplotypeBits(end)
NullPointerException
- ifbitList == null
-
toString
-