removing the Variation interface.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3216 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2010-04-20 18:56:45 +00:00
parent 7d952a34ae
commit 80c4f88a72
13 changed files with 9 additions and 173 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);
}
}

View File

@ -1,19 +0,0 @@
package org.broadinstitute.sting.utils.genotype;
import org.broadinstitute.sting.utils.GenomeLoc;
import java.util.List;
/**
* @author aaron
* <p/>
* Interface Variant
* <p/>
* 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
}
}

View File

@ -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();
}
}
}

View File

@ -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

View File

@ -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() {

View File

@ -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;