Class 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
    • 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 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 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:
        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
      • getUnparsedGenotypeData

        public Object getUnparsedGenotypeData()