Package vcf
Class BasicGT
java.lang.Object
vcf.BasicGT
- All Implemented Interfaces:
GT
Class BasicGT represents genotypes for a list of markers and
samples.
Instances of class BasicGT are immutable
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs aBasicGTinstance from the specified dataConstructs aBasicGTinstance from the specified data.Constructs aBasicGTinstance from the specified data -
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 intgenotype(int a1, int a2) Returns the genotype index corresponding to the specified unordered 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.static BasicGTReturns aBasicGTinstance 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()Returns a string representation ofthis.
-
Constructor Details
-
BasicGT
Constructs aBasicGTinstance from the specified data- Parameters:
recs- genotype records for a list of markers- Throws:
IllegalArgumentException- if elements ofrecscorresponding to the same chromosome are not contiguous and sorted in chromosome position orderIllegalArgumentException- ifrecs.length == 0IllegalArgumentException- if any two elements ofrecscorrespond to the same genetic markerIllegalArgumentException- if(recs[j].samples().equals(recs[k].samples()) == false)for anyj, ksatisfying(0 <= j && j < k && j < recs.length)NullPointerException- ifrecs == nullNullPointerException- if(recs[j] == null)anyjsatisfying(0 <= j && j < recs.length)
-
BasicGT
Constructs aBasicGTinstance from the specified data- Parameters:
samples- the list of samples with genotype datarecs- genotype records for a list of markers- Throws:
IllegalArgumentException- if elements ofrecscorresponding to the same chromosome are not contiguous and sorted in chromosome position orderIllegalArgumentException- if any two elements ofrecscorrespond to the same genetic markerIllegalArgumentException- if(recs[j].samples().equals(samples) == false)for anyjsatisfying(0 <= j && j < recs.length)NullPointerException- ifsamples == null || recs == nullNullPointerException- if(recs[j] == null)anyjsatisfying(0 <= j && j < recs.length)
-
BasicGT
Constructs aBasicGTinstance from the specified data.- Parameters:
markers- the list of markers with genotype datasamples- the list of samples with genotype datarecs- the genotype data for each marker- Throws:
IllegalArgumentException- if(recs[j].marker().equals(markers.marker(j)) == false)for anyjsatisfying(0 <= j && j < recs.length)IllegalArgumentException- if(recs[j].samples().equals(samples) == false)for anyjsatisfying(0 <= j && j < recs.length)NullPointerException- if(markers == null || samples == null || recs == null)NullPointerException- if(recs[j] == null)anyjsatisfying(0 <= j && j < recs.length)
-
-
Method Details
-
genotype
public static int genotype(int a1, int a2) Returns the genotype index corresponding to the specified unordered alleles.- Parameters:
a1- the first allele index of an unordered genotypea2- the second allele index of an unordered genotype- Returns:
- the genotype index corresponding to the specified unordered alleles
- Throws:
IllegalArgumentException- ifa1 < 0 || a2 < 0
-
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
Returns aBasicGTinstance restricted to genotype data for the specified markers.- Parameters:
gt- theBasicGTinstance to be restrictedindices- a list of distinct marker indices (fromthis.markers())in increasing order- Returns:
- a
GTinstance restricted to genotype data for the specified markers - Throws:
IndexOutOfBoundsException- if there existsjsuch that(0 <= j && j < indices.length)such that(indices[j] < 0 || indices[j] >= gt.nMarkers())IllegalArgumentException- if there existsjsuch that(1 <= j && j < indices.length)such that(indices[j] <= indice[j - 1])NullPointerException- ifgt == null || indices == null
-
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. -
toString
Returns a string representation ofthis. The exact details of the representation are unspecified and subject to change.
-