Removing more references to VCFRecord
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3789 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
a4f8d70d8d
commit
af23762778
|
|
@ -1,11 +1,11 @@
|
||||||
package org.broadinstitute.sting.oneoffprojects.walkers;
|
package org.broadinstitute.sting.oneoffprojects.walkers;
|
||||||
|
|
||||||
import org.broad.tribble.vcf.VCFCodec;
|
|
||||||
import org.broad.tribble.vcf.VCFRecord;
|
|
||||||
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.gatk.contexts.StratifiedAlignmentContext;
|
import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext;
|
||||||
|
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||||
import org.broadinstitute.sting.gatk.walkers.DataSource;
|
import org.broadinstitute.sting.gatk.walkers.DataSource;
|
||||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||||
import org.broadinstitute.sting.gatk.walkers.RMD;
|
import org.broadinstitute.sting.gatk.walkers.RMD;
|
||||||
|
|
@ -22,7 +22,7 @@ import java.util.*;
|
||||||
* Time: 3:25:11 PM
|
* Time: 3:25:11 PM
|
||||||
* To change this template use File | Settings | File Templates.
|
* To change this template use File | Settings | File Templates.
|
||||||
*/
|
*/
|
||||||
@Requires(value= DataSource.REFERENCE,referenceMetaData = {@RMD(name="variants",type=VCFRecord.class)})
|
@Requires(value= DataSource.REFERENCE,referenceMetaData = {@RMD(name="variants",type=ReferenceOrderedDatum.class)})
|
||||||
public class AlleleBalanceHistogramWalker extends LocusWalker<Map<String,Double>, Map<String,Set<Double>>> {
|
public class AlleleBalanceHistogramWalker extends LocusWalker<Map<String,Double>, Map<String,Set<Double>>> {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -47,13 +47,12 @@ public class AlleleBalanceHistogramWalker extends LocusWalker<Map<String,Double>
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String,Double> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public Map<String,Double> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
VCFRecord record = tracker.lookup("variants", VCFRecord.class);
|
VariantContext vc = tracker.getVariantContext(ref, "variants", EnumSet.of(VariantContext.Type.SNP), context.getLocation(), false);
|
||||||
|
if ( vc == null || !vc.isBiallelic() ) {
|
||||||
if ( record == null ) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getAlleleBalanceBySample(record,ref,context);
|
return getAlleleBalanceBySample(vc,ref,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTraversalDone(Map<String,Set<Double>> finalSets) {
|
public void onTraversalDone(Map<String,Set<Double>> finalSets) {
|
||||||
|
|
@ -67,13 +66,13 @@ public class AlleleBalanceHistogramWalker extends LocusWalker<Map<String,Double>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String,Double> getAlleleBalanceBySample(VCFRecord vcf, ReferenceContext ref, AlignmentContext context) {
|
private HashMap<String,Double> getAlleleBalanceBySample(VariantContext vc, ReferenceContext ref, AlignmentContext context) {
|
||||||
Map<String, StratifiedAlignmentContext> sampleContext = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup(),null);
|
Map<String, StratifiedAlignmentContext> sampleContext = StratifiedAlignmentContext.splitContextBySample(context.getBasePileup(),null);
|
||||||
HashMap<String,Double> balances = new HashMap<String,Double>();
|
HashMap<String,Double> balances = new HashMap<String,Double>();
|
||||||
System.out.println("----- "+ref.getLocus()+" -----");
|
System.out.println("----- "+ref.getLocus()+" -----");
|
||||||
int returnedBalances = 0;
|
int returnedBalances = 0;
|
||||||
for ( String sample : vcf.getSampleNames() ) {
|
for ( String sample : vc.getSampleNames() ) {
|
||||||
Double balance = getAlleleBalance(ref,sampleContext.get(sample),vcf.getAlternativeBaseForSNP());
|
Double balance = getAlleleBalance(ref,sampleContext.get(sample),(char)vc.getAlternateAllele(0).getBases()[0]);
|
||||||
balances.put(sample, balance);
|
balances.put(sample, balance);
|
||||||
if ( balance != null ) {
|
if ( balance != null ) {
|
||||||
returnedBalances++;
|
returnedBalances++;
|
||||||
|
|
|
||||||
|
|
@ -25,23 +25,23 @@
|
||||||
|
|
||||||
package org.broadinstitute.sting.playground.gatk.walkers.diagnostics;
|
package org.broadinstitute.sting.playground.gatk.walkers.diagnostics;
|
||||||
|
|
||||||
import org.broad.tribble.vcf.VCFCodec;
|
|
||||||
import org.broad.tribble.vcf.VCFRecord;
|
|
||||||
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.gatk.contexts.variantcontext.VariantContext;
|
import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext;
|
||||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors;
|
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
|
||||||
import org.broadinstitute.sting.gatk.walkers.*;
|
import org.broadinstitute.sting.gatk.walkers.*;
|
||||||
import org.broadinstitute.sting.utils.GenomeLoc;
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
||||||
import org.broadinstitute.sting.utils.collections.Pair;
|
import org.broadinstitute.sting.utils.collections.Pair;
|
||||||
import org.broadinstitute.sting.commandline.Argument;
|
import org.broadinstitute.sting.commandline.Argument;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes the density of SNPs passing and failing filters in intervals on the genome and emits a table for display
|
* Computes the density of SNPs passing and failing filters in intervals on the genome and emits a table for display
|
||||||
*/
|
*/
|
||||||
@By(DataSource.REFERENCE)
|
@By(DataSource.REFERENCE)
|
||||||
@Requires(value={},referenceMetaData=@RMD(name="eval",type= VCFRecord.class))
|
@Requires(value={},referenceMetaData=@RMD(name="eval",type=ReferenceOrderedDatum.class))
|
||||||
public class SNPDensity extends RefWalker<Pair<VariantContext, GenomeLoc>, SNPDensity.Counter> {
|
public class SNPDensity extends RefWalker<Pair<VariantContext, GenomeLoc>, SNPDensity.Counter> {
|
||||||
@Argument(fullName="granularity", shortName="granularity", doc="", required=false)
|
@Argument(fullName="granularity", shortName="granularity", doc="", required=false)
|
||||||
private int granularity = 1000000;
|
private int granularity = 1000000;
|
||||||
|
|
@ -63,11 +63,7 @@ public class SNPDensity extends RefWalker<Pair<VariantContext, GenomeLoc>, SNPDe
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<VariantContext, GenomeLoc> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
public Pair<VariantContext, GenomeLoc> map(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||||
VariantContext vc = null;
|
VariantContext vc = tracker.getVariantContext(ref, "eval", EnumSet.of(VariantContext.Type.SNP), context.getLocation(), false);
|
||||||
|
|
||||||
VCFRecord vcf = tracker.lookup("eval",VCFRecord.class);
|
|
||||||
if (vcf != null)
|
|
||||||
vc = VariantContextAdaptors.toVariantContext("eval", vcf, ref);
|
|
||||||
return new Pair<VariantContext, GenomeLoc>(vc, context.getLocation());
|
return new Pair<VariantContext, GenomeLoc>(vc, context.getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue