diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeMap.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeMap.java index 319a3b8e8..cb7250bdb 100644 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeMap.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/GenotypeMap.java @@ -24,21 +24,46 @@ package org.broadinstitute.sting.utils.variantcontext; -import java.util.Collection; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; /** * */ -public class GenotypeMap extends TreeMap implements Map { +public class GenotypeMap implements Map { + final TreeMap genotypes; + boolean immutable = false; public final static GenotypeMap NO_GENOTYPES = new GenotypeMap(); + // --------------------------------------------------------------------------- + // + // private constructors -- you have to use static create methods to make these classes + // + // --------------------------------------------------------------------------- + + private GenotypeMap() { + this(false); + } + + private GenotypeMap(boolean immutable) { + this(new TreeMap(), immutable); + } + + private GenotypeMap(final TreeMap genotypes, final boolean immutable) { + this.genotypes = genotypes; + this.immutable = immutable; + } + + // --------------------------------------------------------------------------- + // + // public static factory methods + // + // --------------------------------------------------------------------------- + public static final GenotypeMap create() { return new GenotypeMap(); } - public static final GenotypeMap create(int nGenotypes) { + public static final GenotypeMap create(final int nGenotypes) { return new GenotypeMap(); } @@ -46,6 +71,9 @@ public class GenotypeMap extends TreeMap implements Map genotypes) { return create(genotypes.values()); } @@ -54,13 +82,110 @@ public class GenotypeMap extends TreeMap implements Map map) { + checkImmutability(); + genotypes.putAll(map); + } + + @Override + public Set keySet() { + return Collections.unmodifiableSet(genotypes.keySet()); + } + + @Override + public Collection values() { + return genotypes.values(); + } + + @Override + public Set> entrySet() { + return genotypes.entrySet(); + } } diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java index 0110b847d..1c01fbdd4 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/genotyper/UnifiedGenotyperIntegrationTest.java @@ -46,7 +46,7 @@ public class UnifiedGenotyperIntegrationTest extends WalkerTest { public void testWithAllelesPassedIn2() { WalkerTest.WalkerTestSpec spec2 = new WalkerTest.WalkerTestSpec( baseCommand + " --output_mode EMIT_ALL_SITES --genotyping_mode GENOTYPE_GIVEN_ALLELES -alleles " + validationDataLocation + "allelesForUG.vcf -I " + validationDataLocation + "pilot2_daughters.chr20.10k-11k.bam -o %s -L 20:10,000,000-10,025,000", 1, - Arrays.asList("14f5cdfc6818cbba600cbdf5fe285275")); + Arrays.asList("9834f0cef1cd6ba4943a5aaee1ee8be8")); executeTest("test MultiSample Pilot2 with alleles passed in and emitting all sites", spec2); }