diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/AlleleList.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/AlleleList.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/AlleleList.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/AlleleList.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/AlleleListUtils.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/AlleleListUtils.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/AlleleListUtils.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/AlleleListUtils.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/IndexedAlleleList.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/IndexedAlleleList.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/IndexedAlleleList.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/IndexedAlleleList.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/IndexedSampleList.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/IndexedSampleList.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/IndexedSampleList.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/IndexedSampleList.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/SampleList.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/SampleList.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/SampleList.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/SampleList.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/SampleListUtils.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/SampleListUtils.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/genotyping/SampleListUtils.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/genotyping/SampleListUtils.java
diff --git a/protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/collections/IndexedSet.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/collections/IndexedSet.java
similarity index 100%
rename from protected/gatk-tools-protected/src/main/java/org/broadinstitute/gatk/utils/collections/IndexedSet.java
rename to public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/collections/IndexedSet.java
diff --git a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/genotyper/ReadLikelihoods.java b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/genotyper/ReadLikelihoods.java
index bf12d3a33..8deb30f49 100644
--- a/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/genotyper/ReadLikelihoods.java
+++ b/public/gatk-tools-public/src/main/java/org/broadinstitute/gatk/utils/genotyper/ReadLikelihoods.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2012 The Broad Institute
-*
+*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
@@ -9,10 +9,10 @@
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
-*
+*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
-*
+*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
@@ -30,6 +30,7 @@ import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import org.broadinstitute.gatk.engine.downsampling.AlleleBiasedDownsamplingUtils;
+import org.broadinstitute.gatk.genotyping.*;
import org.broadinstitute.gatk.utils.GenomeLoc;
import org.broadinstitute.gatk.utils.Utils;
import org.broadinstitute.gatk.utils.sam.GATKSAMRecord;
@@ -42,7 +43,7 @@ import java.util.*;
*
* @author Valentin Ruano-Rubio <valentin@broadinstitute.org>
*/
-public class ReadLikelihoods implements Cloneable {
+public class ReadLikelihoods implements SampleList, AlleleList, Cloneable {
/**
* Reads by sample index. Each sub array contains reference to the reads of the ith sample.
@@ -58,44 +59,37 @@ public class ReadLikelihoods implements Cloneable {
private double[][][] valuesBySampleIndex;
/**
- * Sorted list samples.
+ * Sample list
*/
- private final String[] samples;
+ private final SampleList samples;
/**
- * Unmodifiable list version of the samples
+ * Allele list
*/
- private List In order to save CPU time the indices contained in this array (not the array itself) is
+ * lazily initialized by invoking {@link #readIndexBySampleIndex(int)}.
- * The matrix is indexed by allele and the by read index.
- *
- *
- * result[a][r] == lnLk(Read_r | Allele_a)
- *
- *
- * The matrix is live and changes to it update the likelihood in the collection, please use with care. - *
- * - * @param sampleIndex the sample index. - * - * @return never {@code null}. - */ - /* package */ double[][] sampleValues(final int sampleIndex) { - checkSampleIndex(sampleIndex); - return valuesBySampleIndex[sampleIndex]; - } - - /** * Returns a read vs allele likelihood matrix corresponding to a sample. * @@ -441,7 +337,7 @@ public class ReadLikelihoods implements Cloneable { if (maximumLikelihoodDifferenceCap == Double.NEGATIVE_INFINITY && !bestToZero) return; - final int alleleCount = alleles.length; + final int alleleCount = alleles.alleleCount(); if (alleleCount == 0) // trivial case there is no alleles. return; else if (alleleCount == 1 && !bestToZero) @@ -469,19 +365,20 @@ public class ReadLikelihoods implements Cloneable { final double bestAbsoluteLikelihood = Math.max(bestAlternativeAllele.likelihood,referenceLikelihood); + final int alleleCount = alleles.alleleCount(); if (bestToZero) { if (bestAbsoluteLikelihood == Double.NEGATIVE_INFINITY) - for (int a = 0; a < alleles.length; a++) + for (int a = 0; a < alleleCount; a++) sampleValues[a][readIndex] = 0; else if (worstLikelihoodCap != Double.NEGATIVE_INFINITY) - for (int a = 0; a < alleles.length; a++) + for (int a = 0; a < alleleCount; a++) sampleValues[a][readIndex] = (sampleValues[a][readIndex] < worstLikelihoodCap ? worstLikelihoodCap : sampleValues[a][readIndex]) - bestAbsoluteLikelihood; else - for (int a = 0; a < alleles.length; a++) + for (int a = 0; a < alleleCount; a++) sampleValues[a][readIndex] -= bestAbsoluteLikelihood; } else // else if (maximumReferenceLikelihoodFall != Double.NEGATIVE_INFINITY ) { // - // Guarantee to be the case by enclosing code. - for (int a = 0; a < alleles.length; a++) + // Guarantee to be the case by enclosing code. + for (int a = 0; a < alleleCount; a++) if (sampleValues[a][readIndex] < worstLikelihoodCap) sampleValues[a][readIndex] = worstLikelihoodCap; } @@ -499,9 +396,8 @@ public class ReadLikelihoods implements Cloneable { * @return never {@code null}. */ public List- * If not, it throws an exception. - *
- * @param alleleIndex the target sample index. - * - * @throws IllegalArgumentException if {@code alleleIndex} is invalid, i.e. outside the range [0,{@link #sampleCount}). - */ - private void checkAlleleIndex(final int alleleIndex) { - if (alleleIndex < 0 || alleleIndex >= alleles.length) - throw new IllegalArgumentException("invalid allele index: " + alleleIndex); - } } \ No newline at end of file