Skip to content

Commit

Permalink
renaming to use one convention
Browse files Browse the repository at this point in the history
  • Loading branch information
akiezun committed Jul 31, 2015
1 parent 2aa0567 commit 64a032a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public interface LikelihoodMatrix<A extends Allele> extends AlleleList<A> {
* @return -1 if there is not such a read in the matrix, otherwise its index
* which is 0 or greater.
*/
public int readIndex(final GATKRead read);
public int indexOfRead(final GATKRead read);

/**
* Number of allele in the matrix.
Expand All @@ -81,7 +81,7 @@ public interface LikelihoodMatrix<A extends Allele> extends AlleleList<A> {
* Number of reads in the matrix.
* @return never negative.
*/
public int readCount();
public int numberOfReads();

/**
* Returns the allele given its index.
Expand All @@ -101,7 +101,7 @@ public interface LikelihoodMatrix<A extends Allele> extends AlleleList<A> {
* @throws IllegalArgumentException if {@code readIndex} is not a valid read index.
* @return never {@code null}.
*/
public GATKRead readAt(final int readIndex);
public GATKRead getRead(final int readIndex);


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public static ReadLikelihoods<Allele> fromPerAlleleReadLikelihoodsMap(final Map<
final LikelihoodMatrix<Allele> sampleMatrix = result.sampleMatrix(result.indexOfSample(sampleEntry.getKey()));
for (final Map.Entry<GATKRead,Map<Allele,Double>> readEntry : sampleEntry.getValue().getLikelihoodReadMap().entrySet()) {
final GATKRead read = readEntry.getKey();
final int readIndex = sampleMatrix.readIndex(read);
final int readIndex = sampleMatrix.indexOfRead(read);
for (final Map.Entry<Allele,Double> alleleEntry : readEntry.getValue().entrySet()) {
final int alleleIndex = result.indexOfAllele(alleleEntry.getKey());
sampleMatrix.set(alleleIndex,readIndex,alleleEntry.getValue());
Expand Down Expand Up @@ -1108,7 +1108,7 @@ public static ReadLikelihoods<Allele> fromPerAlleleReadLikelihoodsMap(final Alle
final LikelihoodMatrix<Allele> sampleMatrix = result.sampleMatrix(result.indexOfSample(sampleEntry.getKey()));
for (final Map.Entry<GATKRead,Map<Allele,Double>> readEntry : sampleEntry.getValue().getLikelihoodReadMap().entrySet()) {
final GATKRead read = readEntry.getKey();
final int readIndex = sampleMatrix.readIndex(read);
final int readIndex = sampleMatrix.indexOfRead(read);
final Map<Allele,Double> alleleToLikelihoodMap = readEntry.getValue();
for (int a = 0; a < alleleCount; a++) {
final Allele allele = alleleList.getAllele(a);
Expand Down Expand Up @@ -1469,7 +1469,7 @@ public int indexOfAllele(final A allele) {
}

@Override
public int readIndex(final GATKRead read) {
public int indexOfRead(final GATKRead read) {
return ReadLikelihoods.this.readIndex(sampleIndex, read);
}

Expand All @@ -1479,7 +1479,7 @@ public int numberOfAlleles() {
}

@Override
public int readCount() {
public int numberOfReads() {
return readsBySampleIndex[sampleIndex].length;
}

Expand All @@ -1489,7 +1489,7 @@ public A getAllele(final int alleleIndex) {
}

@Override
public GATKRead readAt(final int readIndex) {
public GATKRead getRead(final int readIndex) {
if (readIndex < 0) {
throw new IllegalArgumentException("the read-index cannot be negative");
}
Expand All @@ -1502,7 +1502,7 @@ public GATKRead readAt(final int readIndex) {

@Override
public void copyAlleleLikelihoods(final int alleleIndex, final double[] dest, final int offset) {
System.arraycopy(valuesBySampleIndex[sampleIndex][alleleIndex], 0, dest, offset, readCount());
System.arraycopy(valuesBySampleIndex[sampleIndex][alleleIndex], 0, dest, offset, numberOfReads());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void testBestAlleleMap(final String[] samples, final Allele[] alleles, fi
}
}
if ((bestAlleleLk - secondBestAlleleLk) > ReadLikelihoods.BestAllele.INFORMATIVE_THRESHOLD)
expected.get(alleles[bestAlleleIndex]).add(sampleMatrix.readAt(r));
expected.get(alleles[bestAlleleIndex]).add(sampleMatrix.getRead(r));
}
}

Expand Down Expand Up @@ -188,7 +188,7 @@ public void testFilterReadsToOverlap(final String[] samples, final Allele[] alle
newLikelihoods[s][a] = new double[(original.sampleReadCount(s) + 1) / 2];
final LikelihoodMatrix<Allele> sampleMatrix = original.sampleMatrix(s);
for (int r = 0; r < newLikelihoods[s][a].length; r++) {
Assert.assertEquals(result.readIndex(s,sampleMatrix.readAt(r << 1)),r);
Assert.assertEquals(result.readIndex(s,sampleMatrix.getRead(r << 1)),r);
newLikelihoods[s][a][r] = sampleMatrix.get(a, r << 1);
}
}
Expand All @@ -209,8 +209,8 @@ public void testMarginalizationWithOverlap(final String[] samples, final Allele[
for (int s = 0; s < samples.length; s++) {
final LikelihoodMatrix<Allele> oldSmapleLikelihoods = original.sampleMatrix(s);
final LikelihoodMatrix<Allele> sampleLikelihoods = marginalized.sampleMatrix(s);
final int sampleReadCount = sampleLikelihoods.readCount();
final int oldSampleReadCount = oldSmapleLikelihoods.readCount();
final int sampleReadCount = sampleLikelihoods.numberOfReads();
final int oldSampleReadCount = oldSmapleLikelihoods.numberOfReads();
Assert.assertEquals(sampleReadCount,(oldSampleReadCount + 1) / 2);
for (int r = 0; r < sampleReadCount; r++) {
double oldBestLk = Double.NEGATIVE_INFINITY;
Expand All @@ -236,8 +236,8 @@ public void testMarginalization(final String[] samples, final Allele[] alleles,
for (int s = 0; s < samples.length; s++) {
final LikelihoodMatrix<Allele> oldSmapleLikelihoods = original.sampleMatrix(s);
final LikelihoodMatrix<Allele> sampleLikelihoods = marginalized.sampleMatrix(s);
final int sampleReadCount = sampleLikelihoods.readCount();
final int oldSampleReadCount = oldSmapleLikelihoods.readCount();
final int sampleReadCount = sampleLikelihoods.numberOfReads();
final int oldSampleReadCount = oldSmapleLikelihoods.numberOfReads();
Assert.assertEquals(oldSampleReadCount,sampleReadCount);
for (int r = 0; r < sampleReadCount; r++) {
double oldBestLk = Double.NEGATIVE_INFINITY;
Expand Down Expand Up @@ -600,7 +600,7 @@ public void testLikelihoodWriting(final int[] readCounts, final int alleleCount,
for (int s = 0; s < sampleCount; s++) {
expectedLikelihoodsSet += readCounts[s] * alleleCount;
final LikelihoodMatrix<Allele> matrix = subject.sampleMatrix(s);
final int readCount = matrix.readCount();
final int readCount = matrix.numberOfReads();
for (int a = 0; a < alleleCount; a++)
for (int r = 0; r < readCount; r++) {
final double likelihood = testLikelihood(s, a, r);
Expand Down Expand Up @@ -658,7 +658,7 @@ public void testMapConversion(final int[] readCounts, final int alleleCount, fin
for (int r = 0; r < sampleReadCount; r++) {
final GATKRead read = sampleToReads.get(sample).get(r);
final int rIndex = subject.readIndex(sIndex,read);
final int rIndex2 = sampleLikelihoods.readIndex(read);
final int rIndex2 = sampleLikelihoods.indexOfRead(read);
Assert.assertEquals(rIndex,rIndex2);
Assert.assertEquals(rIndex >= 0,readsWithLikelihoodsSet.contains(read));
Assert.assertTrue(rIndex < sampleReadCount);
Expand Down Expand Up @@ -686,11 +686,11 @@ private void testLikelihoodMatrixQueries(final AlleleList<Allele> alleles, final
final int sampleReadCount = sampleToReads.get(sample).size();
final List<GATKRead> reads = sampleToReads.get(sample);
Assert.assertEquals(likelihoodMatrix.numberOfAlleles(), alleles.numberOfAlleles());
Assert.assertEquals(likelihoodMatrix.readCount(), sampleReadCount);
Assert.assertEquals(likelihoodMatrix.numberOfReads(), sampleReadCount);
for (int a = 0; a < likelihoodMatrix.numberOfAlleles(); a++) {
Assert.assertEquals(likelihoodMatrix.getAllele(a),alleles.getAllele(a));
for (int r = 0; r < sampleReadCount; r++) {
Assert.assertEquals(likelihoodMatrix.readAt(r),reads.get(r));
Assert.assertEquals(likelihoodMatrix.getRead(r),reads.get(r));
Assert.assertEquals(likelihoodMatrix.get(a, r), 0.0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public int indexOfAllele(Haplotype allele) {
}

@Override
public int readIndex(GATKRead read) {
public int indexOfRead(GATKRead read) {
throw new UnsupportedOperationException();
}

Expand All @@ -536,7 +536,7 @@ public int numberOfAlleles() {
}

@Override
public int readCount() {
public int numberOfReads() {
throw new UnsupportedOperationException();
}

Expand All @@ -546,7 +546,7 @@ public Haplotype getAllele(int alleleIndex) {
}

@Override
public GATKRead readAt(int readIndex) {
public GATKRead getRead(int readIndex) {
throw new UnsupportedOperationException();
}

Expand Down

0 comments on commit 64a032a

Please sign in to comment.