Different features can now be specified by repeatedly supplying the -F "featurename:arguments" option.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1043 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
kiran 2009-06-18 18:45:03 +00:00
parent 17a5b50ea4
commit e26df45e8e
3 changed files with 18 additions and 9 deletions

View File

@ -8,6 +8,14 @@ import net.sf.samtools.SAMRecord;
import java.util.List;
public class IVFBinomialStrand implements IndependentVariantFeature {
private double strandBalance = 0.5;
public IVFBinomialStrand(String arguments) {
if (arguments != null && !arguments.isEmpty()) {
strandBalance = Double.valueOf(arguments);
}
}
public String getFeatureName() { return "binomial"; }
public double[] compute(char ref, LocusContext context) {
@ -35,7 +43,7 @@ public class IVFBinomialStrand implements IndependentVariantFeature {
}
}
likelihoods[genotypeIndex] = Math.log10(MathUtils.binomialProbability(strandCounts[0], strandCounts[0] + strandCounts[1], 0.5));
likelihoods[genotypeIndex] = Math.log10(MathUtils.binomialProbability(strandCounts[0], strandCounts[0] + strandCounts[1], strandBalance));
}
return likelihoods;

View File

@ -4,7 +4,7 @@ import org.broadinstitute.sting.gatk.LocusContext;
public interface IndependentVariantFeature {
public enum Genotype { AA, AC, AG, AT, CC, CG, CT, GG, GT, TT }
public String getFeatureName();
public double[] compute(char ref, LocusContext context);

View File

@ -18,15 +18,12 @@ import java.io.FileNotFoundException;
@Requires(value={DataSource.READS, DataSource.REFERENCE},referenceMetaData=@RMD(name="variant",type=rodVariants.class))
public class VariantFiltrationWalker extends LocusWalker<Integer, Integer> {
@Argument(fullName="features", shortName="F", doc="Comma-separated list of feature tests to apply to genotype posteriors.") public String FEATURES;
@Argument(fullName="features", shortName="F", doc="Feature test (optionally with arguments) to apply to genotype posteriors. Syntax: 'testname:arg1,arg2,...,argN'") public String[] FEATURES;
@Argument(fullName="variants_out", shortName="VO", doc="File to which modified variants should be written") public File VARIANTS_OUT;
private String[] features;
private PrintWriter vwriter;
public void initialize() {
features = FEATURES.split(",");
try {
vwriter = new PrintWriter(VARIANTS_OUT);
@ -41,11 +38,15 @@ public class VariantFiltrationWalker extends LocusWalker<Integer, Integer> {
public Integer map(RefMetaDataTracker tracker, char ref, LocusContext context) {
rodVariants variant = (rodVariants) tracker.lookup("variant", null);
for (String feature : features) {
for (String feature : FEATURES) {
String[] featurePieces = feature.split(":");
String featureName = featurePieces[0];
String featureArgs = featurePieces[1];
IndependentVariantFeature ivf;
if (feature.equalsIgnoreCase("binomial")) { ivf = new IVFBinomialStrand(); }
else { throw new StingException(String.format("Cannot understand feature '%s'\n", feature)); }
if (featureName.equalsIgnoreCase("binomialstrand")) { ivf = new IVFBinomialStrand(featureArgs); }
else { throw new StingException(String.format("Cannot understand feature '%s'", featureName)); }
variant.adjustLikelihoods(ivf.compute(ref, context));
vwriter.println(variant);