Moving around classes in VCF and BCF2
-- Refactored VCF writers into vcf.writers package -- Moved BCF2Writer to bcf2.writer -- Updates to all of the walkers using VCFWriter to reflect new packages -- A large number of files had their headers cleaned up because of this as well
This commit is contained in:
parent
679ffdd333
commit
c3b8048e2e
|
|
@ -4,10 +4,10 @@ import net.sf.samtools.util.BlockCompressedOutputStream;
|
|||
import org.apache.log4j.Logger;
|
||||
import org.broad.tribble.AbstractFeatureReader;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.VCFWriterStub;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFCodec;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ package org.broadinstitute.sting.gatk.io.stubs;
|
|||
|
||||
import org.broadinstitute.sting.commandline.*;
|
||||
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.broadinstitute.sting.utils.classloader.JVMUtils;
|
|||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.broadinstitute.sting.utils.BaseUtils;
|
|||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.broadinstitute.sting.utils.GenomeLoc;
|
|||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.broadinstitute.sting.utils.SampleUtils;
|
|||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Genotype;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompa
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Genotype;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.AnnotatorCompa
|
|||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.baq.BAQ;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.GenotypeLikelihoods;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import org.broadinstitute.sting.utils.codecs.refseq.RefSeqCodec;
|
|||
import org.broadinstitute.sting.utils.codecs.refseq.RefSeqFeature;
|
||||
import org.broadinstitute.sting.utils.codecs.refseq.Transcript;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.collections.CircularArray;
|
||||
import org.broadinstitute.sting.utils.collections.PrimitivePair;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import org.apache.log4j.Logger;
|
|||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
|||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ import org.broadinstitute.sting.utils.GenomeLoc;
|
|||
import org.broadinstitute.sting.utils.HasGenomeLocation;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.SortingVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.pileup.PileupElement;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.util.*;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import org.broadinstitute.sting.utils.SampleUtils;
|
|||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
|||
import org.broadinstitute.sting.utils.GenomeLocParser;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
|||
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||
import org.broadinstitute.sting.utils.MathUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFConstants;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.broadinstitute.sting.utils.MathUtils;
|
|||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.R.RScriptExecutor;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.collections.ExpandingArrayList;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import org.broadinstitute.sting.gatk.walkers.annotator.ChromosomeCounts;
|
|||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
|
|||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.*;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.SortingVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.sam.AlignmentUtils;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ import org.broadinstitute.sting.utils.SampleUtils;
|
|||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeaderLine;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.text.ListFileUtils;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.broadinstitute.sting.gatk.walkers.genotyper.UnifiedGenotyperEngine;
|
|||
import org.broadinstitute.sting.utils.MendelianViolation;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.text.XReadLines;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
|
|||
import org.broadinstitute.sting.utils.QualityUtils;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContextBuilder;
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ import org.broadinstitute.sting.utils.GenomeLoc;
|
|||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.hapmap.RawHapMapFeature;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.SortingVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import net.sf.samtools.SAMFileWriter;
|
|||
import org.broad.tribble.Tribble;
|
||||
import org.broadinstitute.sting.commandline.*;
|
||||
import org.broadinstitute.sting.gatk.io.stubs.SAMFileWriterArgumentTypeDescriptor;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Annotation;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import net.sf.samtools.SAMFileWriter;
|
|||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.broadinstitute.sting.gatk.filters.PlatformUnitFilterHelper;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
|
|
|||
|
|
@ -186,22 +186,22 @@ public class BCF2Codec implements FeatureCodec<VariantContext> {
|
|||
// --------------------------------------------------------------------------------
|
||||
|
||||
private final SitesInfoForDecoding decodeSitesBlock(final VariantContextBuilder builder) {
|
||||
final int contigOffset = decoder.decodeInt(BCFType.INT32.getSizeInBytes());
|
||||
final int contigOffset = decoder.decodeInt(BCF2Type.INT32.getSizeInBytes());
|
||||
final String contig = lookupContigName(contigOffset);
|
||||
builder.chr(contig);
|
||||
|
||||
final int pos = decoder.decodeInt(BCFType.INT32.getSizeInBytes());
|
||||
final int refLength = decoder.decodeInt(BCFType.INT32.getSizeInBytes());
|
||||
final int pos = decoder.decodeInt(BCF2Type.INT32.getSizeInBytes());
|
||||
final int refLength = decoder.decodeInt(BCF2Type.INT32.getSizeInBytes());
|
||||
builder.start((long)pos);
|
||||
builder.stop((long)(pos + refLength - 1)); // minus one because of our open intervals
|
||||
|
||||
final Object qual = decoder.decodeSingleValue(BCFType.FLOAT);
|
||||
final Object qual = decoder.decodeSingleValue(BCF2Type.FLOAT);
|
||||
if ( qual != null ) {
|
||||
builder.log10PError(((Double)qual) / -10.0);
|
||||
}
|
||||
|
||||
final int nAlleleInfo = decoder.decodeInt(BCFType.INT32.getSizeInBytes());
|
||||
final int nFormatSamples = decoder.decodeInt(BCFType.INT32.getSizeInBytes());
|
||||
final int nAlleleInfo = decoder.decodeInt(BCF2Type.INT32.getSizeInBytes());
|
||||
final int nFormatSamples = decoder.decodeInt(BCF2Type.INT32.getSizeInBytes());
|
||||
final int nAlleles = nAlleleInfo >> 16;
|
||||
final int nInfo = nAlleleInfo & 0x00FF;
|
||||
final int nFormatFields = nFormatSamples >> 24;
|
||||
|
|
@ -326,7 +326,7 @@ public class BCF2Codec implements FeatureCodec<VariantContext> {
|
|||
alleles = decodeGenotypeAlleles(siteInfo.alleles, (List<Integer>)values.get(i));
|
||||
} else if ( field.equals(VCFConstants.GENOTYPE_QUALITY_KEY) ) {
|
||||
final Integer value = (Integer)values.get(i);
|
||||
if ( value != BCFType.INT8.getMissingJavaValue() )
|
||||
if ( value != BCF2Type.INT8.getMissingJavaValue() )
|
||||
log10PError = value / -10.0;
|
||||
} else if ( field.equals(VCFConstants.GENOTYPE_FILTER_KEY) ) {
|
||||
throw new ReviewedStingException("Genotype filters not implemented in GATK BCF2");
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ public class BCF2Constants {
|
|||
public static final String DICTIONARY_LINE_TAG = "dictionary";
|
||||
public static final String DICTIONARY_LINE_ENTRY_SEPARATOR = ",";
|
||||
|
||||
public static final Charset BCF2_TEXT_CHARSET = Charset.forName("US-ASCII"); // TODO: enforce this!
|
||||
|
||||
// Note that these values are prefixed by FFFFFF for convenience
|
||||
public static final int INT8_MISSING_VALUE = 0xFFFFFF80;
|
||||
public static final int INT16_MISSING_VALUE = 0xFFFF8000;
|
||||
|
|
|
|||
|
|
@ -130,13 +130,13 @@ public class BCF2Decoder {
|
|||
|
||||
public final Object decodeTypedValue(final byte typeDescriptor) {
|
||||
final int size = TypeDescriptor.sizeIsOverflow(typeDescriptor) ? decodeVectorSize() : TypeDescriptor.decodeSize(typeDescriptor);
|
||||
final BCFType type = TypeDescriptor.decodeType(typeDescriptor);
|
||||
final BCF2Type type = TypeDescriptor.decodeType(typeDescriptor);
|
||||
|
||||
assert size >= 0;
|
||||
|
||||
if ( size == 0 ) {
|
||||
return null;
|
||||
} else if ( type == BCFType.CHAR ) { // special case string decoding for efficiency
|
||||
} else if ( type == BCF2Type.CHAR ) { // special case string decoding for efficiency
|
||||
return decodeLiteralString(size);
|
||||
} else if ( size == 1 ) {
|
||||
return decodeSingleValue(type);
|
||||
|
|
@ -149,7 +149,7 @@ public class BCF2Decoder {
|
|||
}
|
||||
}
|
||||
|
||||
public final Object decodeSingleValue(final BCFType type) {
|
||||
public final Object decodeSingleValue(final BCF2Type type) {
|
||||
// TODO -- decodeTypedValue should integrate this routine
|
||||
final int value = readInt(type.getSizeInBytes(), recordStream);
|
||||
|
||||
|
|
@ -187,10 +187,10 @@ public class BCF2Decoder {
|
|||
private final int decodeVectorSize() {
|
||||
final byte typeDescriptor = readTypeDescriptor();
|
||||
final int size = TypeDescriptor.decodeSize(typeDescriptor);
|
||||
final BCFType type = TypeDescriptor.decodeType(typeDescriptor);
|
||||
final BCF2Type type = TypeDescriptor.decodeType(typeDescriptor);
|
||||
|
||||
assert size == 1;
|
||||
assert type == BCFType.INT8 || type == BCFType.INT16 || type == BCFType.INT32;
|
||||
assert type == BCF2Type.INT8 || type == BCF2Type.INT16 || type == BCF2Type.INT32;
|
||||
|
||||
return decodeInt(type.getSizeInBytes());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,17 +69,17 @@ public class BCF2Encoder {
|
|||
* @param o
|
||||
* @return
|
||||
*/
|
||||
public final BCFType encode(final Object o) throws IOException {
|
||||
public final BCF2Type encode(final Object o) throws IOException {
|
||||
if ( o == null ) throw new ReviewedStingException("Generic encode cannot deal with null values");
|
||||
|
||||
if ( o instanceof String ) {
|
||||
return encodeString((String)o);
|
||||
} else if ( o instanceof List ) {
|
||||
final BCFType type = determinePrimitiveType(((List) o).get(0));
|
||||
final BCF2Type type = determinePrimitiveType(((List) o).get(0));
|
||||
encodeTypedVector((List) o, type);
|
||||
return type;
|
||||
} else {
|
||||
final BCFType type = determinePrimitiveType(o);
|
||||
final BCF2Type type = determinePrimitiveType(o);
|
||||
encodeTypedSingleton(o, type);
|
||||
return type;
|
||||
}
|
||||
|
|
@ -91,31 +91,31 @@ public class BCF2Encoder {
|
|||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
public final void encodeTypedMissing(final BCFType type) throws IOException {
|
||||
public final void encodeTypedMissing(final BCF2Type type) throws IOException {
|
||||
encodeTypedVector(Collections.emptyList(), type);
|
||||
}
|
||||
|
||||
// todo -- should be specialized for each object type for efficiency
|
||||
public final void encodeTypedSingleton(final Object v, final BCFType type) throws IOException {
|
||||
public final void encodeTypedSingleton(final Object v, final BCF2Type type) throws IOException {
|
||||
encodeTypedVector(Collections.singleton(v), type);
|
||||
}
|
||||
|
||||
public final BCFType encodeString(final String v) throws IOException {
|
||||
public final BCF2Type encodeString(final String v) throws IOException {
|
||||
// TODO -- this needs to be optimized
|
||||
final byte[] bytes = v.getBytes();
|
||||
final List<Byte> l = new ArrayList<Byte>(bytes.length);
|
||||
for ( int i = 0; i < bytes.length; i++) l.add(bytes[i]);
|
||||
encodeTypedVector(l, BCFType.CHAR);
|
||||
return BCFType.CHAR;
|
||||
encodeTypedVector(l, BCF2Type.CHAR);
|
||||
return BCF2Type.CHAR;
|
||||
}
|
||||
|
||||
public final <T extends Object> void encodeTypedVector(final Collection<T> v, final BCFType type) throws IOException {
|
||||
public final <T extends Object> void encodeTypedVector(final Collection<T> v, final BCF2Type type) throws IOException {
|
||||
encodeType(v.size(), type);
|
||||
encodeRawValues(v, type);
|
||||
}
|
||||
|
||||
public final BCFType encodeTypedIntOfBestSize(final int value) throws IOException {
|
||||
final BCFType type = determineIntegerType(value);
|
||||
public final BCF2Type encodeTypedIntOfBestSize(final int value) throws IOException {
|
||||
final BCF2Type type = determineIntegerType(value);
|
||||
encodeTypedSingleton(value, type);
|
||||
return type;
|
||||
}
|
||||
|
|
@ -126,13 +126,13 @@ public class BCF2Encoder {
|
|||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
public final <T extends Object> void encodeRawValues(final Collection<T> v, final BCFType type) throws IOException {
|
||||
public final <T extends Object> void encodeRawValues(final Collection<T> v, final BCF2Type type) throws IOException {
|
||||
for ( final T v1 : v ) {
|
||||
encodeRawValue(v1, type);
|
||||
}
|
||||
}
|
||||
|
||||
public final <T extends Object> void encodeRawValue(final T value, final BCFType type) throws IOException {
|
||||
public final <T extends Object> void encodeRawValue(final T value, final BCF2Type type) throws IOException {
|
||||
if ( value == type.getMissingJavaValue() )
|
||||
encodeRawMissingValue(type);
|
||||
else {
|
||||
|
|
@ -147,11 +147,11 @@ public class BCF2Encoder {
|
|||
}
|
||||
}
|
||||
|
||||
public final void encodeRawMissingValue(final BCFType type) throws IOException {
|
||||
public final void encodeRawMissingValue(final BCF2Type type) throws IOException {
|
||||
encodePrimitive(type.getMissingBytes(), type);
|
||||
}
|
||||
|
||||
public final void encodeRawMissingValues(final int size, final BCFType type) throws IOException {
|
||||
public final void encodeRawMissingValues(final int size, final BCF2Type type) throws IOException {
|
||||
for ( int i = 0; i < size; i++ )
|
||||
encodeRawMissingValue(type);
|
||||
}
|
||||
|
|
@ -166,22 +166,22 @@ public class BCF2Encoder {
|
|||
encodeStream.write(c);
|
||||
}
|
||||
|
||||
public final void encodeRawFloat(final float value, final BCFType type) throws IOException {
|
||||
public final void encodeRawFloat(final float value, final BCF2Type type) throws IOException {
|
||||
encodePrimitive(Float.floatToIntBits(value), type);
|
||||
}
|
||||
|
||||
public final void encodeType(final int size, final BCFType type) throws IOException {
|
||||
public final void encodeType(final int size, final BCF2Type type) throws IOException {
|
||||
final byte typeByte = TypeDescriptor.encodeTypeDescriptor(size, type);
|
||||
encodeStream.write(typeByte);
|
||||
if ( TypeDescriptor.willOverflow(size) )
|
||||
encodeTypedIntOfBestSize(size);
|
||||
}
|
||||
|
||||
public final void encodeRawInt(final int value, final BCFType type) throws IOException {
|
||||
public final void encodeRawInt(final int value, final BCF2Type type) throws IOException {
|
||||
encodePrimitive(value, type, encodeStream);
|
||||
}
|
||||
|
||||
public final void encodePrimitive(final int value, final BCFType type) throws IOException {
|
||||
public final void encodePrimitive(final int value, final BCF2Type type) throws IOException {
|
||||
encodePrimitive(value, type, encodeStream);
|
||||
}
|
||||
|
||||
|
|
@ -191,22 +191,22 @@ public class BCF2Encoder {
|
|||
//
|
||||
// --------------------------------------------------------------------------------
|
||||
|
||||
public final BCFType determineIntegerType(final List<Integer> values) {
|
||||
BCFType maxType = BCFType.INT8;
|
||||
public final BCF2Type determineIntegerType(final List<Integer> values) {
|
||||
BCF2Type maxType = BCF2Type.INT8;
|
||||
for ( final int value : values ) {
|
||||
final BCFType type1 = determineIntegerType(value);
|
||||
final BCF2Type type1 = determineIntegerType(value);
|
||||
switch ( type1 ) {
|
||||
case INT8: break;
|
||||
case INT16: maxType = BCFType.INT16; break;
|
||||
case INT32: return BCFType.INT32; // fast path for largest possible value
|
||||
case INT16: maxType = BCF2Type.INT16; break;
|
||||
case INT32: return BCF2Type.INT32; // fast path for largest possible value
|
||||
default: throw new ReviewedStingException("Unexpected integer type " + type1 );
|
||||
}
|
||||
}
|
||||
return maxType;
|
||||
}
|
||||
|
||||
public final BCFType determineIntegerType(final int value) {
|
||||
for ( final BCFType potentialType : TypeDescriptor.INTEGER_TYPES_BY_SIZE ) {
|
||||
public final BCF2Type determineIntegerType(final int value) {
|
||||
for ( final BCF2Type potentialType : TypeDescriptor.INTEGER_TYPES_BY_SIZE ) {
|
||||
if ( potentialType.withinRange(value) )
|
||||
return potentialType;
|
||||
}
|
||||
|
|
@ -214,16 +214,16 @@ public class BCF2Encoder {
|
|||
throw new ReviewedStingException("Integer cannot be encoded in allowable range of even INT32: " + value);
|
||||
}
|
||||
|
||||
private final BCFType determinePrimitiveType(final Object v) {
|
||||
private final BCF2Type determinePrimitiveType(final Object v) {
|
||||
if ( v instanceof Integer )
|
||||
return determineIntegerType((Integer)v);
|
||||
else if ( v instanceof Float )
|
||||
return BCFType.FLOAT;
|
||||
return BCF2Type.FLOAT;
|
||||
else
|
||||
throw new ReviewedStingException("No native encoding for Object of type " + v.getClass().getSimpleName());
|
||||
}
|
||||
|
||||
public final static void encodePrimitive(final int value, final BCFType type, final OutputStream encodeStream) throws IOException {
|
||||
public final static void encodePrimitive(final int value, final BCF2Type type, final OutputStream encodeStream) throws IOException {
|
||||
for ( int i = type.getSizeInBytes() - 1; i >= 0; i-- ) {
|
||||
final int shift = i * 8;
|
||||
int mask = 0xFF << shift;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.RodWalker;
|
||||
import org.broadinstitute.sting.utils.codecs.bcf2.writer.BCF2Writer;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFUtils;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ package org.broadinstitute.sting.utils.codecs.bcf2;
|
|||
* @author depristo
|
||||
* @since 05/12
|
||||
*/
|
||||
public enum BCFType {
|
||||
public enum BCF2Type {
|
||||
RESERVED_0,
|
||||
INT8(1, BCF2Constants.INT8_MISSING_VALUE, -127, 127), // todo -- confirm range
|
||||
INT16(2, BCF2Constants.INT16_MISSING_VALUE, -32767, 32767),
|
||||
|
|
@ -45,15 +45,15 @@ public enum BCFType {
|
|||
private final int sizeInBytes;
|
||||
private final long minValue, maxValue;
|
||||
|
||||
BCFType() {
|
||||
BCF2Type() {
|
||||
this(-1, 0, 0, 0);
|
||||
}
|
||||
|
||||
BCFType(final int sizeInBytes, final int missingBytes) {
|
||||
BCF2Type(final int sizeInBytes, final int missingBytes) {
|
||||
this(sizeInBytes, missingBytes, 0, 0);
|
||||
}
|
||||
|
||||
BCFType(final int sizeInBytes, final int missingBytes, final long minValue, final long maxValue) {
|
||||
BCF2Type(final int sizeInBytes, final int missingBytes, final long minValue, final long maxValue) {
|
||||
this.sizeInBytes = sizeInBytes;
|
||||
this.missingJavaValue = null;
|
||||
this.missingBytes = missingBytes;
|
||||
|
|
@ -25,25 +25,25 @@
|
|||
package org.broadinstitute.sting.utils.codecs.bcf2;
|
||||
|
||||
/**
|
||||
* Simple BCF decoder
|
||||
* Convenience methods for encoding, decoding BCF2 type descriptors (size + type)
|
||||
* @author Mark DePristo
|
||||
* @since 5/3/12
|
||||
*/
|
||||
public class TypeDescriptor {
|
||||
class TypeDescriptor {
|
||||
public static final int OVERFLOW_ELEMENT_MARKER = 15;
|
||||
public static final int MAX_INLINE_ELEMENTS = 14;
|
||||
|
||||
public final static BCFType[] INTEGER_TYPES_BY_SIZE = new BCFType[3];
|
||||
public final static BCFType[] DICTIONARY_TYPES_BY_SIZE = INTEGER_TYPES_BY_SIZE;
|
||||
private final static BCFType[] lookup = BCFType.values();
|
||||
public final static BCF2Type[] INTEGER_TYPES_BY_SIZE = new BCF2Type[3];
|
||||
public final static BCF2Type[] DICTIONARY_TYPES_BY_SIZE = INTEGER_TYPES_BY_SIZE;
|
||||
private final static BCF2Type[] LOOKUP = BCF2Type.values();
|
||||
|
||||
static {
|
||||
INTEGER_TYPES_BY_SIZE[0] = BCFType.INT8;
|
||||
INTEGER_TYPES_BY_SIZE[1] = BCFType.INT16;
|
||||
INTEGER_TYPES_BY_SIZE[2] = BCFType.INT32;
|
||||
INTEGER_TYPES_BY_SIZE[0] = BCF2Type.INT8;
|
||||
INTEGER_TYPES_BY_SIZE[1] = BCF2Type.INT16;
|
||||
INTEGER_TYPES_BY_SIZE[2] = BCF2Type.INT32;
|
||||
}
|
||||
|
||||
public final static byte encodeTypeDescriptor(final int nElements, final BCFType type ) {
|
||||
public final static byte encodeTypeDescriptor(final int nElements, final BCF2Type type ) {
|
||||
int encodeSize = Math.min(nElements, OVERFLOW_ELEMENT_MARKER);
|
||||
byte typeByte = (byte)((0x0F & encodeSize) << 4 | (type.getID() & 0x0F));
|
||||
return typeByte;
|
||||
|
|
@ -57,8 +57,8 @@ public class TypeDescriptor {
|
|||
return typeDescriptor & 0x0F;
|
||||
}
|
||||
|
||||
public final static BCFType decodeType(final byte typeDescriptor) {
|
||||
return lookup[decodeTypeID(typeDescriptor)];
|
||||
public final static BCF2Type decodeType(final byte typeDescriptor) {
|
||||
return LOOKUP[decodeTypeID(typeDescriptor)];
|
||||
}
|
||||
|
||||
public final static boolean sizeIsOverflow(final byte typeDescriptor) {
|
||||
|
|
|
|||
|
|
@ -22,12 +22,17 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.bcf2;
|
||||
package org.broadinstitute.sting.utils.codecs.bcf2.writer;
|
||||
|
||||
import net.sf.samtools.SAMSequenceDictionary;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.broadinstitute.sting.utils.Utils;
|
||||
import org.broadinstitute.sting.utils.codecs.bcf2.BCF2Constants;
|
||||
import org.broadinstitute.sting.utils.codecs.bcf2.BCF2Encoder;
|
||||
import org.broadinstitute.sting.utils.codecs.bcf2.BCF2Type;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.IndexingVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.Allele;
|
||||
|
|
@ -135,19 +140,19 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
throw new UserException(String.format("Contig %s not found in sequence dictionary from reference", vc.getChr()));
|
||||
|
||||
// note use of encodeRawValue to not insert the typing byte
|
||||
encoder.encodeRawValue(contigIndex, BCFType.INT32);
|
||||
encoder.encodeRawValue(contigIndex, BCF2Type.INT32);
|
||||
|
||||
// pos
|
||||
encoder.encodeRawValue(vc.getStart(), BCFType.INT32);
|
||||
encoder.encodeRawValue(vc.getStart(), BCF2Type.INT32);
|
||||
|
||||
// ref length
|
||||
encoder.encodeRawValue(vc.getEnd() - vc.getStart() + 1, BCFType.INT32);
|
||||
encoder.encodeRawValue(vc.getEnd() - vc.getStart() + 1, BCF2Type.INT32);
|
||||
|
||||
// qual
|
||||
if ( vc.hasLog10PError() )
|
||||
encoder.encodeRawFloat((float) vc.getPhredScaledQual(), BCFType.FLOAT);
|
||||
encoder.encodeRawFloat((float) vc.getPhredScaledQual(), BCF2Type.FLOAT);
|
||||
else
|
||||
encoder.encodeRawMissingValue(BCFType.FLOAT);
|
||||
encoder.encodeRawMissingValue(BCF2Type.FLOAT);
|
||||
|
||||
// info fields
|
||||
final int nAlleles = vc.getNAlleles();
|
||||
|
|
@ -155,8 +160,8 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
final int nGenotypeFormatFields = StandardVCFWriter.calcVCFGenotypeKeys(vc).size();
|
||||
final int nSamples = vc.getNSamples();
|
||||
|
||||
encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x00FF), BCFType.INT32);
|
||||
encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x0FFF), BCFType.INT32);
|
||||
encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x00FF), BCF2Type.INT32);
|
||||
encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x0FFF), BCF2Type.INT32);
|
||||
|
||||
buildID(vc);
|
||||
buildAlleles(vc);
|
||||
|
|
@ -181,7 +186,7 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
if ( vc.isFiltered() ) {
|
||||
encodeStringsByRef(vc.getFilters());
|
||||
} else {
|
||||
encoder.encodeTypedMissing(BCFType.INT32);
|
||||
encoder.encodeTypedMissing(BCF2Type.INT32);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -196,11 +201,11 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
|
||||
encodeStringByRef(key);
|
||||
if ( value instanceof List ) // NOTE: ONLY WORKS WITH LISTS
|
||||
encoder.encodeTypedVector((List) value, typeEquiv.bcfType);
|
||||
encoder.encodeTypedVector((List) value, typeEquiv.BCF2Type);
|
||||
else if ( value instanceof String )
|
||||
encoder.encodeString((String)value);
|
||||
else
|
||||
encoder.encodeTypedSingleton(value, typeEquiv.bcfType);
|
||||
encoder.encodeTypedSingleton(value, typeEquiv.BCF2Type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -256,25 +261,25 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
final int numInFormatField = getNGenotypeFieldValues(field, vc);
|
||||
final VCFToBCFType type = getBCF2TypeFromHeader(field, null);
|
||||
|
||||
startGenotypeField(field, numInFormatField, type.bcfType);
|
||||
startGenotypeField(field, numInFormatField, type.BCF2Type);
|
||||
for ( final Genotype g : vc.getGenotypes() ) {
|
||||
if ( ! g.hasAttribute(field) ) {
|
||||
encoder.encodeRawMissingValues(numInFormatField, type.bcfType);
|
||||
encoder.encodeRawMissingValues(numInFormatField, type.BCF2Type);
|
||||
} else {
|
||||
final Object val = g.getAttribute(field);
|
||||
final Collection<Object> vals = numInFormatField == 1 ? Collections.singleton(val) : (Collection)val;
|
||||
encoder.encodeRawValues(vals, type.bcfType);
|
||||
encoder.encodeRawValues(vals, type.BCF2Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class VCFToBCFType {
|
||||
VCFHeaderLineType vcfType;
|
||||
BCFType bcfType;
|
||||
BCF2Type BCF2Type;
|
||||
|
||||
private VCFToBCFType(final VCFHeaderLineType vcfType, final BCFType bcfType) {
|
||||
private VCFToBCFType(final VCFHeaderLineType vcfType, final BCF2Type BCF2Type) {
|
||||
this.vcfType = vcfType;
|
||||
this.bcfType = bcfType;
|
||||
this.BCF2Type = BCF2Type;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -285,11 +290,11 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
|
||||
// TODO -- no sense in allocating these over and over
|
||||
switch ( metaData.getType() ) {
|
||||
case Character: return new VCFToBCFType(metaData.getType(), BCFType.CHAR);
|
||||
case Flag: return new VCFToBCFType(metaData.getType(), BCFType.INT8);
|
||||
case String: return new VCFToBCFType(metaData.getType(), BCFType.CHAR);
|
||||
case Integer: return new VCFToBCFType(metaData.getType(), maybeIntValue != null ? encoder.determineIntegerType((Integer)maybeIntValue) : BCFType.INT32);
|
||||
case Float: return new VCFToBCFType(metaData.getType(), BCFType.FLOAT);
|
||||
case Character: return new VCFToBCFType(metaData.getType(), BCF2Type.CHAR);
|
||||
case Flag: return new VCFToBCFType(metaData.getType(), BCF2Type.INT8);
|
||||
case String: return new VCFToBCFType(metaData.getType(), BCF2Type.CHAR);
|
||||
case Integer: return new VCFToBCFType(metaData.getType(), maybeIntValue != null ? encoder.determineIntegerType((Integer)maybeIntValue) : BCF2Type.INT32);
|
||||
case Float: return new VCFToBCFType(metaData.getType(), BCF2Type.FLOAT);
|
||||
default: throw new ReviewedStingException("Unexpected type for field " + field);
|
||||
}
|
||||
}
|
||||
|
|
@ -308,14 +313,14 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
}
|
||||
|
||||
private final void addGQ(final VariantContext vc) throws IOException {
|
||||
startGenotypeField(VCFConstants.GENOTYPE_QUALITY_KEY, 1, BCFType.INT8);
|
||||
startGenotypeField(VCFConstants.GENOTYPE_QUALITY_KEY, 1, BCF2Type.INT8);
|
||||
for ( final Genotype g : vc.getGenotypes() ) {
|
||||
if ( g.hasLog10PError() ) {
|
||||
final int GQ = (int)Math.round(Math.min(g.getPhredScaledQual(), VCFConstants.MAX_GENOTYPE_QUAL));
|
||||
if ( GQ > VCFConstants.MAX_GENOTYPE_QUAL ) throw new ReviewedStingException("Unexpectedly large GQ " + GQ + " at " + vc);
|
||||
encoder.encodeRawValue(GQ, BCFType.INT8);
|
||||
encoder.encodeRawValue(GQ, BCF2Type.INT8);
|
||||
} else {
|
||||
encoder.encodeRawMissingValues(1, BCFType.INT8);
|
||||
encoder.encodeRawMissingValues(1, BCF2Type.INT8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -328,7 +333,7 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
|
||||
final Map<Allele, String> alleleMap = StandardVCFWriter.buildAlleleMap(vc);
|
||||
final int requiredPloidy = 2; // TODO -- handle ploidy, will need padding / depadding
|
||||
startGenotypeField(VCFConstants.GENOTYPE_KEY, requiredPloidy, BCFType.INT8);
|
||||
startGenotypeField(VCFConstants.GENOTYPE_KEY, requiredPloidy, BCF2Type.INT8);
|
||||
for ( final Genotype g : vc.getGenotypes() ) {
|
||||
if ( g.getPloidy() != requiredPloidy ) throw new ReviewedStingException("Cannot currently handle non-diploid calls!");
|
||||
final List<Integer> encoding = new ArrayList<Integer>(requiredPloidy);
|
||||
|
|
@ -336,7 +341,7 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
final int offset = a.isNoCall() ? -1 : Integer.valueOf(alleleMap.get(a));
|
||||
encoding.add(((offset+1) << 1) | (g.isPhased() ? 0x01 : 0x00));
|
||||
}
|
||||
encoder.encodeRawValues(encoding, BCFType.INT8);
|
||||
encoder.encodeRawValues(encoding, BCF2Type.INT8);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -348,29 +353,29 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
* @throws IOException
|
||||
*/
|
||||
private void writeBlock(final byte[] infoBlock, final byte[] genotypesBlock) throws IOException {
|
||||
BCF2Encoder.encodePrimitive(infoBlock.length, BCFType.INT32, outputStream);
|
||||
BCF2Encoder.encodePrimitive(genotypesBlock.length, BCFType.INT32, outputStream);
|
||||
BCF2Encoder.encodePrimitive(infoBlock.length, BCF2Type.INT32, outputStream);
|
||||
BCF2Encoder.encodePrimitive(genotypesBlock.length, BCF2Type.INT32, outputStream);
|
||||
outputStream.write(infoBlock);
|
||||
outputStream.write(genotypesBlock);
|
||||
}
|
||||
|
||||
public final BCFType encodeStringByRef(final String string) throws IOException {
|
||||
public final BCF2Type encodeStringByRef(final String string) throws IOException {
|
||||
return encodeStringsByRef(Collections.singleton(string));
|
||||
}
|
||||
|
||||
public final BCFType encodeStringsByRef(final Collection<String> strings) throws IOException {
|
||||
public final BCF2Type encodeStringsByRef(final Collection<String> strings) throws IOException {
|
||||
final List<Integer> offsets = new ArrayList<Integer>(strings.size());
|
||||
BCFType maxType = BCFType.INT8; // start with the smallest size
|
||||
BCF2Type maxType = BCF2Type.INT8; // start with the smallest size
|
||||
|
||||
// iterate over strings until we find one that needs 16 bits, and break
|
||||
for ( final String string : strings ) {
|
||||
final int offset = stringDictionary.get(string);
|
||||
offsets.add(offset);
|
||||
final BCFType type1 = encoder.determineIntegerType(offset);
|
||||
final BCF2Type type1 = encoder.determineIntegerType(offset);
|
||||
switch ( type1 ) {
|
||||
case INT8: break;
|
||||
case INT16: if ( maxType == BCFType.INT8 ) maxType = BCFType.INT16; break;
|
||||
case INT32: maxType = BCFType.INT32; break;
|
||||
case INT16: if ( maxType == BCF2Type.INT8 ) maxType = BCF2Type.INT16; break;
|
||||
case INT32: maxType = BCF2Type.INT32; break;
|
||||
default: throw new ReviewedStingException("Unexpected type " + type1);
|
||||
}
|
||||
}
|
||||
|
|
@ -380,7 +385,7 @@ public class BCF2Writer extends IndexingVCFWriter {
|
|||
return maxType;
|
||||
}
|
||||
|
||||
public final void startGenotypeField(final String key, final int size, final BCFType valueType) throws IOException {
|
||||
public final void startGenotypeField(final String key, final int size, final BCF2Type valueType) throws IOException {
|
||||
encodeStringByRef(key);
|
||||
encoder.encodeType(size, valueType);
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
import com.google.java.contract.Ensures;
|
||||
import com.google.java.contract.Requires;
|
||||
|
|
@ -33,6 +33,7 @@ import org.broad.tribble.index.Index;
|
|||
import org.broad.tribble.index.IndexFactory;
|
||||
import org.broad.tribble.util.LittleEndianOutputStream;
|
||||
import org.broadinstitute.sting.gatk.refdata.tracks.IndexDictionaryUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
/**
|
||||
* this class writes VCF files, allowing records to be passed in unsorted.
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
|
|
@ -23,8 +23,9 @@
|
|||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -22,11 +22,12 @@
|
|||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
import net.sf.samtools.SAMSequenceDictionary;
|
||||
import org.broad.tribble.TribbleException;
|
||||
import org.broad.tribble.util.ParsingUtils;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package org.broadinstitute.sting.utils.codecs.vcf;
|
||||
package org.broadinstitute.sting.utils.codecs.vcf.writer;
|
||||
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
||||
/**
|
||||
|
|
@ -50,91 +50,91 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
|
||||
@BeforeSuite
|
||||
public void before() {
|
||||
basicTypes.add(new BCF2TypedValue(1, BCFType.INT8));
|
||||
basicTypes.add(new BCF2TypedValue(1000, BCFType.INT16));
|
||||
basicTypes.add(new BCF2TypedValue(1000000, BCFType.INT32));
|
||||
basicTypes.add(new BCF2TypedValue(1.2345e6, BCFType.FLOAT));
|
||||
basicTypes.add(new BCF2TypedValue(new Byte((byte)'A'), BCFType.CHAR));
|
||||
basicTypes.add(new BCF2TypedValue(1, BCF2Type.INT8));
|
||||
basicTypes.add(new BCF2TypedValue(1000, BCF2Type.INT16));
|
||||
basicTypes.add(new BCF2TypedValue(1000000, BCF2Type.INT32));
|
||||
basicTypes.add(new BCF2TypedValue(1.2345e6, BCF2Type.FLOAT));
|
||||
basicTypes.add(new BCF2TypedValue(new Byte((byte)'A'), BCF2Type.CHAR));
|
||||
|
||||
// small ints
|
||||
primitives.add(new BCF2TypedValue(0, BCFType.INT8));
|
||||
primitives.add(new BCF2TypedValue(10, BCFType.INT8));
|
||||
primitives.add(new BCF2TypedValue(-1, BCFType.INT8));
|
||||
primitives.add(new BCF2TypedValue(100, BCFType.INT8));
|
||||
primitives.add(new BCF2TypedValue(-100, BCFType.INT8));
|
||||
primitives.add(new BCF2TypedValue(-127, BCFType.INT8)); // last value in range
|
||||
primitives.add(new BCF2TypedValue( 127, BCFType.INT8)); // last value in range
|
||||
primitives.add(new BCF2TypedValue(0, BCF2Type.INT8));
|
||||
primitives.add(new BCF2TypedValue(10, BCF2Type.INT8));
|
||||
primitives.add(new BCF2TypedValue(-1, BCF2Type.INT8));
|
||||
primitives.add(new BCF2TypedValue(100, BCF2Type.INT8));
|
||||
primitives.add(new BCF2TypedValue(-100, BCF2Type.INT8));
|
||||
primitives.add(new BCF2TypedValue(-127, BCF2Type.INT8)); // last value in range
|
||||
primitives.add(new BCF2TypedValue( 127, BCF2Type.INT8)); // last value in range
|
||||
|
||||
// medium ints
|
||||
primitives.add(new BCF2TypedValue(-1000, BCFType.INT16));
|
||||
primitives.add(new BCF2TypedValue(1000, BCFType.INT16));
|
||||
primitives.add(new BCF2TypedValue(-128, BCFType.INT16)); // first value in range
|
||||
primitives.add(new BCF2TypedValue( 128, BCFType.INT16)); // first value in range
|
||||
primitives.add(new BCF2TypedValue(-32767, BCFType.INT16)); // last value in range
|
||||
primitives.add(new BCF2TypedValue( 32767, BCFType.INT16)); // last value in range
|
||||
primitives.add(new BCF2TypedValue(-1000, BCF2Type.INT16));
|
||||
primitives.add(new BCF2TypedValue(1000, BCF2Type.INT16));
|
||||
primitives.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range
|
||||
primitives.add(new BCF2TypedValue( 128, BCF2Type.INT16)); // first value in range
|
||||
primitives.add(new BCF2TypedValue(-32767, BCF2Type.INT16)); // last value in range
|
||||
primitives.add(new BCF2TypedValue( 32767, BCF2Type.INT16)); // last value in range
|
||||
|
||||
// larger ints
|
||||
primitives.add(new BCF2TypedValue(-32768, BCFType.INT32)); // first value in range
|
||||
primitives.add(new BCF2TypedValue( 32768, BCFType.INT32)); // first value in range
|
||||
primitives.add(new BCF2TypedValue(-100000, BCFType.INT32));
|
||||
primitives.add(new BCF2TypedValue(100000, BCFType.INT32));
|
||||
primitives.add(new BCF2TypedValue(-2147483647, BCFType.INT32));
|
||||
primitives.add(new BCF2TypedValue(2147483647, BCFType.INT32));
|
||||
primitives.add(new BCF2TypedValue(-32768, BCF2Type.INT32)); // first value in range
|
||||
primitives.add(new BCF2TypedValue( 32768, BCF2Type.INT32)); // first value in range
|
||||
primitives.add(new BCF2TypedValue(-100000, BCF2Type.INT32));
|
||||
primitives.add(new BCF2TypedValue(100000, BCF2Type.INT32));
|
||||
primitives.add(new BCF2TypedValue(-2147483647, BCF2Type.INT32));
|
||||
primitives.add(new BCF2TypedValue(2147483647, BCF2Type.INT32));
|
||||
|
||||
// floats
|
||||
primitives.add(new BCF2TypedValue(0.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-0.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.1, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.1, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(5.0 / 3.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-5.0 / 3.0, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e3, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e6, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e9, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e12, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e15, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e3, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e6, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e9, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e12, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e15, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.MIN_VALUE, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.MAX_VALUE, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.NEGATIVE_INFINITY, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.POSITIVE_INFINITY, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.NaN, BCFType.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-0.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.1, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.1, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(5.0 / 3.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-5.0 / 3.0, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e3, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e9, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e12, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(1.23e15, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e3, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e9, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e12, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(-1.23e15, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.MIN_VALUE, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.MAX_VALUE, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.NEGATIVE_INFINITY, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.POSITIVE_INFINITY, BCF2Type.FLOAT));
|
||||
primitives.add(new BCF2TypedValue(Float.NaN, BCF2Type.FLOAT));
|
||||
|
||||
// strings
|
||||
//primitives.add(new BCF2TypedValue("", BCFType.CHAR)); <- will be null (which is right)
|
||||
primitives.add(new BCF2TypedValue("S", BCFType.CHAR));
|
||||
primitives.add(new BCF2TypedValue("S2", BCFType.CHAR));
|
||||
primitives.add(new BCF2TypedValue("12345678910", BCFType.CHAR));
|
||||
primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCFType.CHAR));
|
||||
primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCFType.CHAR));
|
||||
primitives.add(new BCF2TypedValue("S", BCF2Type.CHAR));
|
||||
primitives.add(new BCF2TypedValue("S2", BCF2Type.CHAR));
|
||||
primitives.add(new BCF2TypedValue("12345678910", BCF2Type.CHAR));
|
||||
primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR));
|
||||
primitives.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR));
|
||||
|
||||
// missing values
|
||||
for ( BCFType type : BCFType.values() ) {
|
||||
for ( BCF2Type type : BCF2Type.values() ) {
|
||||
primitives.add(new BCF2TypedValue(null, type));
|
||||
}
|
||||
|
||||
forCombinations.add(new BCF2TypedValue(10, BCFType.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(100, BCFType.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(-100, BCFType.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(-128, BCFType.INT16)); // first value in range
|
||||
forCombinations.add(new BCF2TypedValue( 128, BCFType.INT16)); // first value in range
|
||||
forCombinations.add(new BCF2TypedValue(-100000, BCFType.INT32));
|
||||
forCombinations.add(new BCF2TypedValue(100000, BCFType.INT32));
|
||||
forCombinations.add(new BCF2TypedValue(0.0, BCFType.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue(1.23e6, BCFType.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue(-1.23e6, BCFType.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue("S", BCFType.CHAR));
|
||||
forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCFType.CHAR));
|
||||
forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCFType.CHAR));
|
||||
forCombinations.add(new BCF2TypedValue(10, BCF2Type.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(100, BCF2Type.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(-100, BCF2Type.INT8));
|
||||
forCombinations.add(new BCF2TypedValue(-128, BCF2Type.INT16)); // first value in range
|
||||
forCombinations.add(new BCF2TypedValue( 128, BCF2Type.INT16)); // first value in range
|
||||
forCombinations.add(new BCF2TypedValue(-100000, BCF2Type.INT32));
|
||||
forCombinations.add(new BCF2TypedValue(100000, BCF2Type.INT32));
|
||||
forCombinations.add(new BCF2TypedValue(0.0, BCF2Type.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue(1.23e6, BCF2Type.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue(-1.23e6, BCF2Type.FLOAT));
|
||||
forCombinations.add(new BCF2TypedValue("S", BCF2Type.CHAR));
|
||||
forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR));
|
||||
forCombinations.add(new BCF2TypedValue("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", BCF2Type.CHAR));
|
||||
|
||||
// missing values
|
||||
for ( BCFType type : BCFType.values() ) {
|
||||
for ( BCF2Type type : BCF2Type.values() ) {
|
||||
forCombinations.add(new BCF2TypedValue(null, type));
|
||||
}
|
||||
|
||||
|
|
@ -147,18 +147,18 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
// --------------------------------------------------------------------------------
|
||||
|
||||
private class BCF2TypedValue {
|
||||
final BCFType type;
|
||||
final BCF2Type type;
|
||||
final Object value;
|
||||
|
||||
private BCF2TypedValue(final int value, final BCFType type) {
|
||||
private BCF2TypedValue(final int value, final BCF2Type type) {
|
||||
this(new Integer(value), type);
|
||||
}
|
||||
|
||||
private BCF2TypedValue(final double value, final BCFType type) {
|
||||
private BCF2TypedValue(final double value, final BCF2Type type) {
|
||||
this(new Float(value), type);
|
||||
}
|
||||
|
||||
private BCF2TypedValue(final Object value, final BCFType type) {
|
||||
private BCF2TypedValue(final Object value, final BCF2Type type) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
|
@ -214,7 +214,7 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
BCF2Decoder decoder = new BCF2Decoder(encoder.getRecordBytes());
|
||||
final Object decoded = decoder.decodeTypedValue();
|
||||
|
||||
if ( tv.type == BCFType.CHAR ) {
|
||||
if ( tv.type == BCF2Type.CHAR ) {
|
||||
Assert.assertTrue(decoded instanceof String);
|
||||
final String decodedString = (String)decoded;
|
||||
Assert.assertTrue(decodedString.length() == length);
|
||||
|
|
@ -232,7 +232,7 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
@Test(dataProvider = "BCF2EncodingTestProviderBasicTypes")
|
||||
public void testBCF2EncodingVectorsWithMissing(final List<BCF2TypedValue> toEncode) throws IOException {
|
||||
for ( final BCF2TypedValue tv : toEncode ) {
|
||||
if ( tv.type != BCFType.CHAR ) {
|
||||
if ( tv.type != BCF2Type.CHAR ) {
|
||||
for ( final int length : Arrays.asList(2, 5, 10, 15, 20, 25) ) {
|
||||
final byte td = TypeDescriptor.encodeTypeDescriptor(1, tv.type);
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
if ( tv.isMissing() )
|
||||
encoder.encodeTypedMissing(tv.type);
|
||||
else {
|
||||
final BCFType encodedType = encoder.encode(tv.value);
|
||||
final BCF2Type encodedType = encoder.encode(tv.value);
|
||||
if ( tv.type != null ) // only if we have an expectation
|
||||
Assert.assertEquals(encodedType, tv.type);
|
||||
}
|
||||
|
|
@ -345,7 +345,7 @@ public class EncoderDecoderUnitTest extends BaseTest {
|
|||
private final void myAssertEquals(final BCF2TypedValue tv, final Object decoded) {
|
||||
if ( tv.value == null ) { // special needs for instanceof double
|
||||
Assert.assertEquals(decoded, tv.value);
|
||||
} else if ( tv.type == BCFType.FLOAT ) { // need tolerance for floats, and they aren't null
|
||||
} else if ( tv.type == BCF2Type.FLOAT ) { // need tolerance for floats, and they aren't null
|
||||
Assert.assertTrue(decoded instanceof Double);
|
||||
|
||||
final float valueFloat = (float)(Float)tv.value;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import org.broad.tribble.CloseableTribbleIterator;
|
|||
import org.broad.tribble.Tribble;
|
||||
import org.broad.tribble.index.*;
|
||||
import org.broadinstitute.sting.BaseTest;
|
||||
import org.broadinstitute.sting.WalkerTest;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.fasta.CachingIndexedFastaSequenceFile;
|
||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package org.broadinstitute.sting.utils.genotype.vcf;
|
|||
import org.broad.tribble.AbstractFeatureReader;
|
||||
import org.broad.tribble.FeatureReader;
|
||||
import org.broad.tribble.Tribble;
|
||||
import org.broad.tribble.readers.AsciiLineReader;
|
||||
import org.broad.tribble.readers.PositionalBufferedStream;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.StandardVCFWriter;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.writer.VCFWriter;
|
||||
import org.broadinstitute.sting.utils.variantcontext.*;
|
||||
import org.broadinstitute.sting.utils.codecs.vcf.*;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
|
|
@ -19,7 +19,6 @@ import org.testng.annotations.Test;
|
|||
import org.testng.annotations.BeforeClass;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
|
|
|||
Loading…
Reference in New Issue