public class GenotypesContext extends java.lang.Object implements java.util.List<Genotype>, java.io.Serializable
Modifier and Type | Field and Description |
---|---|
static GenotypesContext |
NO_GENOTYPES
static constant value for an empty GenotypesContext.
|
protected java.util.ArrayList<Genotype> |
notToBeDirectlyAccessedGenotypes
An ArrayList of genotypes contained in this context
WARNING: TO ENABLE THE LAZY VERSION OF THIS CLASS, NO METHODS SHOULD DIRECTLY
ACCESS THIS VARIABLE.
|
protected java.util.List<java.lang.String> |
sampleNamesInOrder
sampleNamesInOrder a list of sample names, one for each genotype in genotypes, sorted in alphabetical order
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
sampleNameToOffset
a map optimized for efficient lookup.
|
static long |
serialVersionUID |
Modifier | Constructor and Description |
---|---|
protected |
GenotypesContext()
Create an empty GenotypeContext
|
protected |
GenotypesContext(java.util.ArrayList<Genotype> genotypes)
Create an GenotypeContext containing genotypes
|
protected |
GenotypesContext(java.util.ArrayList<Genotype> genotypes,
java.util.Map<java.lang.String,java.lang.Integer> sampleNameToOffset,
java.util.List<java.lang.String> sampleNamesInOrder)
Create a fully resolved GenotypeContext containing genotypes, sample lookup table,
and sorted sample names
|
protected |
GenotypesContext(int n)
Create an empty GenotypeContext, with initial capacity for n elements
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Genotype genotype)
Adds a single genotype to this context.
|
void |
add(int i,
Genotype genotype) |
boolean |
addAll(java.util.Collection<? extends Genotype> genotypes)
Adds all of the genotypes to this context
See
add(Genotype) for important information about this functions
constraints and performance costs |
boolean |
addAll(int i,
java.util.Collection<? extends Genotype> genotypes) |
void |
checkImmutability() |
void |
clear() |
boolean |
contains(java.lang.Object o) |
boolean |
containsAll(java.util.Collection<?> objects) |
boolean |
containsSample(java.lang.String sample) |
boolean |
containsSamples(java.util.Collection<java.lang.String> samples) |
static GenotypesContext |
copy(java.util.Collection<Genotype> toCopy)
Create a GenotypesContext containing the genotypes in iteration order contained
in toCopy
|
static GenotypesContext |
copy(GenotypesContext toCopy)
Create a freshly allocated GenotypeContext containing the genotypes in toCopy
|
static GenotypesContext |
create()
Basic creation routine
|
static GenotypesContext |
create(java.util.ArrayList<Genotype> genotypes)
Create a fully resolved GenotypeContext containing genotypes
|
static GenotypesContext |
create(java.util.ArrayList<Genotype> genotypes,
java.util.Map<java.lang.String,java.lang.Integer> sampleNameToOffset,
java.util.List<java.lang.String> sampleNamesInOrder)
Create a fully resolved GenotypeContext containing genotypes, sample lookup table,
and sorted sample names
|
static GenotypesContext |
create(Genotype... genotypes)
Create a fully resolved GenotypeContext containing genotypes
|
static GenotypesContext |
create(int nGenotypes)
Basic creation routine
|
protected void |
ensureSampleNameMap() |
protected void |
ensureSampleOrdering() |
Genotype |
get(int i) |
Genotype |
get(java.lang.String sampleName)
Gets sample associated with this sampleName, or null if none is found
|
protected java.util.ArrayList<Genotype> |
getGenotypes() |
int |
getMaxPloidy(int defaultPloidy)
What is the max ploidy among all samples? Returns defaultPloidy if no genotypes are present
|
java.util.Set<java.lang.String> |
getSampleNames() |
java.util.List<java.lang.String> |
getSampleNamesOrderedByName() |
GenotypesContext |
immutable() |
int |
indexOf(java.lang.Object o) |
protected void |
invalidateSampleNameMap() |
protected void |
invalidateSampleOrdering() |
boolean |
isEmpty() |
boolean |
isLazyWithData() |
boolean |
isMutable() |
java.lang.Iterable<Genotype> |
iterateInSampleNameOrder()
Iterate over the Genotypes in this context in their sample name order (A, B, C)
regardless of the underlying order in the vector of genotypes
|
java.lang.Iterable<Genotype> |
iterateInSampleNameOrder(java.lang.Iterable<java.lang.String> sampleNamesInOrder)
Iterate over the Genotypes in this context in the order specified by sampleNamesInOrder
|
java.util.Iterator<Genotype> |
iterator() |
int |
lastIndexOf(java.lang.Object o) |
java.util.ListIterator<Genotype> |
listIterator() |
java.util.ListIterator<Genotype> |
listIterator(int i) |
Genotype |
remove(int i)
Note that remove requires us to invalidate our sample -> index
cache.
|
boolean |
remove(java.lang.Object o)
See for important warning
remove(int) |
boolean |
removeAll(java.util.Collection<?> objects) |
Genotype |
replace(Genotype genotype)
Replaces the genotype in this context -- note for efficiency
reasons we do not add the genotype if it's not present.
|
boolean |
retainAll(java.util.Collection<?> objects) |
Genotype |
set(int i,
Genotype genotype) |
int |
size() |
java.util.List<Genotype> |
subList(int i,
int i1) |
GenotypesContext |
subsetToSamples(java.util.Set<java.lang.String> samples)
Return a freshly allocated subcontext of this context containing only the samples
listed in samples.
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] ts) |
java.lang.String |
toString() |
public static final long serialVersionUID
public static final GenotypesContext NO_GENOTYPES
protected java.util.List<java.lang.String> sampleNamesInOrder
protected java.util.Map<java.lang.String,java.lang.Integer> sampleNameToOffset
protected java.util.ArrayList<Genotype> notToBeDirectlyAccessedGenotypes
protected GenotypesContext()
protected GenotypesContext(int n)
protected GenotypesContext(java.util.ArrayList<Genotype> genotypes)
protected GenotypesContext(java.util.ArrayList<Genotype> genotypes, java.util.Map<java.lang.String,java.lang.Integer> sampleNameToOffset, java.util.List<java.lang.String> sampleNamesInOrder)
genotypes
- our genotypes in arbitrarysampleNameToOffset
- map optimized for efficient lookup. Each genotype in genotypes must have its
sample name in sampleNameToOffset, with a corresponding integer value that indicates the offset of that
genotype in the vector of genotypessampleNamesInOrder
- a list of sample names, one for each genotype in genotypes, sorted in alphabetical
order.public static final GenotypesContext create()
public static final GenotypesContext create(int nGenotypes)
public static final GenotypesContext create(java.util.ArrayList<Genotype> genotypes, java.util.Map<java.lang.String,java.lang.Integer> sampleNameToOffset, java.util.List<java.lang.String> sampleNamesInOrder)
genotypes
- our genotypes in arbitrarysampleNameToOffset
- map optimized for efficient lookup. Each genotype in genotypes must have its
sample name in sampleNameToOffset, with a corresponding integer value that indicates the offset of that
genotype in the vector of genotypessampleNamesInOrder
- a list of sample names, one for each genotype in genotypes, sorted in alphabetical
order.public static final GenotypesContext create(java.util.ArrayList<Genotype> genotypes)
genotypes
- our genotypes in arbitrarypublic static final GenotypesContext create(Genotype... genotypes)
genotypes
- our genotypes in arbitrarypublic static final GenotypesContext copy(GenotypesContext toCopy)
toCopy
- the GenotypesContext to copypublic static final GenotypesContext copy(java.util.Collection<Genotype> toCopy)
toCopy
- the collection of genotypespublic final GenotypesContext immutable()
public boolean isMutable()
public final void checkImmutability()
protected void invalidateSampleNameMap()
protected void invalidateSampleOrdering()
protected void ensureSampleOrdering()
protected void ensureSampleNameMap()
public boolean isLazyWithData()
protected java.util.ArrayList<Genotype> getGenotypes()
public void clear()
public int size()
public boolean isEmpty()
public boolean add(Genotype genotype)
public void add(int i, Genotype genotype)
add
in interface java.util.List<Genotype>
public boolean addAll(java.util.Collection<? extends Genotype> genotypes)
add(Genotype)
for important information about this functions
constraints and performance costspublic boolean addAll(int i, java.util.Collection<? extends Genotype> genotypes)
addAll
in interface java.util.List<Genotype>
public boolean contains(java.lang.Object o)
public boolean containsAll(java.util.Collection<?> objects)
public int getMaxPloidy(int defaultPloidy)
defaultPloidy
- the default ploidy, if all samples are no-calledpublic Genotype get(java.lang.String sampleName)
sampleName
- public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List<Genotype>
public java.util.Iterator<Genotype> iterator()
public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List<Genotype>
public java.util.ListIterator<Genotype> listIterator()
listIterator
in interface java.util.List<Genotype>
public java.util.ListIterator<Genotype> listIterator(int i)
listIterator
in interface java.util.List<Genotype>
public Genotype remove(int i)
remove
in interface java.util.List<Genotype>
i
- public boolean remove(java.lang.Object o)
remove(int)
public boolean removeAll(java.util.Collection<?> objects)
public boolean retainAll(java.util.Collection<?> objects)
public Genotype set(int i, Genotype genotype)
set
in interface java.util.List<Genotype>
public Genotype replace(Genotype genotype)
genotype
- a non null genotype to bind in this contextpublic java.util.List<Genotype> subList(int i, int i1)
subList
in interface java.util.List<Genotype>
public java.lang.Object[] toArray()
public <T> T[] toArray(T[] ts)
public java.lang.Iterable<Genotype> iterateInSampleNameOrder(java.lang.Iterable<java.lang.String> sampleNamesInOrder)
sampleNamesInOrder
- a Iterable of String, containing exactly one entry for each Genotype sample name in
this contextpublic java.lang.Iterable<Genotype> iterateInSampleNameOrder()
public java.util.Set<java.lang.String> getSampleNames()
public java.util.List<java.lang.String> getSampleNamesOrderedByName()
public boolean containsSample(java.lang.String sample)
public boolean containsSamples(java.util.Collection<java.lang.String> samples)
public GenotypesContext subsetToSamples(java.util.Set<java.lang.String> samples)
samples
- public java.lang.String toString()
toString
in class java.lang.Object