Package vcf
Class Samples
java.lang.Object
vcf.Samples
Class Samples stores a list of samples.
Samples are immutable.-
Constructor Summary
ConstructorsConstructorDescriptionSamples(int[] idIndices, boolean[] isDiploid) Constructs a new instance ofSamplescorresponding to the specified list of diploid sample identifier indices. -
Method Summary
Modifier and TypeMethodDescriptionstatic SamplesReturns a new samples instance by combining the two list of samples in the specified orderbooleanReturnstrueif the specified object is aSamplesobject which represents the same ordered list of samples asthis, and returnsfalseotherwise.static SamplesConstructs and returns aSamplesinstance corresponding to the specified list of sample identifiers.inthashCode()Returns a hash code value for the object.id(int index) Returns the identifier for the sample with the specified index in this list of samples.intidIndex(int index) Returns the sample identifier index corresponding to the sample with the specified index in this list of samples.int[]Returns an array mapping sample identifier indices to sample indices.String[]ids()Returns this list of samples as an array of sample identifiers.booleanisDiploid(int sample) Returnstrueif the specified sample has two alleles per genotype, and returnsfalseif the sample has one allele per genotype.intsize()Returns the number of samples in this list.toString()Returnsjava.util.Arrays.toString(this.ids()).
-
Constructor Details
-
Samples
public Samples(int[] idIndices, boolean[] isDiploid) Constructs a new instance ofSamplescorresponding to the specified list of diploid sample identifier indices.- Parameters:
idIndices- an array of sample identifier indicesisDiploid- a boolean array whosek-th value istrueif thek-th sample is diploid, and isfalseif thek-th sample is haploid- Throws:
IllegalArgumentException- ifidIndices.length != isDiploid.lengthIllegalArgumentException- if the specifiedidIndicesarray has two or more elements that are equalIndexOutOfBoundsException- if any element of the specifiedidIndicesarray is negative or greater than or equal tobeagleutil.SampleIds.instance().size()NullPointerException- ifidIndices == null || isDiploid == null
-
-
Method Details
-
combine
Returns a new samples instance by combining the two list of samples in the specified order- Parameters:
first- the first list of samplessecond- the second list of samples- Returns:
- the combined samples
- Throws:
IllegalArgumentException- if the two lists of samples are not disjointNullPointerException- iffirst == null || second == null
-
idIndexToIndex
public int[] idIndexToIndex()Returns an array mapping sample identifier indices to sample indices. Indices for sample identifiers not present in this list of samples are mapped to-1.- Returns:
- an array mapping sample identifier indices to sample indices
-
fromIds
Constructs and returns aSamplesinstance corresponding to the specified list of sample identifiers.- Parameters:
ids- an array of sample identifiersisDiploid- a boolean array whosek-th value istrueif thek-th sample is diploid, and isfalseif thek-th sample is haploid- Returns:
- a
Samplesinstance corresponding to the specified list of sample identifiers - Throws:
IllegalArgumentException- ifids.length != isDiploid.lengthIllegalArgumentException- if the specified array has two or more elements that are equal as stringsNullPointerException- ifids == null || isDiploid == null
-
hashCode
public int hashCode()Returns a hash code value for the object. -
equals
Returnstrueif the specified object is aSamplesobject which represents the same ordered list of samples asthis, and returnsfalseotherwise. -
idIndex
public int idIndex(int index) Returns the sample identifier index corresponding to the sample with the specified index in this list of samples.- Parameters:
index- a sample index- Returns:
- the sample identifier index corresponding to the sample with the specified index in this list of samples
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= this.size()
-
size
public int size()Returns the number of samples in this list.- Returns:
- the number of samples in this list
-
id
Returns the identifier for the sample with the specified index in this list of samples.- Parameters:
index- a sample index- Returns:
- the identifier for the sample with the specified index in this list of samples
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >= this.size()
-
ids
Returns this list of samples as an array of sample identifiers. The returned array has lengththis.size(), and it satisfiesthis.ids()[j].equals(this.id(j))for0 <= j && j < this.size()- Returns:
- this list of samples as an array of sample identifiers
-
isDiploid
public boolean isDiploid(int sample) Returnstrueif the specified sample has two alleles per genotype, and returnsfalseif the sample has one allele per genotype.- Parameters:
sample- a sample index- Returns:
trueif the specified sample is diploid- Throws:
IndexOutOfBoundsException- ifsample < 0 || sample >= this.size()
-
toString
Returnsjava.util.Arrays.toString(this.ids()).
-