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
This commit is contained in:
ebanks 2010-10-27 02:21:41 +00:00
parent 52fc023d80
commit ffc0ed2b32
13 changed files with 27 additions and 30 deletions

View File

@ -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<Allele> alleles = new TreeSet<Allele>();
@ -445,7 +445,7 @@ public class VariantContextUtils {
List<String> s = new ArrayList<String>();
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<String, Genotype> 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<String> mergedFilters = new HashSet<String>(); // Since vc1 and vc2 were unfiltered, the merged record remains unfiltered
Map<String, Object> mergedAttribs = VariantContextUtils.mergeVariantContextAttributes(vc1.getAttributes(), vc2.getAttributes());

View File

@ -108,7 +108,7 @@ public class AnalyzeAnnotationsWalker extends RodWalker<Integer, Integer> {
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<Integer, Integer> {
// 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 );
}

View File

@ -252,7 +252,7 @@ public class VariantAnnotatorEngine {
//Create a separate VariantContext (aka. output line) for each element in infoAnnotationOutputsList
Collection<VariantContext> returnValue = new LinkedList<VariantContext>();
for(Map<String, Object> 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;

View File

@ -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;

View File

@ -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<GenomeLoc, String>(context.getLocation(), refBase);
} else if (!vc.getName().startsWith("snpmask") && vc.isInsertion()) {
} else if (!vc.getSource().startsWith("snpmask") && vc.isInsertion()) {
return new Pair<GenomeLoc, String>(context.getLocation(), refBase.concat(vc.getAlternateAllele(0).toString()));
} else if (vc.isSNP()) {
return new Pair<GenomeLoc, String>(context.getLocation(), (vc.getName().startsWith("snpmask") ? "N" : vc.getAlternateAllele(0).toString()));
return new Pair<GenomeLoc, String>(context.getLocation(), (vc.getSource().startsWith("snpmask") ? "N" : vc.getAlternateAllele(0).toString()));
}
}

View File

@ -219,7 +219,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
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() );
}

View File

@ -107,9 +107,9 @@ public class BatchedCallsMerger extends LocusWalker<VariantContext, Integer> imp
Set<VariantContext> calls = new HashSet<VariantContext>();
Set<String> seenRods = new HashSet<String>();
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());
}
}

View File

@ -1044,7 +1044,7 @@ public class ReadBackedPhasingWalker extends RodWalker<PhasingStatsAndOutput, Ph
private Map<String, Object> 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();

View File

@ -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<Integer, Integer> implements Tr
HashMap<String,Object> newAts = new HashMap<String,Object>(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)));
}
}

View File

@ -189,7 +189,7 @@ public class ApplyVariantCuts extends RodWalker<Integer, Integer> {
}
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();

View File

@ -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;

View File

@ -54,7 +54,7 @@ public class IndelConsistencyReadCounter extends ReadWalker<Integer, Integer> {
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;
}

View File

@ -205,7 +205,7 @@ public class MendelianViolationClassifier extends LocusWalker<MendelianViolation
public VariantContext toVariantContext() {
newAttributes.putAll(trio.getAttributes());
return new VariantContext(trio.getName(), trio.getChr(), trio.getStart(), trio.getEnd(),trio.getAlleles(),trio.getGenotypes(),trio.getNegLog10PError(),trio.filtersWereApplied()?trio.getFilters():null,newAttributes);
return new VariantContext(trio.getSource(), trio.getChr(), trio.getStart(), trio.getEnd(),trio.getAlleles(),trio.getGenotypes(),trio.getNegLog10PError(),trio.filtersWereApplied()?trio.getFilters():null,newAttributes);
}
public boolean siteIsFiltered() {