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 TypeMethodDescriptionintallele(int marker, int hap) Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.static XRefGTReturns a newXRefGTinstance from the specified data.voidCopies the specified bit sequence to the specifiedbitListstatic XRefGTfrom(Samples samples, AtomicReferenceArray<SamplePhase> phase) Returns a newXRefGTinstance from the specified data.static XRefGTfromPhasedGT(GT gt, int nThreads) Returns a newXRefGTinstance from the specified data.inthash(int hap, int start, int end) Returns a hash code for the specified alleles.booleanisPhased()Returnstrueif the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalseotherwise.booleanReturnstrueif the markers are ordered by decreasing chromosome base position, and returnsfalseotherwise.marker(int markerIndex) Returns the specified marker.markers()Returns the list of markers in order of increasing chromosome position.intnHaps()Returns the number of haplotypes.intnMarkers()Returns the number of markers.intnSamples()Returns the number of samples.restrict(int start, int end) Returns a newGTinstance restricted to genotype data for the specified markers.Returns aGTinstance restricted to genotype data for the specified markers.samples()Returns the list of samples.toString()
-
Method Details
-
combine
Returns a newXRefGTinstance from the specified data. The order of samples and haplotypes is preserved. Samples in the firstXRefGTparameter are placed before samples in the secondXRefGTparameter in the returnedXRefGTinstance.- Parameters:
first- phased genotype data for a list of samplessecond- phased genotype data for a list of samples- Returns:
- a new
XRefGTinstance - Throws:
NullPointerException- iffirst == null || second == nullIllegalArgumentException- if the lists of samples in the two specifiedXRefGTparameters are not disjointIllegalArgumentException- iffirst.markers().equals(second.markers()) == false
-
from
Returns a newXRefGTinstance from the specified data.- Parameters:
samples- the list of samplesphase- the phased genotypes- Returns:
- a new
XRefGTinstance - Throws:
IllegalArgumentException- ifphase.length()==0 || samples.size() != phase.length()IllegalArgumentException- if if there existsjsuch that(0 <= j && j < phase.length() && phase.get(j).markers().equals(phase.get(j).markers())==falseNullPointerException- ifsamples == null || phase == nullNullPointerException- if there existsjsuch that(0 <= j && j < phase.length() && phase.get(j) == null)
-
fromPhasedGT
Returns a newXRefGTinstance from the specified data. The returnedXRefGTinstance 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
XRefGTinstance - Throws:
IllegalArgumentException- ifgt.isPhased() == falseIllegalArgumentException- ifnThreads < 1NullPointerException- 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:GTReturnstrueif the markers are ordered by decreasing chromosome base position, and returnsfalseotherwise.- Specified by:
isReversedin interfaceGT- Returns:
trueif the markers are ordered by decreasing chromosome base position
-
nMarkers
public int nMarkers()Description copied from interface:GTReturns the number of markers. -
marker
Description copied from interface:GTReturns the specified marker. -
markers
Description copied from interface:GTReturns 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:GTReturns the number of haplotypes. The returned value is equal to2*this.nSamples(). -
nSamples
public int nSamples()Description copied from interface:GTReturns the number of samples. -
samples
Description copied from interface:GTReturns the list of samples. -
isPhased
public boolean isPhased()Description copied from interface:GTReturnstrueif the genotype for each marker and sample has non-missing alleles and is either haploid or diploid with a phased allele separator, and returnsfalseotherwise. -
allele
public int allele(int marker, int hap) Description copied from interface:GTReturns 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:GTReturns aGTinstance restricted to genotype data for the specified markers. -
restrict
Description copied from interface:GTReturns a newGTinstance 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 > endIndexOutOfBoundsException- 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
-