Validate that the reference padding base for indels is correct.

This commit is contained in:
Eric Banks 2011-08-04 12:48:56 -04:00
parent f10588420c
commit e48492f3c3
2 changed files with 10 additions and 5 deletions

View File

@ -154,10 +154,10 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
try {
switch( type ) {
case ALL:
vc.extraStrictValidation(observedRefAllele, rsIDs);
vc.extraStrictValidation(observedRefAllele, ref.getBase(), rsIDs);
break;
case REF:
vc.validateReferenceBases(observedRefAllele);
vc.validateReferenceBases(observedRefAllele, ref.getBase());
break;
case IDS:
vc.validateRSIDs(rsIDs);

View File

@ -1055,11 +1055,12 @@ public class VariantContext implements Feature { // to enable tribble intergrati
* Run all extra-strict validation tests on a Variant Context object
*
* @param reference the true reference allele
* @param paddedRefBase the reference base used for padding indels
* @param rsIDs the true dbSNP IDs
*/
public void extraStrictValidation(Allele reference, Set<String> rsIDs) {
public void extraStrictValidation(Allele reference, Byte paddedRefBase, Set<String> rsIDs) {
// validate the reference
validateReferenceBases(reference);
validateReferenceBases(reference, paddedRefBase);
// validate the RS IDs
validateRSIDs(rsIDs);
@ -1074,11 +1075,15 @@ public class VariantContext implements Feature { // to enable tribble intergrati
//checkReferenceTrack();
}
public void validateReferenceBases(Allele reference) {
public void validateReferenceBases(Allele reference, Byte paddedRefBase) {
// don't validate if we're an insertion
if ( !reference.isNull() && !reference.basesMatch(getReference()) ) {
throw new TribbleException.InternalCodecException(String.format("the REF allele is incorrect for the record at position %s:%d, %s vs. %s", getChr(), getStart(), reference.getBaseString(), getReference().getBaseString()));
}
// we also need to validate the padding base for simple indels
if ( hasReferenceBaseForIndel() && !getReferenceBaseForIndel().equals(paddedRefBase) )
throw new TribbleException.InternalCodecException(String.format("the padded REF base is incorrect for the record at position %s:%d, %s vs. %s", getChr(), getStart(), (char)getReferenceBaseForIndel().byteValue(), (char)paddedRefBase.byteValue()));
}
public void validateRSIDs(Set<String> rsIDs) {