private BCF2Codec.LazyData getLazyData(final VariantContext vc) { if ( vc.getGenotypes().isLazyWithData() ) { final LazyGenotypesContext lgc = (LazyGenotypesContext)vc.getGenotypes(); if ( lgc.getUnparsedGenotypeData() instanceof BCF2Codec.LazyData && canSafelyWriteRawGenotypesBytes((BCF2Codec.LazyData) lgc.getUnparsedGenotypeData())) { return (BCF2Codec.LazyData)lgc.getUnparsedGenotypeData(); } else { lgc.decode(); // WARNING -- required to avoid keeping around bad lazy data for too long } } return null; }
/** * Create the lazy loader for the genotypes data, and store it in the builder * so that the VC will be able to decode on demand the genotypes data * * @param siteInfo * @param builder */ private void createLazyGenotypesDecoder( final SitesInfoForDecoding siteInfo, final VariantContextBuilder builder ) { if (siteInfo.nSamples > 0) { final LazyGenotypesContext.LazyParser lazyParser = new BCF2LazyGenotypesDecoder(this, siteInfo.alleles, siteInfo.nSamples, siteInfo.nFormatFields, builders); final LazyData lazyData = new LazyData(header, siteInfo.nFormatFields, decoder.getRecordBytes()); final LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, lazyData, header.getNGenotypeSamples()); // did we resort the sample names? If so, we need to load the genotype data if ( !header.samplesWereAlreadySorted() ) lazy.decode(); builder.genotypesNoValidation(lazy); } }
/** * 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 * @return */ @Override protected ArrayList<Genotype> getGenotypes() { decode(); return notToBeDirectlyAccessedGenotypes; }
public boolean isLazyWithData() { return this instanceof LazyGenotypesContext && ((LazyGenotypesContext)this).getUnparsedGenotypeData() != null; }
vc.getGenotypes(); genotypesData = gc.getUnparsedGenotypeData(); numGenotypes = gc.size();
@Override public GenotypesContext make(final List<Genotype> initialSamples) { return new LazyGenotypesContext(this, initialSamples, initialSamples.size()); }
/** * Create the lazy loader for the genotypes data, and store it in the builder * so that the VC will be able to decode on demand the genotypes data * * @param siteInfo * @param builder */ private void createLazyGenotypesDecoder( final SitesInfoForDecoding siteInfo, final VariantContextBuilder builder ) { if (siteInfo.nSamples > 0) { final LazyGenotypesContext.LazyParser lazyParser = new BCF2LazyGenotypesDecoder(this, siteInfo.alleles, siteInfo.nSamples, siteInfo.nFormatFields, builders); final LazyData lazyData = new LazyData(header, siteInfo.nFormatFields, decoder.getRecordBytes()); final LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, lazyData, header.getNGenotypeSamples()); // did we resort the sample names? If so, we need to load the genotype data if ( !header.samplesWereAlreadySorted() ) lazy.decode(); builder.genotypesNoValidation(lazy); } }
/** * 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 * @return */ @Override protected ArrayList<Genotype> getGenotypes() { decode(); return notToBeDirectlyAccessedGenotypes; }
public boolean isLazyWithData() { return this instanceof LazyGenotypesContext && ((LazyGenotypesContext)this).getUnparsedGenotypeData() != null; }
vc.getGenotypes(); genotypesData = gc.getUnparsedGenotypeData(); numGenotypes = gc.size();
/** * Create the lazy loader for the genotypes data, and store it in the builder * so that the VC will be able to decode on demand the genotypes data * * @param siteInfo * @param builder */ private void createLazyGenotypesDecoder( final SitesInfoForDecoding siteInfo, final VariantContextBuilder builder ) { if (siteInfo.nSamples > 0) { final LazyGenotypesContext.LazyParser lazyParser = new BCF2LazyGenotypesDecoder(this, siteInfo.alleles, siteInfo.nSamples, siteInfo.nFormatFields, builders); final LazyData lazyData = new LazyData(header, siteInfo.nFormatFields, decoder.getRecordBytes()); final LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, lazyData, header.getNGenotypeSamples()); // did we resort the sample names? If so, we need to load the genotype data if ( !header.samplesWereAlreadySorted() ) lazy.decode(); builder.genotypesNoValidation(lazy); } }
/** * Custom serialization routine. Needed to ensure that we decode any lazily-decoded data * before serialization. * * @param out stream to which to serialize this object */ private void writeObject(ObjectOutputStream out) throws IOException { // If we're a LazyGenotypesContext, decode the genotype data before serialization. // // Ugly, but we can't do this in LazyGenotypesContext.writeObject(), since // by the time that's called we'll already have serialized the superclass // data in GenotypesContext, and we need to make sure that we decode any lazy // data BEFORE serializing the fields in GenotypesContext. if ( getClass() == LazyGenotypesContext.class ) { ((LazyGenotypesContext)this).decode(); } out.defaultWriteObject(); }
private BCF2Codec.LazyData getLazyData(final VariantContext vc) { if ( vc.getGenotypes().isLazyWithData() ) { final LazyGenotypesContext lgc = (LazyGenotypesContext)vc.getGenotypes(); if ( lgc.getUnparsedGenotypeData() instanceof BCF2Codec.LazyData && canSafelyWriteRawGenotypesBytes((BCF2Codec.LazyData) lgc.getUnparsedGenotypeData())) { return (BCF2Codec.LazyData)lgc.getUnparsedGenotypeData(); } else { lgc.decode(); // WARNING -- required to avoid keeping around bad lazy data for too long } } return null; }
public boolean isLazyWithData() { return this instanceof LazyGenotypesContext && ((LazyGenotypesContext)this).getUnparsedGenotypeData() != null; }
vc.getGenotypes(); genotypesData = gc.getUnparsedGenotypeData(); numGenotypes = gc.size();
final LazyGenotypesContext.LazyParser lazyParser = new LazyVCFGenotypesParser(alleles, chr, pos); final int nGenotypes = header.getNGenotypeSamples(); LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, parts[8], nGenotypes); lazy.decode();
/** * Custom serialization routine. Needed to ensure that we decode any lazily-decoded data * before serialization. * * @param out stream to which to serialize this object */ private void writeObject(ObjectOutputStream out) throws IOException { // If we're a LazyGenotypesContext, decode the genotype data before serialization. // // Ugly, but we can't do this in LazyGenotypesContext.writeObject(), since // by the time that's called we'll already have serialized the superclass // data in GenotypesContext, and we need to make sure that we decode any lazy // data BEFORE serializing the fields in GenotypesContext. if ( getClass() == LazyGenotypesContext.class ) { ((LazyGenotypesContext)this).decode(); } out.defaultWriteObject(); }
private BCF2Codec.LazyData getLazyData(final VariantContext vc) { if ( vc.getGenotypes().isLazyWithData() ) { final LazyGenotypesContext lgc = (LazyGenotypesContext)vc.getGenotypes(); if ( lgc.getUnparsedGenotypeData() instanceof BCF2Codec.LazyData && canSafelyWriteRawGenotypesBytes((BCF2Codec.LazyData) lgc.getUnparsedGenotypeData())) { return (BCF2Codec.LazyData)lgc.getUnparsedGenotypeData(); } else { lgc.decode(); // WARNING -- required to avoid keeping around bad lazy data for too long } } return null; }
private String toStringUnparsedGenotypes() { return String.format("[VC %s @ %s Q%s of type=%s alleles=%s attr=%s GT=%s filters=%s", getSource(), contig + ":" + (start - stop == 0 ? start : start + "-" + stop), hasLog10PError() ? String.format("%.2f", getPhredScaledQual()) : ".", this.getType(), ParsingUtils.sortList(this.getAlleles()), ParsingUtils.sortedString(this.getAttributes()), ((LazyGenotypesContext)this.genotypes).getUnparsedGenotypeData(), String.join(",", commonInfo.getFilters())); }
final LazyGenotypesContext.LazyParser lazyParser = new LazyVCFGenotypesParser(alleles, chr, pos); final int nGenotypes = header.getNGenotypeSamples(); LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, parts[8], nGenotypes); lazy.decode();