diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java index c2b452344..071cbd777 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGeliText.java @@ -29,7 +29,6 @@ import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.MathUtils; import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.utils.genotype.Variation; import java.io.IOException; import java.util.ArrayList; diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java index ca0664d30..ebe82a1d0 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodGenotypeChipAsGFF.java @@ -5,7 +5,6 @@ import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.utils.Utils; import org.broadinstitute.sting.utils.genotype.DiploidGenotype; -import org.broadinstitute.sting.utils.genotype.Variation; import java.util.*; import java.util.regex.MatchResult; diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java index 76bba464d..b0c5fbc01 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/RodVCF.java @@ -2,7 +2,6 @@ package org.broadinstitute.sting.gatk.refdata; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.vcf.*; import java.io.File; diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/SimpleIndelROD.java b/java/src/org/broadinstitute/sting/gatk/refdata/SimpleIndelROD.java index be4182b49..c2a4ce8bb 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/SimpleIndelROD.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/SimpleIndelROD.java @@ -2,7 +2,6 @@ package org.broadinstitute.sting.gatk.refdata; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.GenomeLocParser; -import org.broadinstitute.sting.utils.genotype.Variation; import java.util.Arrays; import java.util.List; diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java index 90a13bf55..f9ea154ad 100755 --- a/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/VariantContextAdaptors.java @@ -8,7 +8,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.utils.genotype.CalledGenotype; import org.broadinstitute.sting.utils.genotype.LikelihoodObject; -import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.genotype.geli.GeliTextWriter; import org.broadinstitute.sting.utils.genotype.glf.GLFSingleCall; import org.broadinstitute.sting.utils.genotype.glf.GLFWriter; @@ -187,7 +186,7 @@ public class VariantContextAdaptors { for ( VCFGenotypeEncoding s : vcfG.getAlleles() ) { Allele a = Allele.getMatchingAllele(alleles, s.getBases()); if ( a == null ) { - if ( vcf.getType() == Variation.VARIANT_TYPE.INSERTION || vcf.getType() == Variation.VARIANT_TYPE.DELETION ) + if ( vcf.isIndel() ) genotypeAlleles.add(refAllele); else throw new StingException("Invalid VCF genotype allele " + s + " in VCF " + vcf); diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java index 8db06aa9b..a20cc1ecb 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/rodDbSNP.java @@ -2,7 +2,6 @@ package org.broadinstitute.sting.gatk.refdata; import net.sf.samtools.util.SequenceUtil; import org.broadinstitute.sting.utils.*; -import org.broadinstitute.sting.utils.genotype.Variation; import java.util.ArrayList; import java.util.Arrays; diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/graphalign/GraphReferenceBuilder.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/graphalign/GraphReferenceBuilder.java index 9d2308603..7afe6c837 100755 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/graphalign/GraphReferenceBuilder.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/graphalign/GraphReferenceBuilder.java @@ -32,7 +32,6 @@ import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.gatk.walkers.DataSource; import org.broadinstitute.sting.gatk.walkers.RefWalker; import org.broadinstitute.sting.gatk.walkers.Requires; @@ -40,7 +39,6 @@ import org.broadinstitute.sting.gatk.walkers.WalkerName; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException; import org.broadinstitute.sting.commandline.Argument; -import org.broadinstitute.sting.utils.genotype.Variation; import java.io.FileNotFoundException; import java.io.FileOutputStream; diff --git a/java/src/org/broadinstitute/sting/utils/genotype/InvalidGenotypeException.java b/java/src/org/broadinstitute/sting/utils/genotype/InvalidGenotypeException.java deleted file mode 100644 index 45c013d8e..000000000 --- a/java/src/org/broadinstitute/sting/utils/genotype/InvalidGenotypeException.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.broadinstitute.sting.utils.genotype; - - -/** - * - * @author aaron - * - * Class GenotypeException - * - * This exception is thrown when a genotype call is passed in that cannot be processed, i.e. invalid. - */ -public class InvalidGenotypeException extends Exception { - public InvalidGenotypeException(String msg) { - super(msg); - } - - public InvalidGenotypeException(String message, Throwable throwable) { - super(message, throwable); - } -} diff --git a/java/src/org/broadinstitute/sting/utils/genotype/Variation.java b/java/src/org/broadinstitute/sting/utils/genotype/Variation.java deleted file mode 100644 index acde70d76..000000000 --- a/java/src/org/broadinstitute/sting/utils/genotype/Variation.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.broadinstitute.sting.utils.genotype; - -import org.broadinstitute.sting.utils.GenomeLoc; - -import java.util.List; - -/** - * @author aaron - *
- * Interface Variant - * - * This class represents a variant - */ -public interface Variation { - // the types of variants we currently allow - public enum VARIANT_TYPE { - SNP, INSERTION, DELETION, REFERENCE // though reference is not really a variant, we need to represent it - } -} diff --git a/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java deleted file mode 100644 index dc9d07afd..000000000 --- a/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.broadinstitute.sting.utils.genotype.tabular; - -import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.pileup.ReadBackedPileup; -import org.broadinstitute.sting.utils.genotype.*; -import org.broadinstitute.sting.gatk.contexts.variantcontext.*; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.PrintStream; -import java.util.Arrays; - - -/** - * - * @author aaron - * - * Class TabularLF - * - * the tabular likelihood format, as an implementation of the genotype interface - */ -public class TabularLFWriter implements GenotypeWriter { - /** - * where to print the tabular genotype likelihood info to - */ - public PrintStream outStream; - - /** - * construct, writing to a specified file - * @param writeTo file to write to - */ - public TabularLFWriter(File writeTo) { - try { - outStream = new PrintStream(writeTo); - } catch (FileNotFoundException e) { - throw new StingException("Unable to write to specified file: " + writeTo.getName()); - } - // print the header out - outStream.println("location sample_name ref alt genotype qhat qstar lodVsRef lodVsNextBest depth bases"); - } - - /** - * Add a genotype, given a variant context - * - * @param vc the variant context representing the call to add - */ - public void addCall(VariantContext vc) { - if ( vc.getNSamples() != 1 ) - throw new IllegalArgumentException("The tabular LF format does not support multi-sample or no-calls"); - - org.broadinstitute.sting.gatk.contexts.variantcontext.Genotype genotype = vc.getGenotypes().values().iterator().next(); - if ( genotype.isNoCall() ) - throw new IllegalArgumentException("The tabular LF format does not support no-calls"); - - ReadBackedPileup pileup; - double[] likelihoods; - if ( genotype instanceof CalledGenotype) { - pileup = ((CalledGenotype)genotype).getReadBackedPileup(); - likelihoods = ((CalledGenotype)genotype).getLikelihoods(); - } else { - pileup = (ReadBackedPileup)genotype.getAttribute(CalledGenotype.READBACKEDPILEUP_ATTRIBUTE_KEY); - likelihoods = (double[])genotype.getAttribute(CalledGenotype.LIKELIHOODS_ATTRIBUTE_KEY); - } - - if ( likelihoods == null ) { - likelihoods = new double[10]; - Arrays.fill(likelihoods, Double.MIN_VALUE); - } - - int readDepth = pileup == null ? -1 : pileup.size(); - - double nextVrsBest = 0; - double nextVrsRef = 0; - char ref = vc.getReference().toString().charAt(0); - - - /** - * This output is not correct, but I don't we even use this format anymore. If we do, someone - * should change this code - */ - outStream.println(String.format("%s %s %c %s %s %f %f %f %f %d %s", - vc.getLocation().toString(), - "NOT OUTPUTED", - ref, - genotype.getGenotypeString(), - genotype.getGenotypeString(), - -1, - -1, - nextVrsRef, - nextVrsBest, - readDepth, - genotype.getGenotypeString())); - } - - /** finish writing, closing any open files. */ - public void close() { - if (this.outStream != null) { - outStream.close(); - } - } -} diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeEncoding.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeEncoding.java index 61ed7a878..abcf969c6 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeEncoding.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeEncoding.java @@ -13,7 +13,8 @@ public class VCFGenotypeEncoding { SINGLE_BASE, INSERTION, DELETION, - UNCALLED + UNCALLED, + MIXED // this type is only valid in aggregate, not for a single VCFGenotypeEncoding } // our length (0 for SINGLE_BASE), our bases, and our type diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java index be849f685..bf5090d1b 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java @@ -277,37 +277,21 @@ public class VCFRecord { return 0.0; } - public Variation.VARIANT_TYPE getType() { - if ( ! hasAlternateAllele() ) - return Variation.VARIANT_TYPE.REFERENCE; - + public VCFGenotypeEncoding.TYPE getType() { VCFGenotypeEncoding.TYPE type = mAlts.get(0).getType(); for (int i = 1; i < mAlts.size(); i++) { if ( mAlts.get(i).getType() != type ) - throw new IllegalStateException("The record contains multiple encoding types"); + return VCFGenotypeEncoding.TYPE.MIXED; // if we have more than one type, return mixed } - - switch ( type ) { - case SINGLE_BASE: - return Variation.VARIANT_TYPE.SNP; - case UNCALLED: - // If there are no alt alleles, all of the genotypes are reference or no calls, so we're a reference site - return Variation.VARIANT_TYPE.REFERENCE; - case DELETION: - return Variation.VARIANT_TYPE.DELETION; - case INSERTION: - return Variation.VARIANT_TYPE.INSERTION; - } - - throw new IllegalStateException("The record contains unknown genotype encodings"); + return type; } public boolean isDeletion() { - return getType() == Variation.VARIANT_TYPE.DELETION; + return getType() == VCFGenotypeEncoding.TYPE.DELETION; } public boolean isInsertion() { - return getType() == Variation.VARIANT_TYPE.INSERTION; + return getType() == VCFGenotypeEncoding.TYPE.INSERTION; } public boolean isIndel() { @@ -315,7 +299,7 @@ public class VCFRecord { } public boolean isSNP() { - return getType() == Variation.VARIANT_TYPE.SNP; + return getType() == VCFGenotypeEncoding.TYPE.SINGLE_BASE; } public boolean isNovel() { diff --git a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderUnitTest.java b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderUnitTest.java index e20919746..1097a120c 100644 --- a/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderUnitTest.java +++ b/java/test/org/broadinstitute/sting/utils/genotype/vcf/VCFReaderUnitTest.java @@ -15,7 +15,6 @@ import org.broadinstitute.sting.BaseTest; import org.broadinstitute.sting.gatk.refdata.RodVCF; import org.broadinstitute.sting.utils.GenomeLocParser; import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.genotype.Variation; import org.broadinstitute.sting.utils.fasta.IndexedFastaSequenceFile; import org.junit.Assert; import org.junit.BeforeClass;