Added decode method to LazyGenotypesContext

-- AbstractVCFCodec calls this if the samples are not sorted.  Previously called getGenotypes() which didn't actually trigger the decode
This commit is contained in:
Mark DePristo 2011-11-21 16:21:23 -05:00
parent ab2efe3bd3
commit 9ea7b70a02
3 changed files with 17 additions and 8 deletions

View File

@ -321,6 +321,11 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec {
final LazyGenotypesContext.LazyParser lazyParser = new LazyVCFGenotypesParser(alleles, chr, pos); final LazyGenotypesContext.LazyParser lazyParser = new LazyVCFGenotypesParser(alleles, chr, pos);
final int nGenotypes = header.getGenotypeSamples().size(); final int nGenotypes = header.getGenotypeSamples().size();
LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, parts[8], nGenotypes); LazyGenotypesContext lazy = new LazyGenotypesContext(lazyParser, parts[8], nGenotypes);
// did we resort the sample names? If so, we need to load the genotype data
if ( !header.samplesWereAlreadySorted() )
lazy.decode();
builder.genotypesNoValidation(lazy); builder.genotypesNoValidation(lazy);
} }
@ -332,9 +337,6 @@ public abstract class AbstractVCFCodec implements FeatureCodec, NameAwareCodec {
generateException(e.getMessage()); generateException(e.getMessage());
} }
// did we resort the sample names? If so, we need to load the genotype data
if ( !header.samplesWereAlreadySorted() )
vc.getGenotypes();
return vc; return vc;
} }

View File

@ -177,4 +177,11 @@ public class LazyGenotypesContext extends GenotypesContext {
public Object getUnparsedGenotypeData() { public Object getUnparsedGenotypeData() {
return unparsedGenotypeData; return unparsedGenotypeData;
} }
/**
* Force us to decode the genotypes
*/
public void decode() {
buildCache();
}
} }