Package vcf
Class XRefGT
- java.lang.Object
-
- vcf.XRefGT
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intallele(int marker, int hap)Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.intallele1(int marker, int sample)Returns the first allele for the specified marker and sample or return -1 if the allele is missing.intallele2(int marker, int sample)Returns the second allele for the specified marker and sample or return -1 if the allele is missing.static XRefGTcombine(XRefGT first, XRefGT second)Returns a newXRefGTinstance from the specified data.voidcopyTo(int hap, int start, int end, BitArray bitList)Copies the specified bit sequence to the specifiedbitListstatic XRefGTfrom(Markers markers, Samples samples, BitArray[] haps)Returns a newXRefGTinstance from the specified data.static XRefGTfrom(Samples samples, java.util.concurrent.atomic.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.booleanisReversed()Returnstrueif the markers are ordered by decreasing chromosome base position, and returnsfalseotherwise.Markermarker(int markerIndex)Returns the specified marker.Markersmarkers()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.XRefGTrestrict(int start, int end)Returns a newGTinstance restricted to genotype data for the specified markers.GTrestrict(Markers markers, int[] indices)Returns aGTinstance restricted to genotype data for the specified markers.Samplessamples()Returns the list of samples.BitArray[]toBitLists(int nThreads)Returns the phased, non-missing genotypes as aBitArray[].java.lang.StringtoString()
-
-
-
Method Detail
-
combine
public static XRefGT combine(XRefGT first, XRefGT second)
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:
java.lang.NullPointerException- iffirst == null || second == nulljava.lang.IllegalArgumentException- if the lists of samples in the two specifiedXRefGTparameters are not disjointjava.lang.IllegalArgumentException- iffirst.markers().equals(second.markers()) == false
-
from
public static XRefGT from(Markers markers, Samples samples, BitArray[] haps)
Returns a newXRefGTinstance from the specified data. The specified haplotypes will be copied, and the returnedXRefGTinstance will not contain a reference to the specified haplotypes.- Parameters:
markers- the list of markerssamples- the list of sampleshaps- the list of haplotypes corresponding to the list of samples- Returns:
- a new
XRefGTinstance - Throws:
java.lang.IllegalArgumentException- if there exists(0 <= j && j < haps.length)such that(haps[j].size() != markers.sumHaplotypeBits())java.lang.IllegalArgumentException- if2*samples.size() != haps.lengthjava.lang.NullPointerException- ifmarkers == null || samples == null || haps == null
-
from
public static XRefGT from(Samples samples, java.util.concurrent.atomic.AtomicReferenceArray<SamplePhase> phase)
Returns a newXRefGTinstance from the specified data.- Parameters:
samples- the list of samplesphase- the phased genotypes- Returns:
- a new
XRefGTinstance - Throws:
java.lang.IllegalArgumentException- ifphase.length()==0 || samples.size() != phase.length()java.lang.IllegalArgumentException- if if there existsjsuch that(0 <= j && j < phase.length() && phase.get(j).markers().equals(phase.get(j).markers())==falsejava.lang.NullPointerException- ifsamples == null || phase == nulljava.lang.NullPointerException- if there existsjsuch that(0 <= j && j < phase.length() && phase.get(j) == null)
-
toBitLists
public BitArray[] toBitLists(int nThreads)
Returns the phased, non-missing genotypes as aBitArray[].- Parameters:
nThreads- the maximum number of computational threads for object construction- Returns:
- the phased, non-missing genotypes as a
BitArray[] - Throws:
java.lang.IllegalArgumentException- ifnThreads < 1
-
fromPhasedGT
public static XRefGT fromPhasedGT(GT gt, int nThreads)
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:
java.lang.IllegalArgumentException- ifgt.isPhased() == falsejava.lang.IllegalArgumentException- ifnThreads < 1java.lang.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:
java.lang.IndexOutOfBoundsException- ifhap < 0 || hap >= this.nHaps()java.lang.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
public Marker marker(int markerIndex)
Description copied from interface:GTReturns the specified marker.
-
markers
public Markers 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.
-
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.
-
allele1
public int allele1(int marker, int sample)Description copied from interface:GTReturns the first allele for the specified marker and sample or return -1 if the allele is missing. The order of the two alleles is unspecified ifthis.isPhased() == false.
-
allele2
public int allele2(int marker, int sample)Description copied from interface:GTReturns the second allele for the specified marker and sample or return -1 if the allele is missing. The order of the two alleles is unspecified ifthis.isPhased() == false.
-
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
public GT restrict(Markers markers, int[] indices)
Description copied from interface:GTReturns aGTinstance restricted to genotype data for the specified markers.
-
restrict
public XRefGT restrict(int start, int end)
Description copied from interface:GTReturns a newGTinstance restricted to genotype data for the specified markers.
-
copyTo
public void copyTo(int hap, int start, int end, BitArray bitList)Copies the specified bit sequence to the specifiedbitList- Parameters:
hap- the haplotype indexstart- the start markerend- the end markerbitList- the destinationbitList- Throws:
java.lang.IllegalArgumentException- ifstart > endjava.lang.IndexOutOfBoundsException- ifhap < 0 || hap >= this.nHaps()java.lang.IndexOutOfBoundsException- ifstart < 0 || end > this.markers()java.lang.IndexOutOfBoundsException- ifend <= this.markers() && bitList.size() < this.markers().sumHaplotypeBits(end)java.lang.NullPointerException- ifbitList == null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-