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
Nested ClassesModifier and TypeClassDescriptionstatic classReturns the data used in the full GenotypesContext constructorGenotypesContext(java.util.ArrayList, java.util.Map, java.util.List)static interfaceSimple lazy parser interface. -
Field Summary
Fields inherited from class htsjdk.variant.variantcontext.GenotypesContext
NO_GENOTYPES, notToBeDirectlyAccessedGenotypes, sampleNamesInOrder, sampleNameToOffset, serialVersionUID -
Constructor Summary
ConstructorsConstructorDescriptionLazyGenotypesContext(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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods 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:
getGenotypesin 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:
ensureSampleNameMapin classGenotypesContext
-
ensureSampleOrdering
protected void ensureSampleOrdering()- Overrides:
ensureSampleOrderingin classGenotypesContext
-
invalidateSampleNameMap
protected void invalidateSampleNameMap()- Overrides:
invalidateSampleNameMapin classGenotypesContext
-
invalidateSampleOrdering
protected void invalidateSampleOrdering()- Overrides:
invalidateSampleOrderingin classGenotypesContext
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<Genotype>- Specified by:
isEmptyin interfaceList<Genotype>- Overrides:
isEmptyin classGenotypesContext
-
size
public int size()- Specified by:
sizein interfaceCollection<Genotype>- Specified by:
sizein interfaceList<Genotype>- Overrides:
sizein classGenotypesContext
-
getUnparsedGenotypeData
-