Java Code Examples for htsjdk.samtools.util.StringUtil#charToByte()

The following examples show how to use htsjdk.samtools.util.StringUtil#charToByte() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LikelihoodUtilsTest.java    From Drop-seq with MIT License 6 votes vote down vote up
@Test(enabled=true)
public void testMixedLikelihoodMultiRead () {
	GenotypeType [] g = {GenotypeType.HOM_REF, GenotypeType.HET, GenotypeType.HOM_VAR};
	List<GenotypeType> genotypes  = Arrays.asList(g);

	Double [] m = {new Double(2), new Double(1), new Double(1)};
	List<Double> mixture  = Arrays.asList(m);

	char refAllele ='A';
	char altAllele ='T';

	Byte [] b = {StringUtil.charToByte('A'), StringUtil.charToByte('A')};
	List<Byte> bases = Arrays.asList(b);
	Byte [] q = {new Byte ((byte)10), new Byte ((byte)10)};
	List<Byte> qualities =Arrays.asList(q);

	double result = LikelihoodUtils.getInstance().getLogLikelihoodMixedModel(refAllele, altAllele, genotypes, mixture, bases, qualities, null, null, null);
	Assert.assertEquals(result, Math.log10(0.36), 0.001);

}
 
Example 2
Source File: SNPBasePileUp.java    From Drop-seq with MIT License 5 votes vote down vote up
public int getCountBase (final char base) {
	Byte baseB = StringUtil.charToByte(base);
	int count=0;
	for (Byte b: bases)
		if (b.equals(baseB)) count++;
	return count;
}
 
Example 3
Source File: LikelihoodUtils.java    From Drop-seq with MIT License 4 votes vote down vote up
public double getLogLikelihood (final char refAllele, final char altAllele, final List<Byte> bases, final List<Byte> qualities, final Double genotypeQuality, final Double maximumObservationProbability) {
	byte ref= StringUtil.charToByte(refAllele);
	byte alt= StringUtil.charToByte(altAllele);
	return getLogLikelihood(ref, alt, bases, qualities, genotypeQuality, maximumObservationProbability);
}
 
Example 4
Source File: LikelihoodUtils.java    From Drop-seq with MIT License 3 votes vote down vote up
/**
 * Calculate the likelihood for a pileup of bases and qualities using a mixture of different models.
 * For example, one could calculate a mixture of two genotypes, a ref and a het, by adding those two models to the states list, and adding to 0.5 entries to the mixture list.
 * For each base, the probability of each of the genotypes is calculated and multiplied by the mixture for that genotype.  The individual likelihoods are then summed,
 * and the result is then divided by the sum of the mixtures.
 * This is done per observation, then the log is taken and the results of all log-likelihoods are summed.
 *
 * @param refAllele the reference allele for the variant
 * @param altAllele the alternate allele for the variant
 * @param The list of genotype states for the observed genotypes for the variant (donors that correctly genotyped)
 * @param mixture The list of mixture parameters that these genotypes are mixed by.  This list must be in the same order as the genotype states.
 * @param bases The bases observed
 * @param qualities The qualities of the bases observed.  This list must be in the same order as the bases observed.
 * @return
 */
public double getLogLikelihoodMixedModel (final char refAllele, final char altAllele, final List<GenotypeType> genotypes,
		final List<Double> mixture, final List<Byte> bases, final List<Byte> qualities, final Double missingDataPenality, final Double genotypeProbability, final Double maximumObservationProbability) {

	byte ref= StringUtil.charToByte(refAllele);
	byte alt= StringUtil.charToByte(altAllele);
	double result = getLogLikelihoodMixedModel(ref, alt, genotypes, mixture, bases, qualities, missingDataPenality, genotypeProbability, maximumObservationProbability);
	return result;
}