Attributes are now Map<String,Object> not Map<String,?>

-- Allows us to avoid an unnecessary copy when creating InferredGeneticContext (whose name really needs to change).
This commit is contained in:
Mark DePristo 2011-11-11 09:55:42 -05:00
parent 59945a41e8
commit ee40791776
14 changed files with 35 additions and 45 deletions

View File

@ -257,7 +257,7 @@ public class VariantContextAdaptors {
else genotypeAlleles.add(refAllele);
}
Map<String, String> attributes = new HashMap<String, String>();
Map<String, Object> attributes = new HashMap<String, Object>();
Collection<Genotype> genotypes = new ArrayList<Genotype>();
MutableGenotype call = new MutableGenotype(name, genotypeAlleles);

View File

@ -1061,7 +1061,7 @@ public class SomaticIndelDetectorWalker extends ReadWalker<Integer,Integer> {
for ( String sample : normalSamples ) {
Map<String,?> attrs = call.makeStatsAttributes(null);
Map<String,Object> attrs = call.makeStatsAttributes(null);
if ( call.isCall() ) // we made a call - put actual het genotype here:
genotypes.put(sample,new Genotype(sample,alleles,Genotype.NO_NEG_LOG_10PERROR,null,attrs,false));

View File

@ -186,7 +186,7 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> implements Tr
* File containing tribble-readable features for the IntervalStratificiation
*/
@Input(fullName="stratIntervals", shortName="stratIntervals", doc="File containing tribble-readable features for the IntervalStratificiation", required=false)
protected IntervalBinding<Feature> intervalsFile = null;
public IntervalBinding<Feature> intervalsFile = null;
// Variables
private Set<SortableJexlVCMatchExp> jexlExpressions = new TreeSet<SortableJexlVCMatchExp>();

View File

@ -51,21 +51,21 @@ public class G1KPhaseITable extends VariantEvaluator {
@DataPoint(description = "Number of SNPs")
public long nSNPs = 0;
@DataPoint(description = "SNP Novelty Rate")
public double SNPNoveltyRate = 0;
public String SNPNoveltyRate = "NA";
@DataPoint(description = "Mean number of SNPs per individual")
public long nSNPsPerSample = 0;
@DataPoint(description = "Number of Indels")
public long nIndels = 0;
@DataPoint(description = "Indel Novelty Rate")
public double IndelNoveltyRate = 0;
public String IndelNoveltyRate = "NA";
@DataPoint(description = "Mean number of Indels per individual")
public long nIndelsPerSample = 0;
@DataPoint(description = "Number of SVs")
public long nSVs = 0;
@DataPoint(description = "SV Novelty Rate")
public double SVNoveltyRate = 0;
public String SVNoveltyRate = "NA";
@DataPoint(description = "Mean number of SVs per individual")
public long nSVsPerSample = 0;
@ -106,9 +106,6 @@ public class G1KPhaseITable extends VariantEvaluator {
if ( eval == null || eval.isMonomorphic() ) return null;
switch (eval.getType()) {
// case NO_VARIATION:
// // shouldn't get here
// break;
case SNP:
case INDEL:
case SYMBOLIC:
@ -139,11 +136,12 @@ public class G1KPhaseITable extends VariantEvaluator {
return (int)(Math.round(sum / (1.0 * countsPerSample.size())));
}
private final double noveltyRate(VariantContext.Type type) {
private final String noveltyRate(VariantContext.Type type) {
int all = allVariantCounts.get(type);
int known = knownVariantCounts.get(type);
int novel = all - known;
return (novel / (1.0 * all));
double rate = (novel / (1.0 * all));
return all == 0 ? "NA" : String.format("%.2f", rate);
}
public void finalizeEvaluation() {

View File

@ -63,8 +63,8 @@ public class IntervalStratification extends VariantStratifier {
if ( locs.isEmpty() )
throw new UserException.BadArgumentValue("stratIntervals", "Contains no intervals. Perhaps the file is malformed or empty?");
logger.info(String.format("Creating IntervalStratification containing %d intervals covering %d bp",
locs.size(), IntervalUtils.intervalSize(locs)));
logger.info(String.format("Creating IntervalStratification %s containing %d intervals covering %d bp",
getVariantEvalWalker().intervalsFile.getSource(), locs.size(), IntervalUtils.intervalSize(locs)));
// set up the map from contig -> interval tree
for ( final String contig : getVariantEvalWalker().getContigNames() )

View File

@ -141,7 +141,7 @@ public class VCF3Codec extends AbstractVCFCodec {
double GTQual = VariantContext.NO_NEG_LOG_10PERROR;
Set<String> genotypeFilters = null;
Map<String, String> gtAttributes = null;
Map<String, Object> gtAttributes = null;
String sampleName = sampleNameIterator.next();
// check to see if the value list is longer than the key list, which is a problem
@ -150,7 +150,7 @@ public class VCF3Codec extends AbstractVCFCodec {
int genotypeAlleleLocation = -1;
if (nGTKeys >= 1) {
gtAttributes = new HashMap<String, String>(nGTKeys - 1);
gtAttributes = new HashMap<String, Object>(nGTKeys - 1);
for (int i = 0; i < nGTKeys; i++) {
final String gtKey = new String(genotypeKeyArray[i]);

View File

@ -168,7 +168,7 @@ public class VCFCodec extends AbstractVCFCodec {
double GTQual = VariantContext.NO_NEG_LOG_10PERROR;
Set<String> genotypeFilters = null;
Map<String, String> gtAttributes = null;
Map<String, Object> gtAttributes = null;
String sampleName = sampleNameIterator.next();
// check to see if the value list is longer than the key list, which is a problem
@ -177,7 +177,7 @@ public class VCFCodec extends AbstractVCFCodec {
int genotypeAlleleLocation = -1;
if (nGTKeys >= 1) {
gtAttributes = new HashMap<String, String>(nGTKeys - 1);
gtAttributes = new HashMap<String, Object>(nGTKeys - 1);
for (int i = 0; i < nGTKeys; i++) {
final String gtKey = new String(genotypeKeyArray[i]);

View File

@ -25,11 +25,11 @@ public class Genotype {
protected boolean isPhased = false;
protected boolean filtersWereAppliedToContext;
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, ?> attributes, boolean isPhased) {
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased) {
this(sampleName, alleles, negLog10PError, filters, attributes, isPhased, null);
}
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, ?> attributes, boolean isPhased, double[] log10Likelihoods) {
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
if ( alleles != null )
this.alleles = Collections.unmodifiableList(alleles);
commonInfo = new InferredGeneticContext(sampleName, negLog10PError, filters, attributes);

View File

@ -22,22 +22,14 @@ public final class InferredGeneticContext {
private Set<String> filters = NO_FILTERS;
private Map<String, Object> attributes = NO_ATTRIBUTES;
// public InferredGeneticContext(String name) {
// this.name = name;
// }
//
// public InferredGeneticContext(String name, double negLog10PError) {
// this(name);
// setNegLog10PError(negLog10PError);
// }
public InferredGeneticContext(String name, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public InferredGeneticContext(String name, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this.name = name;
setNegLog10PError(negLog10PError);
if ( filters != null )
setFilters(filters);
if ( attributes != null )
setAttributes(attributes);
if ( filters != null && ! filters.isEmpty() )
this.filters = filters;
if ( attributes != null && ! attributes.isEmpty() ) {
this.attributes = attributes;
}
}
/**
@ -157,7 +149,7 @@ public final class InferredGeneticContext {
if ( attributes == NO_ATTRIBUTES ) // immutable -> mutable
attributes = new HashMap<String, Object>();
attributes.put(key, value);
}

View File

@ -17,7 +17,7 @@ public class MutableGenotype extends Genotype {
}
public MutableGenotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, ?> attributes, boolean genotypesArePhased) {
public MutableGenotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean genotypesArePhased) {
super(sampleName, alleles, negLog10PError, filters, attributes, genotypesArePhased);
}

View File

@ -18,11 +18,11 @@ public class MutableVariantContext extends VariantContext {
//
// ---------------------------------------------------------------------------------------------------------
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
super(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes);
}
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public MutableVariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
super(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes);
}

View File

@ -222,7 +222,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param attributes attributes
* @param referenceBaseForIndel padded reference base
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes, Byte referenceBaseForIndel) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
this(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, referenceBaseForIndel, false);
}
@ -239,7 +239,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param filters filters: use null for unfiltered and empty set for passes filters
* @param attributes attributes
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Map<String, Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this(source, contig, start, stop, alleles, genotypes, negLog10PError, filters, attributes, null, false);
}
@ -260,7 +260,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param attributes attributes
* @param referenceBaseForIndel padded reference base
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, ?> attributes, Byte referenceBaseForIndel) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, Byte referenceBaseForIndel) {
this(source, contig, start, stop, alleles, NO_GENOTYPES, negLog10PError, filters, attributes, referenceBaseForIndel, true);
}
@ -277,7 +277,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* @param filters filters: use null for unfiltered and empty set for passes filters
* @param attributes attributes
*/
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
this(source, contig, start, stop, alleles, genotypes != null ? genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes) : null, negLog10PError, filters, attributes, null, false);
}
@ -334,7 +334,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
*/
private VariantContext(String source, String contig, long start, long stop,
Collection<Allele> alleles, Map<String, Genotype> genotypes,
double negLog10PError, Set<String> filters, Map<String, ?> attributes,
double negLog10PError, Set<String> filters, Map<String, Object> attributes,
Byte referenceBaseForIndel, boolean genotypesAreUnparsed) {
if ( contig == null ) { throw new IllegalArgumentException("Contig cannot be null"); }
this.contig = contig;

View File

@ -69,7 +69,7 @@ public class VariantContextUtils {
* @param attributes attributes
* @return VariantContext object
*/
public static VariantContext toVC(String name, GenomeLoc loc, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, ?> attributes) {
public static VariantContext toVC(String name, GenomeLoc loc, Collection<Allele> alleles, Collection<Genotype> genotypes, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
return new VariantContext(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes != null ? VariantContext.genotypeCollectionToMap(new TreeMap<String, Genotype>(), genotypes) : null, negLog10PError, filters, attributes);
}

View File

@ -120,7 +120,7 @@ public class VCFWriterUnitTest extends BaseTest {
GenomeLoc loc = genomeLocParser.createGenomeLoc("chr1",1);
List<Allele> alleles = new ArrayList<Allele>();
Set<String> filters = null;
Map<String, String> attributes = new HashMap<String,String>();
Map<String, Object> attributes = new HashMap<String,Object>();
Map<String, Genotype> genotypes = new HashMap<String,Genotype>();
alleles.add(Allele.create("-",true));
@ -128,7 +128,7 @@ public class VCFWriterUnitTest extends BaseTest {
attributes.put("DP","50");
for (String name : header.getGenotypeSamples()) {
Map<String, String> gtattributes = new HashMap<String,String>();
Map<String, Object> gtattributes = new HashMap<String,Object>();
gtattributes.put("BB","1");
Genotype gt = new Genotype(name,alleles.subList(1,2),0,null,gtattributes,true);