From d8469e2fba063aae597a82234e8893f5ff5cd0b7 Mon Sep 17 00:00:00 2001 From: weisburd Date: Wed, 19 May 2010 03:40:47 +0000 Subject: [PATCH] Updated to use Tribble-based GATKFeature instead of TabularROD git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3388 348d0f76-0448-11de-a6fe-93d51630548a --- .../walkers/annotator/GenomicAnnotation.java | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java index 712d11efa..5290bd8d3 100644 --- a/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java +++ b/java/src/org/broadinstitute/sting/playground/gatk/walkers/annotator/GenomicAnnotation.java @@ -13,9 +13,8 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.StratifiedAlignmentContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.Allele; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContext; -import org.broadinstitute.sting.gatk.refdata.AnnotatorROD; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.TabularROD; +import org.broadinstitute.sting.gatk.refdata.features.sampileup.AnnotatorInputTableFeature; import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature; import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotatorEngine; import org.broadinstitute.sting.gatk.walkers.annotator.interfaces.InfoFieldAnnotation; @@ -31,9 +30,10 @@ import org.broadinstitute.sting.utils.StingException; */ public class GenomicAnnotation implements InfoFieldAnnotation { - private static final String HAPLOTYPE_REFERENCE_COLUMN = AnnotatorROD.HAPLOTYPE_REFERENCE_COLUMN; - private static final String HAPLOTYPE_ALTERNATE_COLUMN = AnnotatorROD.HAPLOTYPE_ALTERNATE_COLUMN; - private static final String HAPLOTYPE_STRAND_COLUMN = AnnotatorROD.HAPLOTYPE_STRAND_COLUMN; + public static final String CHRPOS_COLUMN = "chrpos"; + public static final String HAPLOTYPE_REFERENCE_COLUMN = "haplotypeReference"; + public static final String HAPLOTYPE_ALTERNATE_COLUMN = "haplotypeAlternate"; + public static final String HAPLOTYPE_STRAND_COLUMN = "haplotypeStrand"; /** @@ -72,18 +72,16 @@ public class GenomicAnnotation implements InfoFieldAnnotation { final Map annotations = new HashMap(); for(final GATKFeature gatkFeature : tracker.getAllRods()) { - final Object rod = gatkFeature.getUnderlyingObject(); final String name = gatkFeature.getName(); if( name.equals("variant") || name.equals("interval") ) { continue; } - if( ! (rod instanceof TabularROD) ) { + if( ! (gatkFeature.getUnderlyingObject() instanceof AnnotatorInputTableFeature) ) { continue; //GenericAnnotation only works with TabularRODs because it needs to be able to select individual columns. } - TabularROD tabularRod = (TabularROD) rod; - final Map annotationsForRecord = convertRecordToAnnotations( tabularRod ); + final Map annotationsForRecord = convertRecordToAnnotations( gatkFeature ); //If this record contains the HAPLOTYPE_REFERENCE_COLUMN and/or HAPLOTYPE_ALTERNATE_COLUMN, check whether the //alleles specified match the the variant's reference allele and alternate allele. @@ -118,7 +116,7 @@ public class GenomicAnnotation implements InfoFieldAnnotation { if(hapStrandValue.equals("-") || hapStrandValue.equals("r")) { positiveStrand = false; } else if(!hapStrandValue.equals("+") && !hapStrandValue.equals("f")) { - throw new StingException("Record (" + rod + ") in " + name + " has an invalid value for " + HAPLOTYPE_STRAND_COLUMN + ". This value is: \"" + hapStrandValue + "\""); + throw new StingException("Record (" + gatkFeature.getUnderlyingObject() + ") in " + name + " has an invalid value for " + HAPLOTYPE_STRAND_COLUMN + ". This value is: \"" + hapStrandValue + "\""); } } @@ -183,18 +181,17 @@ public class GenomicAnnotation implements InfoFieldAnnotation { * thisRodName.fieldName1=fieldValue, thisRodName.fieldName1=fieldValue * (eg. dbSNP.avHet=0.7, dbSNP.ref_allele=A) * - * @param rod A TabularROD corresponding to one record in one input file. - * + * @param annotatorInputTableFeature AnnotatorInputTableFeature corresponding to one record in one input file. + * @param name The binding name of the given AnnotatorInputTableFeature. * @return The map of column-name -> value pairs. */ - private Map convertRecordToAnnotations( final TabularROD rod ) { - final String rodName = rod.getName(); //aka the rod binding + private Map convertRecordToAnnotations( final GATKFeature feature) { final Map result = new HashMap(); - for(final Entry entry : rod.entrySet()) { + for(final Entry entry : ((AnnotatorInputTableFeature) feature.getUnderlyingObject()).getEntrySet()) { final String value = entry.getValue(); if(!value.trim().isEmpty()) { - result.put( generateInfoFieldKey(rodName, entry.getKey()), entry.getValue()); + result.put( generateInfoFieldKey(feature.getName(), entry.getKey()), entry.getValue()); } }