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>`, `SequencedCollection<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 class`
`LazyGenotypesContext.LazyData`
Returns the data used in the full GenotypesContext constructor `GenotypesContext(java.util.ArrayList, java.util.Map, java.util.List)`
`static interface`
`LazyGenotypesContext.LazyParser`
Simple 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

Modifier and Type
Method
Description
`void`
`decode()`
Force us to decode the genotypes, if not already done
`protected void`
`ensureSampleNameMap()`
Overrides the ensure* functionality.
`protected void`
`ensureSampleOrdering()`
`protected ArrayList<Genotype>`
`getGenotypes()`
Overrides the genotypes accessor.
`Object`
`getUnparsedGenotypeData()`
`protected void`
`invalidateSampleNameMap()`
`protected void`
`invalidateSampleOrdering()`
`boolean`
`isEmpty()`
`int`
`size()`

### 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.lang.Iterable

`forEach`

### Methods inherited from interface java.util.List

`addFirst, addLast, equals, getFirst, getLast, hashCode, removeFirst, removeLast, replaceAll, reversed, 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 data
  `unparsedGenotypeData` - the encoded genotypes data that we will decode if necessary
  `nUnparsedGenotypes` - the number of genotypes that will be produced if / when we actually decode the genotypes data

## Method Details

### 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:
  `getGenotypes` in class `GenotypesContext`
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 class `GenotypesContext`

### ensureSampleOrdering

protected void ensureSampleOrdering()

Overrides:
  `ensureSampleOrdering` in class `GenotypesContext`

### invalidateSampleNameMap

protected void invalidateSampleNameMap()

Overrides:
  `invalidateSampleNameMap` in class `GenotypesContext`

### invalidateSampleOrdering

protected void invalidateSampleOrdering()

Overrides:
  `invalidateSampleOrdering` in class `GenotypesContext`

### isEmpty

public boolean isEmpty()

Specified by:
  `isEmpty` in interface `Collection<Genotype>`
Specified by:
  `isEmpty` in interface `List<Genotype>`
Overrides:
  `isEmpty` in class `GenotypesContext`

### size

public int size()

Specified by:
  `size` in interface `Collection<Genotype>`
Specified by:
  `size` in interface `List<Genotype>`
Overrides:
  `size` in class `GenotypesContext`

### getUnparsedGenotypeData

public Object getUnparsedGenotypeData()