Merged bug fix from Stable into Unstable

This commit is contained in:
Eric Banks 2011-06-29 15:54:38 -04:00
commit 0b622e8d67
5 changed files with 20 additions and 9 deletions

View File

@ -798,11 +798,11 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
private void generateAlternateConsensesFromKnownIndels(final Set<Consensus> altConsensesToPopulate, final int leftmostIndex, final byte[] reference) { private void generateAlternateConsensesFromKnownIndels(final Set<Consensus> altConsensesToPopulate, final int leftmostIndex, final byte[] reference) {
for ( VariantContext knownIndel : knownIndelsToTry ) { for ( VariantContext knownIndel : knownIndelsToTry ) {
if ( knownIndel == null || !knownIndel.isIndel() ) if ( knownIndel == null || !knownIndel.isIndel() || knownIndel.isComplexIndel() )
continue; continue;
byte[] indelStr = knownIndel.isInsertion() ? knownIndel.getAlternateAllele(0).getBases() : Utils.dupBytes((byte)'-', knownIndel.getReference().length()); byte[] indelStr = knownIndel.isInsertion() ? knownIndel.getAlternateAllele(0).getBases() : Utils.dupBytes((byte)'-', knownIndel.getReference().length());
int start = knownIndel.getStart() - leftmostIndex + 1; int start = knownIndel.getStart() - leftmostIndex + 1;
Consensus c = createAlternateConsensus(start, reference, indelStr, knownIndel.isDeletion()); Consensus c = createAlternateConsensus(start, reference, indelStr, knownIndel);
if ( c != null ) if ( c != null )
altConsensesToPopulate.add(c); 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 // 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 ) if ( indexOnRef < 0 || indexOnRef >= reference.length )
return null; return null;
@ -1002,11 +1002,11 @@ public class IndelRealigner extends ReadWalker<Integer, Integer> {
if ( indexOnRef > 0 ) if ( indexOnRef > 0 )
cigar.add(new CigarElement(indexOnRef, CigarOperator.M)); cigar.add(new CigarElement(indexOnRef, CigarOperator.M));
if ( isDeletion ) { if ( indel.isDeletion() ) {
refIdx += indelStr.length; refIdx += indelStr.length;
cigar.add(new CigarElement(indelStr.length, CigarOperator.D)); cigar.add(new CigarElement(indelStr.length, CigarOperator.D));
} }
else { else if ( indel.isInsertion() ) {
for ( byte b : indelStr ) for ( byte b : indelStr )
sb.append((char)b); sb.append((char)b);
cigar.add(new CigarElement(indelStr.length, CigarOperator.I)); cigar.add(new CigarElement(indelStr.length, CigarOperator.I));

View File

@ -161,7 +161,7 @@ public class AnnotateMNPsWalker extends RodWalker<Integer, Integer> {
boolean atStartOfVc = curLocus.getStart() == vcLoc.getStart(); boolean atStartOfVc = curLocus.getStart() == vcLoc.getStart();
boolean atEndOfVc = curLocus.getStart() == vcLoc.getStop(); boolean atEndOfVc = curLocus.getStart() == vcLoc.getStop();
if (vc.getType() == VariantContext.Type.MNP) { if (vc.isMNP()) {
logger.debug("Observed MNP at " + vcLoc); logger.debug("Observed MNP at " + vcLoc);
if (isChrM(vc)) { if (isChrM(vc)) {

View File

@ -209,7 +209,7 @@ public class PickSequenomProbes extends RodWalker<String, String> {
String assay_sequence; String assay_sequence;
if ( vc.isSNP() ) if ( vc.isSNP() )
assay_sequence = leading_bases + "[" + (char)ref.getBase() + "/" + vc.getAlternateAllele(0).toString() + "]" + trailing_bases; 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); 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() ) else if ( vc.isInsertion() )
assay_sequence = leading_bases + (char)ref.getBase() + "[-/" + vc.getAlternateAllele(0).toString() + "]" + trailing_bases; assay_sequence = leading_bases + (char)ref.getBase() + "[-/" + vc.getAlternateAllele(0).toString() + "]" + trailing_bases;

View File

@ -113,7 +113,7 @@ public class ValidateVariants extends RodWalker<Integer, Integer> {
observedRefAllele = Allele.create(Allele.NULL_ALLELE_STRING); observedRefAllele = Allele.create(Allele.NULL_ALLELE_STRING);
} }
// deletions // 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 // we can't validate arbitrarily long deletions
if ( reportedRefAllele.length() > 100 ) { 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())); 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; // deletions are associated with the (position of) the last (preceding) non-deleted base;
// hence to get actually deleted bases we need offset = 1 // hence to get actually deleted bases we need offset = 1
int 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[] refBytes = ref.getBases();
byte[] trueRef = new byte[reportedRefAllele.length()]; byte[] trueRef = new byte[reportedRefAllele.length()];
for (int i = 0; i < reportedRefAllele.length(); i++) for (int i = 0; i < reportedRefAllele.length(); i++)

View File

@ -566,10 +566,21 @@ public class VariantContext implements Feature { // to enable tribble intergrati
return getType() == Type.INDEL && getAlternateAllele(0).isNull(); 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() { public boolean isSymbolic() {
return getType() == Type.SYMBOLIC; return getType() == Type.SYMBOLIC;
} }
public boolean isMNP() {
return getType() == Type.MNP;
}
/** /**
* convenience method for indels * convenience method for indels
* *