Intermediate checking for evaluation -- now supports transition / transversion evaluation
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@793 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
f2ea193149
commit
7a979859a9
|
|
@ -73,11 +73,12 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements AllelicVaria
|
|||
*
|
||||
* @return reference allele, forward strand
|
||||
*/
|
||||
public String getRefBasesFWD() {
|
||||
if ( onFwdStrand() )
|
||||
return refBases;
|
||||
else
|
||||
return SequenceUtil.reverseComplement(refBases);
|
||||
public String getRefBasesFWD() {
|
||||
return getAllelesFWD().get(0);
|
||||
//if ( onFwdStrand() )
|
||||
// return refBases;
|
||||
//else
|
||||
// return SequenceUtil.reverseComplement(refBases);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -87,9 +88,11 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements AllelicVaria
|
|||
* @return reference base on the forward strand
|
||||
*/
|
||||
public char getRefSnpFWD() throws IllegalStateException {
|
||||
//System.out.printf("refbases is %s but %s%n", refBases, toString());
|
||||
if ( isIndel() ) throw new IllegalStateException("Variant is not a SNP");
|
||||
if ( onFwdStrand() ) return refBases.charAt(0);
|
||||
else return SequenceUtil.reverseComplement(refBases).charAt(0);
|
||||
return getAllelesFWD().get(0).charAt(0);
|
||||
// if ( onFwdStrand() ) return refBases.charAt(0);
|
||||
// else return SequenceUtil.reverseComplement(refBases).charAt(0);
|
||||
}
|
||||
|
||||
public List<String> getAllelesFWD() {
|
||||
|
|
@ -187,8 +190,7 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements AllelicVaria
|
|||
|
||||
@Override
|
||||
public char getAltSnpFWD() throws IllegalStateException {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return getAllelesFWD().get(1).charAt(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -205,8 +207,8 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements AllelicVaria
|
|||
|
||||
@Override
|
||||
public double getMAF() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
// Fixme: update to actually get MAF
|
||||
return avHet;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -218,7 +220,7 @@ public class rodDbSNP extends BasicReferenceOrderedDatum implements AllelicVaria
|
|||
@Override
|
||||
public double getVariationConfidence() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.playground.gatk.walkers;
|
||||
package org.broadinstitute.sting.playground.gatk.duplicates.walkers;
|
||||
|
||||
import org.broadinstitute.sting.gatk.LocusContext;
|
||||
import org.broadinstitute.sting.gatk.walkers.DuplicateWalker;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,38 @@ package org.broadinstitute.sting.utils;
|
|||
* @author Kiran Garimella
|
||||
*/
|
||||
public class BaseUtils {
|
||||
|
||||
/// In genetics, a transition is a mutation changing a purine to another purine nucleotide (A <-> G) or
|
||||
// a pyrimidine to another pyrimidine nucleotide (C <-> T).
|
||||
// Approximately two out of every three single nucleotide polymorphisms (SNPs) are transitions.
|
||||
public enum BaseSubstitutionType {
|
||||
TRANSITION, // A <-> G or C <-> T
|
||||
TRANSVERSION
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base substitution type of the 2 state SNP
|
||||
* @param base1
|
||||
* @param base2
|
||||
* @return
|
||||
*/
|
||||
public static BaseSubstitutionType SNPSubstitutionType( char base1, char base2 ) {
|
||||
BaseSubstitutionType t = isTransition(base1, base2) ? BaseSubstitutionType.TRANSITION : BaseSubstitutionType.TRANSVERSION;
|
||||
//System.out.printf("SNPSubstitutionType( char %c, char %c ) => %s%n", base1, base2, t);
|
||||
return t;
|
||||
}
|
||||
|
||||
public static boolean isTransition( char base1, char base2 ) {
|
||||
int b1 = simpleBaseToBaseIndex(base1);
|
||||
int b2 = simpleBaseToBaseIndex(base2);
|
||||
return b1 == 0 && b2 == 2 || b1 == 2 && b2 == 0 ||
|
||||
b1 == 1 && b2 == 3 || b1 == 3 && b2 == 1;
|
||||
}
|
||||
|
||||
public static boolean isTransversion( char base1, char base2 ) {
|
||||
return ! isTransition(base1, base2);
|
||||
}
|
||||
|
||||
/** Private constructor. No instantiating this class! */
|
||||
private BaseUtils() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,33 @@ public class BaseUtilsTest extends BaseTest {
|
|||
compareFrequentBaseFractionToExpected("ACCCCTTTTG", 4.0/10.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransitionTransversion() {
|
||||
logger.warn("Executing testTransitionTransversion");
|
||||
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'T' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'C' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'G' ) == BaseUtils.BaseSubstitutionType.TRANSITION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'C', 'A' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'C', 'T' ) == BaseUtils.BaseSubstitutionType.TRANSITION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'C', 'G' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'T', 'A' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'T', 'C' ) == BaseUtils.BaseSubstitutionType.TRANSITION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'T', 'G' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'G', 'A' ) == BaseUtils.BaseSubstitutionType.TRANSITION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'G', 'T' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'G', 'C' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'a', 'T' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'a', 'C' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'T' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'C' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 't' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'A', 'c' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'a', 't' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
Assert.assertTrue( BaseUtils.SNPSubstitutionType( 'a', 'c' ) == BaseUtils.BaseSubstitutionType.TRANSVERSION );
|
||||
}
|
||||
|
||||
private void compareFrequentBaseFractionToExpected(String sequence, double expected) {
|
||||
double fraction = BaseUtils.mostFrequentBaseFraction(sequence.getBytes());
|
||||
Assert.assertTrue(MathUtils.compareDoubles(fraction, expected) == 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue