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>
public class LazyGenotypesContext extends GenotypesContext
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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLazyGenotypesContext.LazyDataReturns the data used in the full GenotypesContext constructorGenotypesContext(java.util.ArrayList, java.util.Map, java.util.List)static interfaceLazyGenotypesContext.LazyParserSimple lazy parser interface.
-
Field Summary
-
Fields inherited from class htsjdk.variant.variantcontext.GenotypesContext
NO_GENOTYPES, notToBeDirectlyAccessedGenotypes, sampleNamesInOrder, sampleNameToOffset, serialVersionUID
-
-
Constructor Summary
Constructors Constructor Description LazyGenotypesContext(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddecode()Force us to decode the genotypes, if not already doneprotected voidensureSampleNameMap()Overrides the ensure* functionality.protected voidensureSampleOrdering()protected ArrayList<Genotype>getGenotypes()Overrides the genotypes accessor.ObjectgetUnparsedGenotypeData()protected voidinvalidateSampleNameMap()protected voidinvalidateSampleOrdering()booleanisEmpty()intsize()-
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 Detail
-
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 Detail
-
getGenotypes
protected ArrayList<Genotype> 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
public Object getUnparsedGenotypeData()
-
-