Package htsjdk.variant.variantcontext
Class LazyGenotypesContext
java.lang.Object
htsjdk.variant.variantcontext.GenotypesContext
htsjdk.variant.variantcontext.LazyGenotypesContext
- All Implemented Interfaces:
Serializable
,Iterable<Genotype>
,Collection<Genotype>
,List<Genotype>
Lazy-loading GenotypesContext. A lazy-loading context has access to the
VCFParser and a unparsed string of genotype data. If the user attempts to manipulate
the genotypes contained in this context, we decode the data and become a full blown
GenotypesContext. However, if the user never does this we are spared a lot of expense
decoding the genotypes unnecessarily.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Returns the data used in the full GenotypesContext constructorGenotypesContext(java.util.ArrayList, java.util.Map, java.util.List)
static interface
Simple lazy parser interface. -
Field Summary
Fields inherited from class htsjdk.variant.variantcontext.GenotypesContext
NO_GENOTYPES, notToBeDirectlyAccessedGenotypes, sampleNamesInOrder, sampleNameToOffset, serialVersionUID
-
Constructor Summary
ConstructorDescriptionLazyGenotypesContext
(LazyGenotypesContext.LazyParser parser, Object unparsedGenotypeData, int nUnparsedGenotypes) Creates a new lazy loading genotypes context using the LazyParser to create genotypes data on demand. -
Method Summary
Methods inherited from class htsjdk.variant.variantcontext.GenotypesContext
add, add, addAll, addAll, checkImmutability, clear, contains, containsAll, containsSample, containsSamples, copy, copy, create, create, create, create, create, get, get, getMaxPloidy, getSampleNames, getSampleNamesOrderedByName, immutable, indexOf, isLazyWithData, isMutable, iterateInSampleNameOrder, iterateInSampleNameOrder, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replace, retainAll, set, subList, subsetToSamples, toArray, toArray, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.List
equals, hashCode, replaceAll, sort, spliterator
-
Constructor Details
-
LazyGenotypesContext
public LazyGenotypesContext(LazyGenotypesContext.LazyParser parser, Object unparsedGenotypeData, int nUnparsedGenotypes) Creates a new lazy loading genotypes context using the LazyParser to create genotypes data on demand.- Parameters:
parser
- the parser to be used to load on-demand genotypes dataunparsedGenotypeData
- the encoded genotypes data that we will decode if necessarynUnparsedGenotypes
- the number of genotypes that will be produced if / when we actually decode the genotypes data
-
-
Method Details
-
getGenotypes
Overrides the genotypes accessor. If we haven't already, decode the genotypes data and store the decoded results in the appropriate variables. Otherwise we just returned the decoded result directly. Note some care needs to be taken here as the value in notToBeDirectlyAccessedGenotypes may diverge from what would be produced by decode, if after the first decode the genotypes themselves are replaced- Overrides:
getGenotypes
in classGenotypesContext
- Returns:
-
decode
public void decode()Force us to decode the genotypes, if not already done -
ensureSampleNameMap
protected void ensureSampleNameMap()Overrides the ensure* functionality. If the data hasn't been loaded yet and we want to build the cache, just decode it and we're done. If we've already decoded the data, though, go through the super class- Overrides:
ensureSampleNameMap
in classGenotypesContext
-
ensureSampleOrdering
protected void ensureSampleOrdering()- Overrides:
ensureSampleOrdering
in classGenotypesContext
-
invalidateSampleNameMap
protected void invalidateSampleNameMap()- Overrides:
invalidateSampleNameMap
in classGenotypesContext
-
invalidateSampleOrdering
protected void invalidateSampleOrdering()- Overrides:
invalidateSampleOrdering
in classGenotypesContext
-
isEmpty
public boolean isEmpty()- Specified by:
isEmpty
in interfaceCollection<Genotype>
- Specified by:
isEmpty
in interfaceList<Genotype>
- Overrides:
isEmpty
in classGenotypesContext
-
size
public int size()- Specified by:
size
in interfaceCollection<Genotype>
- Specified by:
size
in interfaceList<Genotype>
- Overrides:
size
in classGenotypesContext
-
getUnparsedGenotypeData
-