Merge if both GT are phased

This commit is contained in:
Ron Levine 2015-06-26 13:12:55 -04:00
parent 5ea2aff379
commit 1a7e83fa50
3 changed files with 25 additions and 4 deletions

View File

@ -363,7 +363,7 @@ class PhasingUtils {
*
* @param gt1 genotype 1
* @param gt2 genotype 2
* @return true if genotypes have the same number of chromosomes, haplotype, number of attributes
* @return true if genotypes have the same number of chromosomes, haplotype, phased, number of attributes
* as chromosomes, and either genotype is homozygous, false otherwise
*/
static boolean alleleSegregationIsKnown(Genotype gt1, Genotype gt2) {
@ -371,6 +371,10 @@ class PhasingUtils {
if (gt1.getPloidy() != gt2.getPloidy())
return false;
// If gt1 or gt2 are not phased, then can not be merged.
if (!gt1.isPhased() || !gt2.isPhased())
return false;
// If gt1 or gt2 are homozygous, then could be merged.
if (gt1.isHom() || gt2.isHom())
return true;

View File

@ -81,6 +81,7 @@ public class PhasingUtilsUnitTest extends BaseTest {
private ReferenceSequenceFile referenceFile;
private Genotype genotype1;
private Genotype genotype2;
private Genotype genotype2unphased;
private String contig;
private List<Allele> alleleList1;
private List<Allele> alleleList2;
@ -93,8 +94,9 @@ public class PhasingUtilsUnitTest extends BaseTest {
genomeLocParser = new GenomeLocParser(referenceFile);
alleleList1 = Arrays.asList(Allele.create("T", true), Allele.create("C", false));
alleleList2 = Arrays.asList(Allele.create("G", true), Allele.create("A", false));
genotype1 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).attribute("PQ", 100.0).alleles(alleleList1).make();
genotype2 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-2", "10-1"}).attribute("PQ", 200.0).alleles(alleleList2).make();
genotype1 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-1", "10-2"}).attribute("PQ", 100.0).alleles(alleleList1).phased(true).make();
genotype2 = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-2", "10-1"}).attribute("PQ", 200.0).alleles(alleleList2).phased(true).make();
genotype2unphased = new GenotypeBuilder().name("sample").attribute("HP", new String[]{"10-2", "10-1"}).attribute("PQ", 200.0).alleles(alleleList2).phased(false).make();
contig = new String("1");
vc1 = new VariantContextBuilder().chr(contig).id("id1").source("TC").start(start).stop(start).alleles(alleleList1).genotypes(genotype1).make();
vc2 = new VariantContextBuilder().chr(contig).id("id2").source("GA").start(start+1).stop(start+1).alleles(alleleList2).genotypes(genotype2).make();
@ -184,6 +186,7 @@ public class PhasingUtilsUnitTest extends BaseTest {
@Test
public void TestAlleleSegregationIsKnown(){
Assert.assertTrue(PhasingUtils.alleleSegregationIsKnown(genotype1, genotype2));
Assert.assertFalse(PhasingUtils.alleleSegregationIsKnown(genotype1, genotype2unphased));
}
@Test

View File

@ -138,7 +138,21 @@ public class ReadBackedPhasingIntegrationTest extends WalkerTest {
+ " -L chr20:332341-802503",
1,
Arrays.asList("ac41d1aa9c9a67c07d894f485c29c574"));
executeTest("Use trio-phased VCF, adding read-backed phasing infomration in HP tag (as is now standard for RBP) [TEST SEVEN]", spec);
executeTest("Use trio-phased VCF, adding read-backed phasing information in HP tag (as is now standard for RBP) [TEST SEVEN]", spec);
}
@Test
public void testDoNotMergeUnphasedSNPs() {
WalkerTestSpec spec = new WalkerTestSpec(
"-T ReadBackedPhasing" +
" -R " + hg19Reference +
" -I " + privateTestDir + "S17C1-8.KRAS.bam" +
" --variant " + privateTestDir + "S17C1-8_bwa_mutect_filtered.vcf" +
" --phaseQualityThresh 20.0 -enableMergeToMNP -maxDistMNP 3 -L 12:25398281-25398284" +
" -o %s" +
" --no_cmdline_in_header",
1,
Arrays.asList("59ee67d657ee955477bca94d07014ac3"));
executeTest("Do not merge unphased SNPs", spec);
}
}