
org.snpeff.stats.ObservedOverExpectedCpG Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SnpEff Show documentation
Show all versions of SnpEff Show documentation
Variant annotation and effect prediction package.
The newest version!
package org.snpeff.stats;
/**
* Observed over expected values (o/e) of CpG in a sequence
*
* @author pcingola
*
*/
public class ObservedOverExpectedCpG extends ObservedOverExpected {
@Override
public double expected(String sequence) {
return sequence.length() / 16.0; // P[ base(i) = C ] * P[ base(i+1) = G] is 1/16
}
/**
* Count the number of CpG in this sequence
* @param sequence
* @return
*/
@Override
public int observed(String sequence) {
char seq[] = sequence.toUpperCase().toCharArray();
int cpg = 0;
for( int pos = 0; pos < (seq.length - 1); pos++ )
if( (seq[pos] == 'C') && (seq[pos + 1] == 'G') ) cpg++;
return cpg;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy