Fixed bug in the IndelRealigner: now that variants are correctly typed in VariantContext, it is possible that a variant can be an indel but neither an insertion or a deletion; added a isComplexIndel() method and now we check for such an event in the realigner (we don't use them to generate alternate consenses). Also, added a isMNP() method while I was there so that it would be consistent with other variant types.
This commit is contained in:
parent
f018c27050
commit
1f19afe1d9
|
|
@ -798,11 +798,11 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
|||
|
||||
private void generateAlternateConsensesFromKnownIndels(final Set<Consensus> altConsensesToPopulate, final int leftmostIndex, final byte[] reference) {
|
||||
for ( VariantContext knownIndel : knownIndelsToTry ) {
|
||||
if ( knownIndel == null || !knownIndel.isIndel() )
|
||||
if ( knownIndel == null || !knownIndel.isIndel() || knownIndel.isComplexIndel() )
|
||||
continue;
|
||||
byte[] indelStr = knownIndel.isInsertion() ? knownIndel.getAlternateAllele(0).getBases() : Utils.dupBytes((byte)'-', knownIndel.getReference().length());
|
||||
int start = knownIndel.getStart() - leftmostIndex + 1;
|
||||
Consensus c = createAlternateConsensus(start, reference, indelStr, knownIndel.isDeletion());
|
||||
Consensus c = createAlternateConsensus(start, reference, indelStr, knownIndel);
|
||||
if ( c != null )
|
||||
altConsensesToPopulate.add(c);
|
||||
}
|
||||
|
|
@ -988,7 +988,7 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
|||
}
|
||||
|
||||
// create a Consensus from just the indel string that falls on the reference
|
||||
private Consensus createAlternateConsensus(final int indexOnRef, final byte[] reference, final byte[] indelStr, final boolean isDeletion) {
|
||||
private Consensus createAlternateConsensus(final int indexOnRef, final byte[] reference, final byte[] indelStr, final VariantContext indel) {
|
||||
if ( indexOnRef < 0 || indexOnRef >= reference.length )
|
||||
return null;
|
||||
|
||||
|
|
@ -1002,11 +1002,11 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
|
|||
if ( indexOnRef > 0 )
|
||||
cigar.add(new CigarElement(indexOnRef, CigarOperator.M));
|
||||
|
||||
if ( isDeletion ) {
|
||||
if ( indel.isDeletion() ) {
|
||||
refIdx += indelStr.length;
|
||||
cigar.add(new CigarElement(indelStr.length, CigarOperator.D));
|
||||
}
|
||||
else {
|
||||
else if ( indel.isInsertion() ) {
|
||||
for ( byte b : indelStr )
|
||||
sb.append((char)b);
|
||||
cigar.add(new CigarElement(indelStr.length, CigarOperator.I));
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
|
|||
boolean atStartOfVc = curLocus.getStart() == vcLoc.getStart();
|
||||
boolean atEndOfVc = curLocus.getStart() == vcLoc.getStop();
|
||||
|
||||
if (vc.getType() == VariantContext.Type.MNP) {
|
||||
if (vc.isMNP()) {
|
||||
logger.debug("Observed MNP at " + vcLoc);
|
||||
|
||||
if (isChrM(vc)) {
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ public class PickSequenomProbes extends RodWalker<String, String> {
|
|||
String assay_sequence;
|
||||
if ( vc.isSNP() )
|
||||
assay_sequence = leading_bases + "[" + (char)ref.getBase() + "/" + vc.getAlternateAllele(0).toString() + "]" + trailing_bases;
|
||||
else if ( vc.getType() == VariantContext.Type.MNP )
|
||||
else if ( vc.isMNP() )
|
||||
assay_sequence = leading_bases + "[" + new String(vc.getReference().getBases()) + "/" + new String(vc.getAlternateAllele(0).getBases())+"]"+trailing_bases.substring(vc.getReference().length()-1);
|
||||
else if ( vc.isInsertion() )
|
||||
assay_sequence = leading_bases + (char)ref.getBase() + "[-/" + vc.getAlternateAllele(0).toString() + "]" + trailing_bases;
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
|
|||
observedRefAllele = Allele.create(Allele.NULL_ALLELE_STRING);
|
||||
}
|
||||
// deletions
|
||||
else if ( vc.isDeletion() || vc.isMixed() || vc.getType() == VariantContext.Type.MNP ) {
|
||||
else if ( vc.isDeletion() || vc.isMixed() || vc.isMNP() ) {
|
||||
// we can't validate arbitrarily long deletions
|
||||
if ( reportedRefAllele.length() > 100 ) {
|
||||
logger.info(String.format("Reference allele is too long (%d) at position %s:%d; skipping that record.", reportedRefAllele.length(), vc.getChr(), vc.getStart()));
|
||||
|
|
@ -123,7 +123,7 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
|
|||
// deletions are associated with the (position of) the last (preceding) non-deleted base;
|
||||
// hence to get actually deleted bases we need offset = 1
|
||||
int offset = 1 ;
|
||||
if ( vc.getType() == VariantContext.Type.MNP ) offset = 0; // if it's an MNP, the reported position IS the first modified base
|
||||
if ( vc.isMNP() ) offset = 0; // if it's an MNP, the reported position IS the first modified base
|
||||
byte[] refBytes = ref.getBases();
|
||||
byte[] trueRef = new byte[reportedRefAllele.length()];
|
||||
for (int i = 0; i < reportedRefAllele.length(); i++)
|
||||
|
|
|
|||
|
|
@ -566,10 +566,21 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
|||
return getType() == Type.INDEL && getAlternateAllele(0).isNull();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the alleles indicate neither a simple deletion nor a simple insertion
|
||||
*/
|
||||
public boolean isComplexIndel() {
|
||||
return isIndel() && !isDeletion() && !isInsertion();
|
||||
}
|
||||
|
||||
public boolean isSymbolic() {
|
||||
return getType() == Type.SYMBOLIC;
|
||||
}
|
||||
|
||||
public boolean isMNP() {
|
||||
return getType() == Type.MNP;
|
||||
}
|
||||
|
||||
/**
|
||||
* convenience method for indels
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue