From ffc0ed2b32e2ef59b55460ed6f291874a6e4f406 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 27 Oct 2010 02:21:41 +0000 Subject: [PATCH] Renamed getName() to getSource() in VariantContext to be more accurate git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4579 348d0f76-0448-11de-a6fe-93d51630548a --- .../variantcontext/VariantContextUtils.java | 20 +++++++++---------- .../AnalyzeAnnotationsWalker.java | 4 ++-- .../annotator/VariantAnnotatorEngine.java | 2 +- .../genomicannotator/GenomicAnnotation.java | 3 +-- .../fasta/FastaAlternateReferenceWalker.java | 6 +++--- .../filters/VariantFiltrationWalker.java | 2 +- .../walkers/genotyper/BatchedCallsMerger.java | 4 ++-- .../phasing/ReadBackedPhasingWalker.java | 2 +- .../varianteval/VariantEvalWalker.java | 6 ++---- .../ApplyVariantCuts.java | 2 +- .../VariantGaussianMixtureModel.java | 2 +- .../walkers/IndelConsistencyReadCounter.java | 2 +- .../walkers/MendelianViolationClassifier.java | 2 +- 13 files changed, 27 insertions(+), 30 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java index cf541d125..cfc67a7cf 100755 --- a/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java +++ b/java/src/org/broadinstitute/sting/gatk/contexts/variantcontext/VariantContextUtils.java @@ -86,7 +86,7 @@ public class VariantContextUtils { * @return VariantContext object */ public static VariantContext toVC(VariantContext other) { - return new VariantContext(other.getName(), other.getChr(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getNegLog10PError(), other.getFilters(), other.getAttributes()); + return new VariantContext(other.getSource(), other.getChr(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getNegLog10PError(), other.getFilters(), other.getAttributes()); } /** @@ -355,7 +355,7 @@ public class VariantContextUtils { // establish the baseline info from the first VC VariantContext first = VCs.get(0); - String name = first.getName(); + String name = first.getSource(); GenomeLoc loc = getLocation(first); Set alleles = new TreeSet(); @@ -445,7 +445,7 @@ public class VariantContextUtils { List s = new ArrayList(); for ( VariantContext vc : VCs ) if ( vc.isVariant() ) - s.add( vc.isFiltered() ? "filterIn" + vc.getName() : vc.getName() ); + s.add( vc.isFiltered() ? "filterIn" + vc.getSource() : vc.getSource() ); setValue = Utils.join("-", s); } @@ -609,7 +609,7 @@ public class VariantContextUtils { g.getFilters(),g.getAttributes(),g.genotypesArePhased())); } - return new VariantContext(inputVC.getName(), inputVC.getChr(), inputVC.getStart(), inputVC.getEnd(), alleles, genotypes, inputVC.getNegLog10PError(), + return new VariantContext(inputVC.getSource(), inputVC.getChr(), inputVC.getStart(), inputVC.getEnd(), alleles, genotypes, inputVC.getNegLog10PError(), inputVC.getFilters(), attributes); } @@ -626,8 +626,8 @@ public class VariantContextUtils { } private int getIndex(VariantContext vc) { - int i = priorityListOfVCs.indexOf(vc.getName()); - if ( i == -1 ) throw new UserException.BadArgumentValue(Utils.join(",", priorityListOfVCs), "Priority list " + priorityListOfVCs + " doesn't contain variant context " + vc.getName()); + int i = priorityListOfVCs.indexOf(vc.getSource()); + if ( i == -1 ) throw new UserException.BadArgumentValue(Utils.join(",", priorityListOfVCs), "Priority list " + priorityListOfVCs + " doesn't contain variant context " + vc.getSource()); return i; } @@ -651,7 +651,7 @@ public class VariantContextUtils { private static void mergeGenotypes(Map mergedGenotypes, VariantContext oneVC, AlleleMapper alleleMapping, boolean uniqifySamples) { for ( Genotype g : oneVC.getGenotypes().values() ) { - String name = mergedSampleName(oneVC.getName(), g.getSampleName(), uniqifySamples); + String name = mergedSampleName(oneVC.getSource(), g.getSampleName(), uniqifySamples); if ( ! mergedGenotypes.containsKey(name) ) { // only add if the name is new Genotype newG = g; @@ -672,7 +672,7 @@ public class VariantContextUtils { } public static VariantContext modifyLocation(VariantContext vc, GenomeLoc loc) { - return new VariantContext(vc.getName(), loc.getContig(), loc.getStart(), loc.getStop(), vc.getAlleles(), vc.getGenotypes(), vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes()); + return new VariantContext(vc.getSource(), loc.getContig(), loc.getStart(), loc.getStop(), vc.getAlleles(), vc.getGenotypes(), vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes()); } /** @@ -706,7 +706,7 @@ public class VariantContextUtils { newGenotypes.put(genotype.getKey(), Genotype.modifyAlleles(genotype.getValue(), newAlleles)); } - return new VariantContext(vc.getName(), vc.getChr(), vc.getStart(), vc.getEnd(), alleleMap.values(), newGenotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes()); + return new VariantContext(vc.getSource(), vc.getChr(), vc.getStart(), vc.getEnd(), alleleMap.values(), newGenotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, vc.getAttributes()); } @@ -809,7 +809,7 @@ public class VariantContextUtils { mergedGenotypes.put(sample, mergedGt); } - String mergedName = VariantContextUtils.mergeVariantContextNames(vc1.getName(), vc2.getName()); + String mergedName = VariantContextUtils.mergeVariantContextNames(vc1.getSource(), vc2.getSource()); double mergedNegLog10PError = Math.max(vc1.getNegLog10PError(), vc2.getNegLog10PError()); Set mergedFilters = new HashSet(); // Since vc1 and vc2 were unfiltered, the merged record remains unfiltered Map mergedAttribs = VariantContextUtils.mergeVariantContextAttributes(vc1.getAttributes(), vc2.getAttributes()); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/analyzeannotations/AnalyzeAnnotationsWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/analyzeannotations/AnalyzeAnnotationsWalker.java index 3f2f81c68..8ffc7d957 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/analyzeannotations/AnalyzeAnnotationsWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/analyzeannotations/AnalyzeAnnotationsWalker.java @@ -108,7 +108,7 @@ public class AnalyzeAnnotationsWalker extends RodWalker { boolean isTrueVariant = false; for ( VariantContext vc : VCs ) { if( vc != null && vc.isSNP() && !vc.isFiltered() ) { - if( vc.getName().toUpperCase().startsWith("TRUTH") ) { + if( vc.getSource().toUpperCase().startsWith("TRUTH") ) { isInTruthSet = true; if( vc.isBiallelic() && vc.isVariant() ) { isTrueVariant = true; @@ -120,7 +120,7 @@ public class AnalyzeAnnotationsWalker extends RodWalker { // Add each annotation in this VCF Record to the dataManager for ( VariantContext vc : VCs ) { if( vc != null && vc.isSNP() && vc.isBiallelic() && !vc.isFiltered() ) { - if( !vc.getName().toUpperCase().startsWith("TRUTH") ) { + if( !vc.getSource().toUpperCase().startsWith("TRUTH") ) { if( vc.isVariant() ) { dataManager.addAnnotations( vc, SAMPLE_NAME, isInTruthSet, isTrueVariant ); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java index 1b7527416..3cded6029 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/VariantAnnotatorEngine.java @@ -252,7 +252,7 @@ public class VariantAnnotatorEngine { //Create a separate VariantContext (aka. output line) for each element in infoAnnotationOutputsList Collection returnValue = new LinkedList(); for(Map infoAnnotationOutput : infoAnnotationOutputsList) { - returnValue.add( new VariantContext(vc.getName(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, infoAnnotationOutput) ); + returnValue.add( new VariantContext(vc.getSource(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), vc.filtersWereApplied() ? vc.getFilters() : null, infoAnnotationOutput) ); } return returnValue; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java index 0e9b453dd..350020111 100644 --- a/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java @@ -39,7 +39,6 @@ import org.broadinstitute.sting.gatk.refdata.features.annotator.AnnotatorInputTa 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; -import org.broadinstitute.sting.utils.BaseUtils; import org.broadinstitute.sting.utils.exceptions.UserException; /** @@ -133,7 +132,7 @@ public class GenomicAnnotation implements InfoFieldAnnotation { //continue; //TODO If this site is monomorphic in the VC, and the current record specifies a particular alternate allele, skip this record. Right? //} else if(alternateAlleles.size() > 1) { - throw new UserException.MalformedFile("File associated with " + vc.getName() + " contains record [" + vc + "] contains " + alternateAlleles.size() + " alternate alleles. GenomicAnnotion currently only supports annotating 1 alternate allele."); + throw new UserException.MalformedFile("File associated with " + vc.getSource() + " contains record [" + vc + "] contains " + alternateAlleles.size() + " alternate alleles. GenomicAnnotion currently only supports annotating 1 alternate allele."); } Allele vcAlt; diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceWalker.java index 305a04dae..a4a3cfc52 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/fasta/FastaAlternateReferenceWalker.java @@ -57,14 +57,14 @@ public class FastaAlternateReferenceWalker extends FastaReferenceWalker { for ( VariantContext vc : tracker.getAllVariantContexts(ref) ) { // if we have multiple variants at a locus, just take the first one we see - if (!vc.getName().startsWith("snpmask") && vc.isDeletion()) { + if (!vc.getSource().startsWith("snpmask") && vc.isDeletion()) { deletionBasesRemaining = vc.getReference().length(); // delete the next n bases, not this one return new Pair(context.getLocation(), refBase); - } else if (!vc.getName().startsWith("snpmask") && vc.isInsertion()) { + } else if (!vc.getSource().startsWith("snpmask") && vc.isInsertion()) { return new Pair(context.getLocation(), refBase.concat(vc.getAlternateAllele(0).toString())); } else if (vc.isSNP()) { - return new Pair(context.getLocation(), (vc.getName().startsWith("snpmask") ? "N" : vc.getAlternateAllele(0).toString())); + return new Pair(context.getLocation(), (vc.getSource().startsWith("snpmask") ? "N" : vc.getAlternateAllele(0).toString())); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java index 6b8fe2e2a..31a617f68 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/filters/VariantFiltrationWalker.java @@ -219,7 +219,7 @@ public class VariantFiltrationWalker extends RodWalker { if ( genotypes == null ) filteredVC = VariantContext.modifyFilters(vc, filters); else - filteredVC = new VariantContext(vc.getName(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), filters, vc.getAttributes()); + filteredVC = new VariantContext(vc.getSource(), vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles(), genotypes, vc.getNegLog10PError(), filters, vc.getAttributes()); writer.add( filteredVC, context.getReferenceContext().getBase() ); } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java index 6dafd5869..c98f0639a 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/genotyper/BatchedCallsMerger.java @@ -107,9 +107,9 @@ public class BatchedCallsMerger extends LocusWalker imp Set calls = new HashSet(); Set seenRods = new HashSet(); for ( VariantContext vc : VCs ) { - if ( targetRods.contains(vc.getName()) ) { + if ( targetRods.contains(vc.getSource()) ) { calls.add(vc); - seenRods.add(vc.getName()); + seenRods.add(vc.getSource()); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java index 462923255..781309e58 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/phasing/ReadBackedPhasingWalker.java @@ -1044,7 +1044,7 @@ public class ReadBackedPhasingWalker extends RodWalker attributes; public UnfinishedVariantContext(VariantContext vc) { - this.name = vc.getName(); + this.name = vc.getSource(); this.contig = vc.getChr(); this.start = vc.getStart(); this.stop = vc.getEnd(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalWalker.java b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalWalker.java index 28a4ed90d..738483b25 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalWalker.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/VariantEvalWalker.java @@ -37,7 +37,6 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext; import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils; import org.broadinstitute.sting.gatk.datasources.simpleDataSources.ReferenceOrderedDataSource; import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker; -import org.broadinstitute.sting.gatk.refdata.VariantContextAdaptors; import org.broadinstitute.sting.gatk.refdata.utils.helpers.DbSNPHelper; import org.broadinstitute.sting.gatk.walkers.Reference; import org.broadinstitute.sting.gatk.walkers.RodWalker; @@ -52,7 +51,6 @@ import org.broadinstitute.sting.utils.report.utils.Node; import org.broadinstitute.sting.utils.exceptions.ReviewedStingException; import org.broadinstitute.sting.utils.classloader.PackageUtils; import org.broadinstitute.sting.utils.Utils; -import org.broadinstitute.sting.utils.vcf.VCFUtils; import org.broadinstitute.sting.commandline.Argument; import org.broadinstitute.sting.commandline.Output; import org.broadinstitute.sting.utils.exceptions.DynamicClassResolutionException; @@ -684,10 +682,10 @@ public class VariantEvalWalker extends RodWalker implements Tr HashMap newAts = new HashMap(vc.getAttributes()); VariantContextUtils.calculateChromosomeCounts(vc,newAts,true); vc = VariantContext.modifyAttributes(vc,newAts); - logger.debug(String.format("VC %s subset to %s AC%n",vc.getName(),vc.getAttributeAsString(VCFConstants.ALLELE_COUNT_KEY))); + logger.debug(String.format("VC %s subset to %s AC%n",vc.getSource(),vc.getAttributeAsString(VCFConstants.ALLELE_COUNT_KEY))); //if ( ! name.equals("eval") ) logger.info(String.format(" => VC %s", vc)); } else if ( !hasGenotypes && !name.equals("dbsnp") ) { - throw new UserException(String.format("Genotypes for the variant context %s do not contain all the provided samples %s",vc.getName(), getMissingSamples(SAMPLES_LIST,vc))); + throw new UserException(String.format("Genotypes for the variant context %s do not contain all the provided samples %s",vc.getSource(), getMissingSamples(SAMPLES_LIST,vc))); } } diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java index c93cbe07c..8db0e4fec 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyVariantCuts.java @@ -189,7 +189,7 @@ public class ApplyVariantCuts extends RodWalker { } for( VariantContext vc : tracker.getAllVariantContexts(ref, null, context.getLocation(), false, false) ) { - if( vc != null && !vc.getName().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) && vc.isSNP() ) { + if( vc != null && !vc.getSource().equals(DbSNPHelper.STANDARD_DBSNP_TRACK_NAME) && vc.isSNP() ) { String filterString = null; if( !vc.isFiltered() ) { final double qual = vc.getPhredScaledQual(); diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java index b436fba3b..22df25028 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantGaussianMixtureModel.java @@ -436,7 +436,7 @@ public final class VariantGaussianMixtureModel extends VariantOptimizationModel try { value = Double.parseDouble( (String)vc.getAttribute( annotationKey ) ); } catch( Exception e ) { - throw new UserException.MalformedFile(vc.getName(), "No double value detected for annotation = " + annotationKey + " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ), e ); + throw new UserException.MalformedFile(vc.getSource(), "No double value detected for annotation = " + annotationKey + " in variant at " + VariantContextUtils.getLocation(vc) + ", reported annotation value = " + vc.getAttribute( annotationKey ), e ); } } return value; diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelConsistencyReadCounter.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelConsistencyReadCounter.java index f0a7e0ad6..fb22c7577 100755 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelConsistencyReadCounter.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/IndelConsistencyReadCounter.java @@ -54,7 +54,7 @@ public class IndelConsistencyReadCounter extends ReadWalker { Object rod = rodIter.next().getUnderlyingObject(); if ( VariantContextAdaptors.canBeConvertedToVariantContext(rod)) { VariantContext vc = VariantContextAdaptors.toVariantContext("", rod, ref); - if ( vc.getName().equals("indels") ) { + if ( vc.getSource().equals("indels") ) { indel = vc; break; } diff --git a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java index 5401fa360..89487ca16 100644 --- a/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java +++ b/java/src/org/broadinstitute/sting/oneoffprojects/walkers/MendelianViolationClassifier.java @@ -205,7 +205,7 @@ public class MendelianViolationClassifier extends LocusWalker