Package vcf
Class BasicGT
- java.lang.Object
-
- vcf.BasicGT
-
-
Constructor Summary
Constructors Constructor Description BasicGT(GTRec[] recs)
Constructs aBasicGT
instance from the specified dataBasicGT(Markers markers, Samples samples, GTRec[] recs)
Constructs aBasicGT
instance from the specified data.BasicGT(Samples samples, GTRec[] recs)
Constructs aBasicGT
instance from the specified data
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
allele(int marker, int hap)
Returns the allele on the specified haplotype for the specified marker or return -1 if the allele is missing.int
allele1(int marker, int sample)
Returns the first allele for the specified marker and sample or return -1 if the allele is missing.int
allele2(int marker, int sample)
Returns the second allele for the specified marker and sample or return -1 if the allele is missing.static int
genotype(int a1, int a2)
Returns the genotype index corresponding to the specified unordered 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
isReversed()
Returnstrue
if the markers are ordered by decreasing chromosome base position, and returnsfalse
otherwise.Marker
marker(int markerIndex)
Returns the specified marker.Markers
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.BasicGT
restrict(int start, int end)
Returns a newGT
instance restricted to genotype data for the specified markers.static BasicGT
restrict(BasicGT gt, int[] indices)
Returns aBasicGT
instance restricted to genotype data for the specified markers.BasicGT
restrict(Markers restrictedMarkers, int[] indices)
Returns aGT
instance restricted to genotype data for the specified markers.Samples
samples()
Returns the list of samples.java.lang.String
toString()
Returns a string representation ofthis
.
-
-
-
Constructor Detail
-
BasicGT
public BasicGT(GTRec[] recs)
Constructs aBasicGT
instance from the specified data- Parameters:
recs
- genotype records for a list of markers- Throws:
java.lang.IllegalArgumentException
- if elements ofrecs
corresponding to the same chromosome are not contiguous and sorted in chromosome position orderjava.lang.IllegalArgumentException
- ifrecs.length == 0
java.lang.IllegalArgumentException
- if any two elements ofrecs
correspond to the same genetic markerjava.lang.IllegalArgumentException
- if(recs[j].samples().equals(recs[k].samples()) == false)
for anyj, k
satisfying(0 <= j && j < k && j < recs.length)
java.lang.NullPointerException
- ifrecs == null
java.lang.NullPointerException
- if(recs[j] == null)
anyj
satisfying(0 <= j && j < recs.length)
-
BasicGT
public BasicGT(Samples samples, GTRec[] recs)
Constructs aBasicGT
instance from the specified data- Parameters:
samples
- the list of samples with genotype datarecs
- genotype records for a list of markers- Throws:
java.lang.IllegalArgumentException
- if elements ofrecs
corresponding to the same chromosome are not contiguous and sorted in chromosome position orderjava.lang.IllegalArgumentException
- if any two elements ofrecs
correspond to the same genetic markerjava.lang.IllegalArgumentException
- if(recs[j].samples().equals(samples) == false)
for anyj
satisfying(0 <= j && j < recs.length)
java.lang.NullPointerException
- ifsamples == null || recs == null
java.lang.NullPointerException
- if(recs[j] == null)
anyj
satisfying(0 <= j && j < recs.length)
-
BasicGT
public BasicGT(Markers markers, Samples samples, GTRec[] recs)
Constructs aBasicGT
instance 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:
java.lang.IllegalArgumentException
- if(recs[j].marker().equals(markers.marker(j)) == false)
for anyj
satisfying(0 <= j && j < recs.length)
java.lang.IllegalArgumentException
- if(recs[j].samples().equals(samples) == false)
for anyj
satisfying(0 <= j && j < recs.length)
java.lang.NullPointerException
- if(markers == null || samples == null || recs == null)
java.lang.NullPointerException
- if(recs[j] == null)
anyj
satisfying(0 <= j && j < recs.length)
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- ifa1 < 0 || a2 < 0
-
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
public Marker marker(int markerIndex)
Description copied from interface:GT
Returns the specified marker.
-
markers
public Markers 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.
-
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.
-
allele1
public int allele1(int marker, int sample)
Description copied from interface:GT
Returns 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:GT
Returns 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: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
public static BasicGT restrict(BasicGT gt, int[] indices)
Returns aBasicGT
instance restricted to genotype data for the specified markers.- Parameters:
gt
- theBasicGT
instance to be restrictedindices
- a list of distinct marker indices (fromthis.markers())
in increasing order- Returns:
- a
GT
instance restricted to genotype data for the specified markers - Throws:
java.lang.IndexOutOfBoundsException
- if there existsj
such that(0 <= j && j < indices.length)
such that(indices[j] < 0 || indices[j] >= gt.nMarkers())
java.lang.IllegalArgumentException
- if there existsj
such that(1 <= j && j < indices.length)
such that(indices[j] <= indice[j - 1])
java.lang.NullPointerException
- ifgt == null || indices == null
-
restrict
public BasicGT restrict(Markers restrictedMarkers, int[] indices)
Description copied from interface:GT
Returns aGT
instance restricted to genotype data for the specified markers.
-
restrict
public BasicGT restrict(int start, int end)
Description copied from interface:GT
Returns a newGT
instance restricted to genotype data for the specified markers.
-
toString
public java.lang.String toString()
Returns a string representation ofthis
. The exact details of the representation are unspecified and subject to change.- Overrides:
toString
in classjava.lang.Object
- Returns:
- a string representation of
this
-
-