A few more char -> byte cleanups
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3398 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
8a725b6c93
commit
5abac5c057
|
|
@ -53,6 +53,9 @@ public class ReferenceContext {
|
|||
*/
|
||||
private byte[] bases;
|
||||
|
||||
/**
|
||||
* A cache of the bases converted to characters for walkers not yet using byte[] interface
|
||||
*/
|
||||
private char[] basesAsCharCached = null;
|
||||
|
||||
/**
|
||||
|
|
@ -64,6 +67,7 @@ public class ReferenceContext {
|
|||
this( locus, locus, new byte[] { base } );
|
||||
}
|
||||
|
||||
// todo -- this really should take the referenceview as an option and only grab the bases if necessary
|
||||
public ReferenceContext( GenomeLoc locus, GenomeLoc window, byte[] bases ) {
|
||||
// if( !window.containsP(locus) )
|
||||
// throw new StingException("Invalid locus or window; window does not contain locus");
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2010.
|
||||
* Copyright (c) 2010, The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -12,15 +12,14 @@
|
|||
*
|
||||
* 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
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.gatk.walkers.genotyper;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2010.
|
||||
* Copyright (c) 2010, The Broad Institute
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
|
@ -12,15 +12,14 @@
|
|||
*
|
||||
* 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
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
|
||||
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.broadinstitute.sting.gatk.walkers.genotyper;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class DiploidGenotypePriors {
|
|||
* @param ref
|
||||
* @param heterozygosity
|
||||
*/
|
||||
public DiploidGenotypePriors(char ref, double heterozygosity, boolean dontPolarize) {
|
||||
public DiploidGenotypePriors(byte ref, double heterozygosity, boolean dontPolarize) {
|
||||
if ( dontPolarize ) {
|
||||
double[] vals = heterozygosity2DiploidProbabilities(heterozygosity);
|
||||
priors = getReferenceIndependentPriors(ref, vals[0], vals[1], vals[2]);
|
||||
|
|
@ -90,7 +90,7 @@ public class DiploidGenotypePriors {
|
|||
* @param heterozygosity
|
||||
* @param probOfTriStateGenotype The prob of seeing a true B/C het when the reference is A
|
||||
*/
|
||||
public DiploidGenotypePriors(char ref, double heterozygosity, double probOfTriStateGenotype) {
|
||||
public DiploidGenotypePriors(byte ref, double heterozygosity, double probOfTriStateGenotype) {
|
||||
priors = getReferencePolarizedPriors(ref, heterozygosity, probOfTriStateGenotype);
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ public class DiploidGenotypePriors {
|
|||
* @param heterozyosity
|
||||
* @param pRefError
|
||||
*/
|
||||
public static double[] getReferencePolarizedPriors(char ref, double heterozyosity, double pRefError ) {
|
||||
public static double[] getReferencePolarizedPriors(byte ref, double heterozyosity, double pRefError ) {
|
||||
if ( ! MathUtils.isBounded(pRefError, 0.0, 0.01) ) {
|
||||
throw new RuntimeException(String.format("BUG: p Reference error is out of bounds (0.0 - 0.01) is allow range %f", pRefError));
|
||||
}
|
||||
|
|
@ -276,7 +276,7 @@ public class DiploidGenotypePriors {
|
|||
* @param priorHomVar
|
||||
*/
|
||||
@Deprecated
|
||||
public static double[] getReferenceIndependentPriors(char ref, double priorHomRef, double priorHet, double priorHomVar ) {
|
||||
public static double[] getReferenceIndependentPriors(byte ref, double priorHomRef, double priorHet, double priorHomVar ) {
|
||||
if ((priorHomRef + priorHet + priorHomVar) != 1) {
|
||||
throw new RuntimeException(String.format("Prior probabilities don't sum to one => %f, %f, %f", priorHomRef, priorHet, priorHomVar));
|
||||
}
|
||||
|
|
@ -284,7 +284,7 @@ public class DiploidGenotypePriors {
|
|||
double[] priors = new double[DiploidGenotype.values().length];
|
||||
|
||||
for ( DiploidGenotype g : DiploidGenotype.values() ) {
|
||||
int nRefBases = MathUtils.countOccurrences(ref, g.toString());
|
||||
int nRefBases = MathUtils.countOccurrences((char)ref, g.toString()); // todo -- fixme
|
||||
double log10POfG = 0.0;
|
||||
|
||||
switch ( nRefBases ) {
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ public class UnifiedGenotyperEngine {
|
|||
if ( stratifiedContexts == null )
|
||||
return null;
|
||||
|
||||
DiploidGenotypePriors priors = new DiploidGenotypePriors(ref, UAC.heterozygosity, DiploidGenotypePriors.PROB_OF_REFERENCE_ERROR);
|
||||
DiploidGenotypePriors priors = new DiploidGenotypePriors((byte)ref, UAC.heterozygosity, DiploidGenotypePriors.PROB_OF_REFERENCE_ERROR);
|
||||
call = gcm.get().callLocus(tracker, ref, rawContext.getLocation(), stratifiedContexts, priors);
|
||||
|
||||
// annotate the call, if possible
|
||||
|
|
|
|||
|
|
@ -638,19 +638,19 @@ public class VariantEvalWalker extends RodWalker<Integer, Integer> {
|
|||
}
|
||||
}
|
||||
|
||||
private String formatKeyword(String keyWord) {
|
||||
//System.out.printf("keyword %s%n", keyWord);
|
||||
|
||||
StringBuilder s = new StringBuilder();
|
||||
int i = 0;
|
||||
for ( String part : keyWord.split("\\.") ) {
|
||||
//System.out.printf("part %s %d%n", part, nameSizes[i]);
|
||||
s.append(String.format("%" + nameSizes[i] + "s ", part));
|
||||
i++;
|
||||
}
|
||||
|
||||
return s.toString();
|
||||
}
|
||||
// private String formatKeyword(String keyWord) {
|
||||
// //System.out.printf("keyword %s%n", keyWord);
|
||||
//
|
||||
// StringBuilder s = new StringBuilder();
|
||||
// int i = 0;
|
||||
// for ( String part : keyWord.split("\\.") ) {
|
||||
// //System.out.printf("part %s %d%n", part, nameSizes[i]);
|
||||
// s.append(String.format("%" + nameSizes[i] + "s ", part));
|
||||
// i++;
|
||||
// }
|
||||
//
|
||||
// return s.toString();
|
||||
// }
|
||||
|
||||
public void onTraversalDone(Integer result) {
|
||||
// our report mashaller
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class GATKPaperGenotyper extends LocusWalker<SimpleCall, Integer> impleme
|
|||
if (ref.getBase() == 'N' || ref.getBase() == 'n') return null; // we don't deal with the N ref base case
|
||||
|
||||
ReadBackedPileup pileup = context.getPileup();
|
||||
double likelihoods[] = DiploidGenotypePriors.getReferencePolarizedPriors(ref.getBaseAsChar(),
|
||||
double likelihoods[] = DiploidGenotypePriors.getReferencePolarizedPriors(ref.getBase(),
|
||||
DiploidGenotypePriors.HUMAN_HETEROZYGOSITY,
|
||||
0.01);
|
||||
// get the bases and qualities from the pileup
|
||||
|
|
|
|||
|
|
@ -47,22 +47,31 @@ public enum DiploidGenotype {
|
|||
GT ('G', 'T'),
|
||||
TT ('T', 'T');
|
||||
|
||||
public char base1, base2;
|
||||
public byte base1, base2;
|
||||
|
||||
private DiploidGenotype(char base1, char base2) {
|
||||
this((byte)base1, (byte)base2);
|
||||
}
|
||||
|
||||
private DiploidGenotype(byte base1, byte base2) {
|
||||
this.base1 = base1;
|
||||
this.base2 = base2;
|
||||
}
|
||||
|
||||
public boolean isHomRef(char r) {
|
||||
public boolean isHomRef(byte r) {
|
||||
return isHom() && r == base1;
|
||||
}
|
||||
|
||||
public boolean isHomVar(char r) {
|
||||
public boolean isHomVar(byte r) {
|
||||
return isHom() && r != base1;
|
||||
}
|
||||
|
||||
public boolean isHetRef(char r) {
|
||||
return MathUtils.countOccurrences(r, this.toString()) == 1;
|
||||
public boolean isHetRef(byte r) {
|
||||
if ( base1 == r )
|
||||
return r != base2;
|
||||
else
|
||||
return base2 == r;
|
||||
//return MathUtils.countOccurrences(r, this.toString()) == 1;
|
||||
}
|
||||
|
||||
public boolean isHom() {
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest {
|
|||
private void testGenotypePriors(char ref, double h, double[] array) {
|
||||
for ( DiploidGenotype g : DiploidGenotype.values() ) {
|
||||
double val = 0.0;
|
||||
if ( g.isHomRef(ref) ) val = DiploidGenotypePriors.heterozygosity2HomRefProbability(h);
|
||||
if ( g.isHomRef((byte)ref) ) val = DiploidGenotypePriors.heterozygosity2HomRefProbability(h);
|
||||
if ( g.isHet() ) val = DiploidGenotypePriors.heterozygosity2HetProbability(h);
|
||||
if ( g.isHomVar(ref) ) val = DiploidGenotypePriors.heterozygosity2HomVarProbability(h);
|
||||
if ( g.isHomVar((byte)ref) ) val = DiploidGenotypePriors.heterozygosity2HomVarProbability(h);
|
||||
|
||||
val = log10(val);
|
||||
double e = array[g.ordinal()];
|
||||
|
|
@ -99,7 +99,7 @@ public class GenotypeLikelihoodsUnitTest extends BaseTest {
|
|||
}
|
||||
|
||||
private void testPolarizedGenotypePriors(char ref, double h, double pRefError, double[] array) {
|
||||
DiploidGenotypePriors priors = new DiploidGenotypePriors(ref, h, pRefError);
|
||||
DiploidGenotypePriors priors = new DiploidGenotypePriors((byte)ref, h, pRefError);
|
||||
for ( DiploidGenotype g : DiploidGenotype.values() ) {
|
||||
double val = Math.pow(10, priors.getPrior(g));
|
||||
double e = array[g.ordinal()];
|
||||
|
|
|
|||
Loading…
Reference in New Issue