Serializable
, Iterable<Genotype>
, Collection<Genotype>
, List<Genotype>
LazyGenotypesContext
public class GenotypesContext extends Object implements List<Genotype>, Serializable
Modifier and Type | Field | Description |
---|---|---|
static GenotypesContext |
NO_GENOTYPES |
static constant value for an empty GenotypesContext.
|
protected 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 List<String> |
sampleNamesInOrder |
sampleNamesInOrder a list of sample names, one for each genotype in genotypes, sorted in alphabetical order
|
protected Map<String,Integer> |
sampleNameToOffset |
a map optimized for efficient lookup.
|
static long |
serialVersionUID |
Modifier | Constructor | Description |
---|---|---|
protected |
GenotypesContext() |
Create an empty GenotypeContext
|
protected |
GenotypesContext(int n) |
Create an empty GenotypeContext, with initial capacity for n elements
|
protected |
GenotypesContext(ArrayList<Genotype> genotypes) |
Create an GenotypeContext containing genotypes
|
protected |
GenotypesContext(ArrayList<Genotype> genotypes,
Map<String,Integer> sampleNameToOffset,
List<String> sampleNamesInOrder) |
Create a fully resolved GenotypeContext containing genotypes, sample lookup table,
and sorted sample names
|
Modifier and Type | Method | Description |
---|---|---|
void |
add(int i,
Genotype genotype) |
|
boolean |
add(Genotype genotype) |
Adds a single genotype to this context.
|
boolean |
addAll(int i,
Collection<? extends Genotype> genotypes) |
|
boolean |
addAll(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 |
void |
checkImmutability() |
|
void |
clear() |
|
boolean |
contains(Object o) |
|
boolean |
containsAll(Collection<?> objects) |
|
boolean |
containsSample(String sample) |
|
boolean |
containsSamples(Collection<String> samples) |
|
static GenotypesContext |
copy(GenotypesContext toCopy) |
Create a freshly allocated GenotypeContext containing the genotypes in toCopy
|
static GenotypesContext |
copy(Collection<Genotype> toCopy) |
Create a GenotypesContext containing the genotypes in iteration order contained
in toCopy
|
static GenotypesContext |
create() |
Basic creation routine
|
static GenotypesContext |
create(int nGenotypes) |
Basic creation routine
|
static GenotypesContext |
create(Genotype... genotypes) |
Create a fully resolved GenotypeContext containing genotypes
|
static GenotypesContext |
create(ArrayList<Genotype> genotypes) |
Create a fully resolved GenotypeContext containing genotypes
|
static GenotypesContext |
create(ArrayList<Genotype> genotypes,
Map<String,Integer> sampleNameToOffset,
List<String> sampleNamesInOrder) |
Create a fully resolved GenotypeContext containing genotypes, sample lookup table,
and sorted sample names
|
protected void |
ensureSampleNameMap() |
|
protected void |
ensureSampleOrdering() |
|
Genotype |
get(int i) |
|
Genotype |
get(String sampleName) |
Gets sample associated with this sampleName, or null if none is found
|
protected ArrayList<Genotype> |
getGenotypes() |
|
int |
getMaxPloidy(int defaultPloidy) |
What is the max ploidy among all samples? Returns defaultPloidy if no genotypes are present
|
Set<String> |
getSampleNames() |
|
List<String> |
getSampleNamesOrderedByName() |
|
GenotypesContext |
immutable() |
|
int |
indexOf(Object o) |
|
protected void |
invalidateSampleNameMap() |
|
protected void |
invalidateSampleOrdering() |
|
boolean |
isEmpty() |
|
boolean |
isLazyWithData() |
|
boolean |
isMutable() |
|
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
|
Iterable<Genotype> |
iterateInSampleNameOrder(Iterable<String> sampleNamesInOrder) |
Iterate over the Genotypes in this context in the order specified by sampleNamesInOrder
|
Iterator<Genotype> |
iterator() |
|
int |
lastIndexOf(Object o) |
|
ListIterator<Genotype> |
listIterator() |
|
ListIterator<Genotype> |
listIterator(int i) |
|
Genotype |
remove(int i) |
Note that remove requires us to invalidate our sample -> index
cache.
|
boolean |
remove(Object o) |
See for important warning
remove(int) |
boolean |
removeAll(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(Collection<?> objects) |
|
Genotype |
set(int i,
Genotype genotype) |
|
int |
size() |
|
List<Genotype> |
subList(int i,
int i1) |
|
GenotypesContext |
subsetToSamples(Set<String> samples) |
Return a freshly allocated subcontext of this context containing only the samples
listed in samples.
|
Object[] |
toArray() |
|
<T> T[] |
toArray(T[] ts) |
|
String |
toString() |
parallelStream, removeIf, stream
equals, hashCode, replaceAll, sort, spliterator
public static final long serialVersionUID
public static final GenotypesContext NO_GENOTYPES
protected List<String> sampleNamesInOrder
protected Map<String,Integer> sampleNameToOffset
protected GenotypesContext()
protected GenotypesContext(int n)
protected GenotypesContext(ArrayList<Genotype> genotypes)
protected GenotypesContext(ArrayList<Genotype> genotypes, Map<String,Integer> sampleNameToOffset, List<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(ArrayList<Genotype> genotypes, Map<String,Integer> sampleNameToOffset, List<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(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(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()
public void clear()
public int size()
public boolean isEmpty()
public boolean add(Genotype genotype)
public boolean addAll(Collection<? extends Genotype> genotypes)
add(Genotype)
for important information about this functions
constraints and performance costspublic boolean addAll(int i, Collection<? extends Genotype> genotypes)
public boolean contains(Object o)
public boolean containsAll(Collection<?> objects)
containsAll
in interface Collection<Genotype>
containsAll
in interface List<Genotype>
public int getMaxPloidy(int defaultPloidy)
defaultPloidy
- the default ploidy, if all samples are no-calledpublic Genotype get(String sampleName)
sampleName
- public int lastIndexOf(Object o)
lastIndexOf
in interface List<Genotype>
public ListIterator<Genotype> listIterator()
listIterator
in interface List<Genotype>
public ListIterator<Genotype> listIterator(int i)
listIterator
in interface List<Genotype>
public Genotype remove(int i)
public boolean remove(Object o)
remove(int)
public boolean removeAll(Collection<?> objects)
public boolean retainAll(Collection<?> objects)
public Genotype replace(Genotype genotype)
genotype
- a non null genotype to bind in this contextpublic Object[] toArray()
public <T> T[] toArray(T[] ts)
public Iterable<Genotype> iterateInSampleNameOrder(Iterable<String> sampleNamesInOrder)
sampleNamesInOrder
- a Iterable of String, containing exactly one entry for each Genotype sample name in
this contextpublic Iterable<Genotype> iterateInSampleNameOrder()
public Set<String> getSampleNames()
public List<String> getSampleNamesOrderedByName()
public boolean containsSample(String sample)
public boolean containsSamples(Collection<String> samples)
public GenotypesContext subsetToSamples(Set<String> samples)
samples
-