Cut DeNovoSNPWalker over to the new Variation system, some renaming of methods on the Variation interface, and some corrections on the interface.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1724 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2009-09-25 04:35:52 +00:00
parent 392152f149
commit 7ffc1d97ef
16 changed files with 112 additions and 98 deletions

View File

@ -28,7 +28,7 @@ public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes,
* @return * @return
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return getAltBasesFWD(); return getAltBasesFWD();
} }
@ -38,7 +38,7 @@ public class PooledEMSNPROD extends TabularROD implements SNPCallFromGenotypes,
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> str = new ArrayList<String>(); List<String> str = new ArrayList<String>();
str.add(this.getAltBasesFWD()); str.add(this.getAltBasesFWD());
return str; return str;

View File

@ -161,9 +161,9 @@ public class RodGLF implements VariationRod, Iterator<RodGLF> {
@Override @Override
public char getAlternativeBaseForSNP() { public char getAlternativeBaseForSNP() {
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP"); if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
if (getAlternateBase().charAt(0) == this.getReference().charAt(0)) if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
return getAlternateBase().charAt(1); return getAlternateBases().charAt(1);
return getAlternateBase().charAt(0); return getAlternateBases().charAt(0);
} }
@ -175,9 +175,9 @@ public class RodGLF implements VariationRod, Iterator<RodGLF> {
@Override @Override
public char getReferenceForSNP() { public char getReferenceForSNP() {
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP"); if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
if (getAlternateBase().charAt(0) == this.getReference().charAt(0)) if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
return getAlternateBase().charAt(0); return getAlternateBases().charAt(0);
return getAlternateBase().charAt(1); return getAlternateBases().charAt(1);
} }
@ -259,7 +259,7 @@ public class RodGLF implements VariationRod, Iterator<RodGLF> {
* @return a string, of ploidy * @return a string, of ploidy
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return this.getBestGenotype(0).toString(); return this.getBestGenotype(0).toString();
} }
@ -269,9 +269,9 @@ public class RodGLF implements VariationRod, Iterator<RodGLF> {
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(this.getAlternateBase()); list.add(this.getAlternateBases());
return list; return list;
} }

View File

@ -193,7 +193,7 @@ public class RodGeliText extends BasicReferenceOrderedDatum implements Variation
* @return a string, of ploidy * @return a string, of ploidy
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return this.bestGenotype; return this.bestGenotype;
} }
@ -203,9 +203,9 @@ public class RodGeliText extends BasicReferenceOrderedDatum implements Variation
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(this.getAlternateBase()); list.add(this.getAlternateBases());
return list; return list;
} }

View File

@ -187,7 +187,7 @@ public class RodGenotypeChipAsGFF extends BasicReferenceOrderedDatum implements
* @return * @return
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return this.feature; return this.feature;
} }
@ -197,9 +197,9 @@ public class RodGenotypeChipAsGFF extends BasicReferenceOrderedDatum implements
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(this.getAlternateBase()); list.add(this.getAlternateBases());
return list; return list;
} }

View File

@ -171,7 +171,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod,
/** are we bi-allelic? */ /** are we bi-allelic? */
@Override @Override
public boolean isBiallelic() { public boolean isBiallelic() {
return (this.getAlternateBases().size() == 1); return (this.getAlternateBaseList().size() == 1);
} }
/** /**
@ -201,8 +201,8 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod,
* @return * @return
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
if (!this.isBiallelic()) throw new UnsupportedOperationException("We're not biallelic, so please call getAlternateBases instead"); if (!this.isBiallelic()) throw new UnsupportedOperationException("We're not biallelic, so please call getAlternateBaseList instead");
return this.mCurrentRecord.getAlternateAlleles().get(0); return this.mCurrentRecord.getAlternateAlleles().get(0);
} }
@ -212,7 +212,7 @@ public class RodVCF extends BasicReferenceOrderedDatum implements VariationRod,
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
return this.mCurrentRecord.getAlternateAlleles(); return this.mCurrentRecord.getAlternateAlleles();
} }

View File

@ -73,7 +73,7 @@ public class SimpleIndelROD extends TabularROD implements Genotype, AllelicVaria
* @return * @return
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return ""; return "";
} }
@ -83,7 +83,7 @@ public class SimpleIndelROD extends TabularROD implements Genotype, AllelicVaria
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
return Arrays.asList(new String[]{""}); return Arrays.asList(new String[]{""});
} }
@ -171,4 +171,4 @@ public class SimpleIndelROD extends TabularROD implements Genotype, AllelicVaria
} }
return KGENOMES_FORMAT; return KGENOMES_FORMAT;
} }
} }

View File

@ -174,7 +174,7 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
* @return a string, of ploidy * @return a string, of ploidy
*/ */
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return getAllelesFWDString(); return getAllelesFWDString();
} }
@ -184,9 +184,9 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(this.getAlternateBase()); list.add(this.getAlternateBases());
return list; return list;
} }
@ -204,9 +204,9 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements VariationRod
public char getAlternativeBaseForSNP() { public char getAlternativeBaseForSNP() {
return getAltSnpFWD(); /* return getAltSnpFWD(); /*
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP"); if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
if (getAlternateBase().charAt(0) == this.getReference()) if (getAlternateBases().charAt(0) == this.getReference())
return getAlternateBase().charAt(1); return getAlternateBases().charAt(1);
return getAlternateBase().charAt(0); */ return getAlternateBases().charAt(0); */
} }
/** /**

View File

@ -1,7 +1,10 @@
package org.broadinstitute.sting.gatk.walkers.filters; package org.broadinstitute.sting.gatk.walkers.filters;
import org.broadinstitute.sting.gatk.contexts.VariantContext; import org.broadinstitute.sting.gatk.contexts.VariantContext;
import org.broadinstitute.sting.gatk.refdata.*; import org.broadinstitute.sting.gatk.refdata.CleanedOutSNPROD;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.refdata.rodDbSNP;
import org.broadinstitute.sting.utils.genotype.Variation;
import java.util.HashMap; import java.util.HashMap;
@ -23,7 +26,7 @@ public class VECIndelArtifact implements VariantExclusionCriterion {
return; return;
} }
AllelicVariant indelCall = (AllelicVariant)tracker.lookup("indels", null); Variation indelCall = (Variation)tracker.lookup("indels", null);
if ( indelCall != null ) { if ( indelCall != null ) {
exclude = true; exclude = true;
source = "IndelCall"; source = "IndelCall";

View File

@ -1,11 +1,14 @@
package org.broadinstitute.sting.gatk.walkers.indels; package org.broadinstitute.sting.gatk.walkers.indels;
import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.utils.*; import org.broadinstitute.sting.gatk.refdata.AllelicVariant;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import org.broadinstitute.sting.gatk.walkers.*; import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import org.broadinstitute.sting.utils.cmdLine.Argument; import org.broadinstitute.sting.utils.cmdLine.Argument;
import org.broadinstitute.sting.utils.genotype.Variation;
@WalkerName("SNPClusters") @WalkerName("SNPClusters")
@Requires(value={DataSource.REFERENCE},referenceMetaData={@RMD(name="snps",type=AllelicVariant.class)}) @Requires(value={DataSource.REFERENCE},referenceMetaData={@RMD(name="snps",type=AllelicVariant.class)})
@ -19,7 +22,7 @@ public class SNPClusterWalker extends RefWalker<GenomeLoc, GenomeLoc> {
} }
public GenomeLoc map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { public GenomeLoc map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
AllelicVariant snp = (AllelicVariant)tracker.lookup("snps", null); Variation snp = (Variation)tracker.lookup("snps", null);
return (snp != null && snp.isSNP()) ? context.getLocation() : null; return (snp != null && snp.isSNP()) ? context.getLocation() : null;
} }

View File

@ -1,13 +1,13 @@
package org.broadinstitute.sting.playground.gatk.walkers; package org.broadinstitute.sting.playground.gatk.walkers;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.gatk.refdata.*;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext; import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.utils.GenotypeUtils; import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
import java.util.List; import org.broadinstitute.sting.gatk.refdata.VariationRod;
import java.util.Collection; import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.StingException;
import org.broadinstitute.sting.utils.genotype.VariantBackedByGenotype;
import org.broadinstitute.sting.utils.genotype.Variation;
/** /**
* Created by IntelliJ IDEA. * Created by IntelliJ IDEA.
@ -17,38 +17,42 @@ import java.util.Collection;
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
@By(DataSource.REFERENCE) @By(DataSource.REFERENCE)
@Requires(value={DataSource.REFERENCE},referenceMetaData={@RMD(name="child",type= AllelicVariant.class), @RMD(name="parent1",type= AllelicVariant.class), @RMD(name="parent2",type= AllelicVariant.class)}) @Requires(value={DataSource.REFERENCE},referenceMetaData={@RMD(name="child",type= VariationRod.class), @RMD(name="parent1",type= VariationRod.class), @RMD(name="parent2",type= VariationRod.class)})
//@Allows(value={DataSource.REFERENCE},referenceMetaData = {@RMD(name="eval",type=AllelicVariant.class), @RMD(name="dbsnp",type=AllelicVariant.class),@RMD(name="hapmap-chip",type=AllelicVariant.class), @RMD(name="interval",type=IntervalRod.class)}) //@Allows(value={DataSource.REFERENCE},referenceMetaData = {@RMD(name="eval",type=AllelicVariant.class), @RMD(name="dbsnp",type=AllelicVariant.class),@RMD(name="hapmap-chip",type=AllelicVariant.class), @RMD(name="interval",type=IntervalRod.class)})
//@Allows(value={DataSource.REFERENCE},referenceMetaData = {@RMD(name="dbsnp",type=AllelicVariant.class)}) //@Allows(value={DataSource.REFERENCE},referenceMetaData = {@RMD(name="dbsnp",type=AllelicVariant.class)})
public class DeNovoSNPWalker extends RefWalker<String, Integer>{ public class DeNovoSNPWalker extends RefWalker<String, Integer>{
public String map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) { public String map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
AllelicVariant child = (AllelicVariant)tracker.lookup("child", null); Variation child = (Variation)tracker.lookup("child", null);
AllelicVariant parent1 = (AllelicVariant)tracker.lookup("parent1", null); Variation parent1 = (Variation)tracker.lookup("parent1", null);
AllelicVariant parent2 = (AllelicVariant)tracker.lookup("parent2", null); Variation parent2 = (Variation)tracker.lookup("parent2", null);
AllelicVariant dbsnp = (AllelicVariant)tracker.lookup("dbSNP", null); Variation dbsnp = (Variation)tracker.lookup("dbSNP", null);
if (child != null && parent1 != null && parent2 != null) { if (child != null && parent1 != null && parent2 != null) {
if (!(parent1 instanceof VariantBackedByGenotype) || !(parent2 instanceof VariantBackedByGenotype))
throw new StingException("Both parents ROD tracks must be backed by genotype data. Ensure that your parent rod(s) contain genotyping information");
if (child.isSNP() && if (child.isSNP() &&
child.getVariationConfidence() > 5 && // BTR > 5 child.getNegLog10PError() > 5 && // BTR > 5
parent1.isReference() && parent1.isReference() &&
parent1.getConsensusConfidence() > 5 && ((VariantBackedByGenotype)parent1).getCalledGenotype().getNegLog10PError() > 5 &&
parent2.isReference() && parent2.isReference() &&
parent2.getConsensusConfidence() > 5 ((VariantBackedByGenotype)parent2).getCalledGenotype().getNegLog10PError() > 5
) { ) {
double sumConfidences = 0.5 * (0.5 * child.getVariationConfidence() + Math.min(parent1.getConsensusConfidence(), parent2.getConsensusConfidence())); double sumConfidences = 0.5 * (0.5 * child.getNegLog10PError() +
Math.min(((VariantBackedByGenotype)parent1).getCalledGenotype().getNegLog10PError(),
((VariantBackedByGenotype)parent2).getCalledGenotype().getNegLog10PError()));
out.format("%s\t", child.getLocation().getContig()); out.format("%s\t", child.getLocation().getContig());
out.format("%s\t", child.getLocation().getStart()); out.format("%s\t", child.getLocation().getStart());
out.format("%.4f\t", sumConfidences); out.format("%.4f\t", sumConfidences);
out.format("%.4f\t", child.getVariationConfidence()); out.format("%.4f\t", child.getNegLog10PError());
out.format("%.4f\t", parent1.getConsensusConfidence()); out.format("%.4f\t", ((VariantBackedByGenotype)parent1).getCalledGenotype().getNegLog10PError());
out.format("%.4f\t", parent2.getConsensusConfidence()); out.format("%.4f\t", ((VariantBackedByGenotype)parent2).getCalledGenotype().getNegLog10PError());
out.format("%s\t", dbsnp != null); out.format("%s\t", dbsnp != null);
out.format ("%s\t", child.toString()); out.format ("%s\t", child.toString());
out.format ("%s\t", parent1.toString()); out.format ("%s\t", parent1.toString());
out.format ("%s", parent2.toSimpleString()); out.format ("%s", parent2.toString());
if (dbsnp != null) if (dbsnp != null)
out.format ("\tDBSNP\t:%s", dbsnp.toString()); out.format ("\tDBSNP\t:%s", dbsnp.toString());
out.println(); out.println();

View File

@ -58,18 +58,18 @@ public class GenotypeConcordance extends BasicVariantAnalysis implements Genotyp
int truthIndex, callIndex; int truthIndex, callIndex;
if (chip == null) if (chip == null)
truthIndex = UNKNOWN; truthIndex = UNKNOWN;
else if (chip.getAlternateBase().equals(g.toString())) else if (chip.getAlternateBases().equals(g.toString()))
truthIndex = REF; truthIndex = REF;
else if (chip.getAlternateBase().charAt(0) != chip.getAlternateBase().charAt(1)) else if (chip.getAlternateBases().charAt(0) != chip.getAlternateBases().charAt(1))
truthIndex = VAR_HET; truthIndex = VAR_HET;
else else
truthIndex = VAR_HOM; truthIndex = VAR_HOM;
if (eval == null) if (eval == null)
callIndex = NO_CALL; callIndex = NO_CALL;
else if (eval.getAlternateBase().equals(g.toString())) else if (eval.getAlternateBases().equals(g.toString()))
callIndex = REF; callIndex = REF;
else if (eval.getAlternateBase().charAt(0) != eval.getAlternateBase().charAt(1)) else if (eval.getAlternateBases().charAt(0) != eval.getAlternateBases().charAt(1))
callIndex = VAR_HET; callIndex = VAR_HET;
else else
callIndex = VAR_HOM; callIndex = VAR_HOM;

View File

@ -38,10 +38,10 @@ public class IndelMetricsAnalysis extends BasicVariantAnalysis implements Genoty
else else
throw new RuntimeException("Variation is indel, but isn't insertion or deletion!"); throw new RuntimeException("Variation is indel, but isn't insertion or deletion!");
if ( eval.getAlternateBase().length() < 100 ) { if ( eval.getAlternateBases().length() < 100 ) {
sizes[eval.isDeletion() ? 0 : 1][eval.getAlternateBase().length()]++; sizes[eval.isDeletion() ? 0 : 1][eval.getAlternateBases().length()]++;
if ( eval.getAlternateBase().length() > maxSize ) if ( eval.getAlternateBases().length() > maxSize )
maxSize = eval.getAlternateBase().length(); maxSize = eval.getAlternateBases().length();
} }
} }

View File

@ -183,7 +183,7 @@ class PooledConcordanceTable {
public boolean pooledCallIsRef(Variation eval, char ref) { public boolean pooledCallIsRef(Variation eval, char ref) {
// code broken out for easy alteration when we start using pool-specific variations // code broken out for easy alteration when we start using pool-specific variations
return eval.getAlternateBase().equalsIgnoreCase((Utils.dupString(ref,2))); return eval.getAlternateBases().equalsIgnoreCase((Utils.dupString(ref,2)));
} }
public int calculateNumFrequencyIndeces(int poolSize) { public int calculateNumFrequencyIndeces(int poolSize) {
@ -207,7 +207,7 @@ class PooledConcordanceTable {
for ( Variation eval : evals ) { for ( Variation eval : evals ) {
if ( mismatchingCalls(firstEval, eval, ref) ) { if ( mismatchingCalls(firstEval, eval, ref) ) {
// todo -- make this not a StingException but go to the log // todo -- make this not a StingException but go to the log
throw new StingException("Tri-Allelic Position "+eval.getAlternateBase()+"/"+firstEval.getAlternateBase() + " Ref: "+ ref + " not supported"); throw new StingException("Tri-Allelic Position "+eval.getAlternateBases()+"/"+firstEval.getAlternateBases() + " Ref: "+ ref + " not supported");
} else { } else {
alternateFrequency += calledVariantFrequency(eval,ref); alternateFrequency += calledVariantFrequency(eval,ref);
} }
@ -231,10 +231,10 @@ class PooledConcordanceTable {
public boolean mismatchingCalls(Variation eval, Variation chip, char ref) { public boolean mismatchingCalls(Variation eval, Variation chip, char ref) {
// eval and chip guaranteed to be non-null // eval and chip guaranteed to be non-null
char chipF = chip.getAlternateBase().charAt(0); char chipF = chip.getAlternateBases().charAt(0);
char chipS = chip.getAlternateBase().charAt(1); char chipS = chip.getAlternateBases().charAt(1);
char evalF = chip.getAlternateBase().charAt(0); char evalF = chip.getAlternateBases().charAt(0);
char evalS = chip.getAlternateBase().charAt(1); char evalS = chip.getAlternateBases().charAt(1);
boolean mismatch; boolean mismatch;
if (chipF == ref) { if (chipF == ref) {
if ( chipS == ref ) { if ( chipS == ref ) {
@ -259,7 +259,7 @@ class PooledConcordanceTable {
public double calledVariantFrequency( Variation var, char ref ) { public double calledVariantFrequency( Variation var, char ref ) {
// code broken out for easy alteration when we start using pool-specific variations // code broken out for easy alteration when we start using pool-specific variations
String varStr = var.getAlternateBase(); String varStr = var.getAlternateBases();
double freq; double freq;
if ( varStr.charAt(0) != ref && varStr.charAt(1) != ref ) { if ( varStr.charAt(0) != ref && varStr.charAt(1) != ref ) {
freq = (double) 2; freq = (double) 2;

View File

@ -92,7 +92,7 @@ public class VariantDBCoverage extends BasicVariantAnalysis implements GenotypeA
if (eval != null) { if (eval != null) {
char alt = (eval.isSNP()) ? eval.getAlternativeBaseForSNP() : eval.getReference().charAt(0); char alt = (eval.isSNP()) ? eval.getAlternativeBaseForSNP() : eval.getReference().charAt(0);
if (dbSNP != null && dbSNP.isSNP()) if (dbSNP != null && dbSNP.isSNP())
return !dbSNP.getAlternateBase().contains(String.valueOf(alt)); return !dbSNP.getAlternateBases().contains(String.valueOf(alt));
} }
return false; return false;
} }
@ -125,7 +125,7 @@ public class VariantDBCoverage extends BasicVariantAnalysis implements GenotypeA
if (dbsnp.isSNP() && eval.isSNP() && discordantP(dbsnp, eval)) { if (dbsnp.isSNP() && eval.isSNP() && discordantP(dbsnp, eval)) {
return String.format("Discordant [DBSNP %s] [EVAL %s]", dbsnp, eval); return String.format("Discordant [DBSNP %s] [EVAL %s]", dbsnp, eval);
} else if (dbsnp.isIndel() && eval.isSNP()) { } else if (dbsnp.isIndel() && eval.isSNP()) {
return String.format("SNP-at-indel DBSNP=%s %s", dbsnp.getAlternateBase(), eval); return String.format("SNP-at-indel DBSNP=%s %s", dbsnp.getAlternateBases(), eval);
} else { } else {
return null; return null;
} }

View File

@ -83,7 +83,7 @@ public class BasicVariation implements Variation {
} }
@Override @Override
public String getAlternateBase() { public String getAlternateBases() {
return mBases; return mBases;
} }
@ -93,9 +93,9 @@ public class BasicVariation implements Variation {
* @return * @return
*/ */
@Override @Override
public List<String> getAlternateBases() { public List<String> getAlternateBaseList() {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
list.add(this.getAlternateBase()); list.add(this.getAlternateBases());
return list; return list;
} }
@ -151,9 +151,9 @@ public class BasicVariation implements Variation {
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP"); if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
// we know that if we're a snp, the reference is a single base, so charAt(0) is safe // we know that if we're a snp, the reference is a single base, so charAt(0) is safe
if (getAlternateBase().charAt(0) == this.getReference().charAt(0)) if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
return getAlternateBase().charAt(1); return getAlternateBases().charAt(1);
return getAlternateBase().charAt(0); return getAlternateBases().charAt(0);
} }
/** /**
@ -166,9 +166,9 @@ public class BasicVariation implements Variation {
if (!this.isSNP()) throw new IllegalStateException("we're not a SNP"); if (!this.isSNP()) throw new IllegalStateException("we're not a SNP");
// we know that if we're a snp, the reference is a single base, so charAt(0) is safe // we know that if we're a snp, the reference is a single base, so charAt(0) is safe
if (getAlternateBase().charAt(0) == this.getReference().charAt(0)) if (getAlternateBases().charAt(0) == this.getReference().charAt(0))
return getAlternateBase().charAt(0); return getAlternateBases().charAt(0);
return getAlternateBase().charAt(1); return getAlternateBases().charAt(1);
} }

View File

@ -18,17 +18,21 @@ public interface Variation {
} }
/** /**
* get the frequency of this variant * get the frequency of this variant, if we're a variant. If we're reference this method
* should return 0.
* *
* @return VariantFrequency with the stored frequency * @return double with the stored frequency
*/ */
public double getNonRefAlleleFrequency(); public double getNonRefAlleleFrequency();
/** @return the VARIANT_TYPE of the current variant */ /**
* A convenience method, for switching over the variation type
* @return the VARIANT_TYPE of the current variant
**/
public VARIANT_TYPE getType(); public VARIANT_TYPE getType();
/** /**
* are we a SNP? If not we're a Indel/deletion * are we a SNP? If not we're a Indel/deletion or the reference
* *
* @return true if we're a SNP * @return true if we're a SNP
*/ */
@ -42,12 +46,19 @@ public interface Variation {
public boolean isInsertion(); public boolean isInsertion();
/** /**
* are we an insertion? * are we an deletion?
* *
* @return true if we are, false otherwise * @return true if we are, false otherwise
*/ */
public boolean isDeletion(); public boolean isDeletion();
/**
* are we a variant that represents the reference allele?
*
* @return false if we're a variant(indel, delete, SNP, etc), true if we're hom ref
*/
public boolean isReference();
/** /**
* get the location that this Variant represents * get the location that this Variant represents
* *
@ -68,33 +79,26 @@ public interface Variation {
/** /**
* get the -1 * (log 10 of the error value) * get the -1 * (log 10 of the error value)
* *
* @return the log based error estimate * @return the postive number space log based error estimate
*/ */
public double getNegLog10PError(); public double getNegLog10PError();
/**
* are we truely a variant, given a reference
*
* @return false if we're a variant(indel, delete, SNP, etc), true if we're not
*/
public boolean isReference();
/** /**
* gets the alternate base. Use this method if we're biallelic * gets the alternate base. Use this method if we're biallelic
* *
* @return * @return
*/ */
public String getAlternateBase(); public String getAlternateBases();
/** /**
* gets the alternate bases. Use this method if teh allele count is greater then 2 * gets the alternate bases. Use this method if the allele count is greater then 2 (not biallelic)
* *
* @return * @return
*/ */
public List<String> getAlternateBases(); public List<String> getAlternateBaseList();
/** /**
* are we an insertion or a deletion? yes, then return true. No? Well, false then. * are we an insertion or a deletion? yes, then return true. No? false.
* *
* @return true if we're an insertion or deletion * @return true if we're an insertion or deletion
*/ */