We no longer require dbSNP files to be of the dbsnp rod-type; VCFs will do (provided they are bound to the name 'dbsnp')

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4753 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-11-30 03:25:18 +00:00
parent 4413208c45
commit a181680814
4 changed files with 33 additions and 22 deletions

View File

@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.refdata.utils.helpers;
import net.sf.samtools.util.SequenceUtil;
import org.broad.tribble.annotation.Strand;
import org.broad.tribble.dbsnp.DbSNPFeature;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.Utils;
import java.util.ArrayList;
@ -33,6 +34,28 @@ public class DbSNPHelper {
return dbsnp;
}
public static String rsIDOfFirstRealSNP(List<Object> featureList) {
if (featureList == null)
return null;
String rsID = null;
for ( Object d : featureList ) {
if ( d instanceof DbSNPFeature ) {
if ( DbSNPHelper.isSNP((DbSNPFeature)d) ) {
rsID = ((DbSNPFeature)d).getRsID();
break;
}
} else if ( d instanceof VariantContext) {
if ( ((VariantContext)d).isSNP() ) {
rsID = ((VariantContext)d).getID();
break;
}
}
}
return rsID;
}
/**
* get the -1 * (log 10 of the error value)
*

View File

@ -25,7 +25,6 @@
package org.broadinstitute.sting.gatk.walkers;
import org.broad.tribble.dbsnp.DbSNPFeature;
import org.broad.tribble.hapmap.HapMapFeature;
import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
@ -69,14 +68,14 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
if ( tracker == null || !BaseUtils.isRegularBase(ref.getBase()) )
return 0;
DbSNPFeature dbsnp = DbSNPHelper.getFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
String rsID = DbSNPHelper.rsIDOfFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
Collection<VariantContext> contexts = tracker.getVariantContexts(ref, INPUT_ROD_NAME, ALLOWED_VARIANT_CONTEXT_TYPES, context.getLocation(), true, false);
for ( VariantContext vc : contexts ) {
Map<String, Object> attrs = new HashMap<String, Object>(vc.getAttributes());
if ( dbsnp != null )
attrs.put(VariantContext.ID_KEY, dbsnp.getRsID());
if ( rsID != null )
attrs.put(VariantContext.ID_KEY, rsID);
vc = VariantContext.modifyAttributes(vc, attrs);
// set the appropriate sample name if necessary

View File

@ -37,7 +37,6 @@ import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import org.broad.tribble.dbsnp.DbSNPFeature;
import org.broad.tribble.util.variantcontext.Genotype;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.*;
@ -212,11 +211,11 @@ public class VariantAnnotatorEngine {
private void annotateDBs(RefMetaDataTracker tracker, ReferenceContext ref, VariantContext vc, Map<String, Object> infoAnnotations) {
for ( Map.Entry<String, String> dbSet : dbAnnotations.entrySet() ) {
if ( dbSet.getKey().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) ) {
DbSNPFeature dbsnp = DbSNPHelper.getFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
infoAnnotations.put(VCFConstants.DBSNP_KEY, dbsnp == null ? false : true);
String rsID = DbSNPHelper.rsIDOfFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
infoAnnotations.put(VCFConstants.DBSNP_KEY, rsID == null ? false : true);
// annotate dbsnp id if available and not already there
if ( dbsnp != null && (!vc.hasAttribute(VariantContext.ID_KEY) || vc.getAttribute(VariantContext.ID_KEY).equals(VCFConstants.EMPTY_ID_FIELD)) )
infoAnnotations.put(VariantContext.ID_KEY, dbsnp.getRsID());
if ( rsID != null && (!vc.hasID() || vc.getID().equals(VCFConstants.EMPTY_ID_FIELD)) )
infoAnnotations.put(VariantContext.ID_KEY, rsID);
} else {
boolean overlapsComp = false;
for ( VariantContext comp : tracker.getVariantContexts(ref, dbSet.getKey(), null, ref.getLocus(), false, false) ) {

View File

@ -45,7 +45,6 @@ import org.broadinstitute.sting.utils.pileup.*;
import org.broadinstitute.sting.utils.sam.GATKSAMRecordFilter;
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
import org.broad.tribble.vcf.VCFConstants;
import org.broad.tribble.dbsnp.DbSNPFeature;
import java.io.PrintStream;
import java.util.*;
@ -312,9 +311,9 @@ public class UnifiedGenotyperEngine {
// *** note that calculating strand bias involves overwriting data structures, so we do that last
HashMap<String, Object> attributes = new HashMap<String, Object>();
DbSNPFeature dbsnp = getDbSNP(tracker);
if ( dbsnp != null )
attributes.put(VariantContext.ID_KEY, dbsnp.getRsID());
String rsID = DbSNPHelper.rsIDOfFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
if ( rsID != null )
attributes.put(VariantContext.ID_KEY, rsID);
// if the site was downsampled, record that fact
if ( rawContext.hasPileupBeenDownsampled() )
@ -598,15 +597,6 @@ public class UnifiedGenotyperEngine {
}
}
/**
* @param tracker rod data
*
* @return the dbsnp rod if there is one at this position
*/
protected static DbSNPFeature getDbSNP(RefMetaDataTracker tracker) {
return DbSNPHelper.getFirstRealSNP(tracker.getReferenceMetaData(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME));
}
protected boolean passesEmitThreshold(double conf, int bestAFguess, boolean atTriggerTrack) {
return (atTriggerTrack ?
(conf >= Math.min(UAC.TRIGGER_CONFIDENCE_FOR_CALLING, UAC.TRIGGER_CONFIDENCE_FOR_EMITTING)) :