Merge branch 'master' of ssh://nickel.broadinstitute.org/humgen/gsa-scr1/gsa-engineering/git/unstable

This commit is contained in:
Ryan Poplin 2012-05-10 13:09:10 -04:00
commit c9dd0f3173
4 changed files with 36 additions and 8 deletions

View File

@ -21,7 +21,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* Variant confidence (given as (AB+BB)/AA from the PLs) / unfiltered depth. * Variant confidence (from the QUAL field) / unfiltered depth.
* *
* Low scores are indicative of false positive calls and artifacts. Note that QualByDepth requires sequencing * Low scores are indicative of false positive calls and artifacts. Note that QualByDepth requires sequencing
* reads associated with the samples with polymorphic genotypes. * reads associated with the samples with polymorphic genotypes.
@ -100,4 +100,4 @@ public class QualByDepth extends InfoFieldAnnotation implements StandardAnnotati
return map; return map;
} }
} }

View File

@ -253,14 +253,14 @@ public class ConsensusAlleleCounter {
stop = loc.getStart() + dLen; stop = loc.getStart() + dLen;
final byte[] refBases = Arrays.copyOfRange(ref.getBases(), startIdxInReference, startIdxInReference + dLen); final byte[] refBases = Arrays.copyOfRange(ref.getBases(), startIdxInReference, startIdxInReference + dLen);
if (Allele.acceptableAlleleBases(refBases)) { if (Allele.acceptableAlleleBases(refBases, false)) {
refAllele = Allele.create(refBases, true); refAllele = Allele.create(refBases, true);
altAllele = Allele.create(Allele.NULL_ALLELE_STRING, false); altAllele = Allele.create(Allele.NULL_ALLELE_STRING, false);
} }
else continue; // don't go on with this allele if refBases are non-standard else continue; // don't go on with this allele if refBases are non-standard
} else { } else {
// insertion case // insertion case
if (Allele.acceptableAlleleBases(s)) { if (Allele.acceptableAlleleBases(s, false)) { // don't allow N's in insertions
refAllele = Allele.create(Allele.NULL_ALLELE_STRING, true); refAllele = Allele.create(Allele.NULL_ALLELE_STRING, true);
altAllele = Allele.create(s, false); altAllele = Allele.create(s, false);
stop = loc.getStart(); stop = loc.getStart();

View File

@ -226,7 +226,11 @@ public class Allele implements Comparable<Allele> {
* @return true if the bases represent the well formatted allele * @return true if the bases represent the well formatted allele
*/ */
public static boolean acceptableAlleleBases(String bases) { public static boolean acceptableAlleleBases(String bases) {
return acceptableAlleleBases(bases.getBytes()); return acceptableAlleleBases(bases.getBytes(), true);
}
public static boolean acceptableAlleleBases(String bases, boolean allowNsAsAcceptable) {
return acceptableAlleleBases(bases.getBytes(), allowNsAsAcceptable);
} }
/** /**
@ -234,13 +238,22 @@ public class Allele implements Comparable<Allele> {
* @return true if the bases represent the well formatted allele * @return true if the bases represent the well formatted allele
*/ */
public static boolean acceptableAlleleBases(byte[] bases) { public static boolean acceptableAlleleBases(byte[] bases) {
return acceptableAlleleBases(bases, true); // default: N bases are acceptable
}
public static boolean acceptableAlleleBases(byte[] bases, boolean allowNsAsAcceptable) {
if ( wouldBeNullAllele(bases) || wouldBeNoCallAllele(bases) || wouldBeSymbolicAllele(bases) ) if ( wouldBeNullAllele(bases) || wouldBeNoCallAllele(bases) || wouldBeSymbolicAllele(bases) )
return true; return true;
for ( int i = 0; i < bases.length; i++ ) { for (byte base : bases ) {
switch (bases[i]) { switch (base) {
case 'A': case 'C': case 'G': case 'T': case 'N' : case 'a': case 'c': case 'g': case 't': case 'n' : case 'A': case 'C': case 'G': case 'T': case 'a': case 'c': case 'g': case 't':
break; break;
case 'N' : case 'n' :
if (allowNsAsAcceptable)
break;
else
return false;
default: default:
return false; return false;
} }

View File

@ -90,6 +90,21 @@ public class IndelGenotypeLikelihoodsUnitTest extends BaseTest {
Assert.assertEquals(alleles.size(),2); Assert.assertEquals(alleles.size(),2);
alleles = getConsensusAlleles(eventLength,false,10,0.5001, altBases); alleles = getConsensusAlleles(eventLength,false,10,0.5001, altBases);
Assert.assertEquals(alleles.size(),0); Assert.assertEquals(alleles.size(),0);
// test N's in insertions
altBases = "CCTCNTGAGA";
eventLength = 4;
alleles = getConsensusAlleles(eventLength,true,10,0.1, altBases);
Assert.assertEquals(alleles.size(),2);
Assert.assertEquals(alleles.get(1).getBaseString(), altBases.substring(0,eventLength));
altBases = "CCTCNTGAGA";
eventLength = 5;
alleles = getConsensusAlleles(eventLength,true,10,0.1, altBases);
Assert.assertEquals(alleles.size(),0);
} }
private List<Allele> getConsensusAlleles(int eventLength, boolean isInsertion, int minCnt, double minFraction, String altBases) { private List<Allele> getConsensusAlleles(int eventLength, boolean isInsertion, int minCnt, double minFraction, String altBases) {