Added else clause to handle symbolic alleles
Add test for createAlleleMapping
This commit is contained in:
parent
29ebfc32c3
commit
697c4b0cf1
|
|
@ -223,4 +223,18 @@ public class CombineVariantsIntegrationTest extends WalkerTest {
|
||||||
executeTest("combiningGVCFsFails", spec);
|
executeTest("combiningGVCFsFails", spec);
|
||||||
} catch (Exception e) { } // do nothing
|
} catch (Exception e) { } // do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void combineSymbolicVariants() {
|
||||||
|
// Just checking that this does not fail, hence no output files and MD5
|
||||||
|
WalkerTestSpec spec = new WalkerTestSpec(
|
||||||
|
"-T CombineVariants --no_cmdline_in_header -o %s "
|
||||||
|
+ " -R " + hg19RefereneWithChrPrefixInChromosomeNames
|
||||||
|
+ " -V " + privateTestDir + "WES-chr1.DEL.vcf"
|
||||||
|
+ " -V " + privateTestDir + "WGS-chr1.DEL.vcf"
|
||||||
|
+ " -genotypeMergeOptions UNIQUIFY",
|
||||||
|
0,
|
||||||
|
Arrays.asList(""));
|
||||||
|
executeTest("combineSymbolicVariants: ", spec);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -393,7 +393,7 @@ public class GATKVariantContextUtils {
|
||||||
if (repetitionCount[0] == 0 || repetitionCount[1] == 0)
|
if (repetitionCount[0] == 0 || repetitionCount[1] == 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (lengths.size() == 0) {
|
if (lengths.isEmpty()) {
|
||||||
lengths.add(repetitionCount[0]); // add ref allele length only once
|
lengths.add(repetitionCount[0]); // add ref allele length only once
|
||||||
}
|
}
|
||||||
lengths.add(repetitionCount[1]); // add this alt allele's length
|
lengths.add(repetitionCount[1]); // add this alt allele's length
|
||||||
|
|
@ -947,7 +947,7 @@ public class GATKVariantContextUtils {
|
||||||
final String setKey,
|
final String setKey,
|
||||||
final boolean filteredAreUncalled,
|
final boolean filteredAreUncalled,
|
||||||
final boolean mergeInfoWithMaxAC ) {
|
final boolean mergeInfoWithMaxAC ) {
|
||||||
if ( unsortedVCs == null || unsortedVCs.size() == 0 )
|
if ( unsortedVCs == null || unsortedVCs.isEmpty() )
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (priorityListOfVCs != null && originalNumOfVCs != priorityListOfVCs.size())
|
if (priorityListOfVCs != null && originalNumOfVCs != priorityListOfVCs.size())
|
||||||
|
|
@ -965,7 +965,7 @@ public class GATKVariantContextUtils {
|
||||||
VCs.add(vc);
|
VCs.add(vc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( VCs.size() == 0 ) // everything is filtered out and we're filteredAreUncalled
|
if ( VCs.isEmpty() ) // everything is filtered out and we're filteredAreUncalled
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
// establish the baseline info from the first VC
|
// establish the baseline info from the first VC
|
||||||
|
|
@ -1289,7 +1289,7 @@ public class GATKVariantContextUtils {
|
||||||
* @param currentAlleles the list of alleles already created
|
* @param currentAlleles the list of alleles already created
|
||||||
* @return a non-null mapping of original alleles to new (extended) ones
|
* @return a non-null mapping of original alleles to new (extended) ones
|
||||||
*/
|
*/
|
||||||
private static Map<Allele, Allele> createAlleleMapping(final Allele refAllele,
|
protected static Map<Allele, Allele> createAlleleMapping(final Allele refAllele,
|
||||||
final VariantContext oneVC,
|
final VariantContext oneVC,
|
||||||
final Collection<Allele> currentAlleles) {
|
final Collection<Allele> currentAlleles) {
|
||||||
final Allele myRef = oneVC.getReference();
|
final Allele myRef = oneVC.getReference();
|
||||||
|
|
@ -1305,6 +1305,8 @@ public class GATKVariantContextUtils {
|
||||||
if ( extended.equals(b) )
|
if ( extended.equals(b) )
|
||||||
extended = b;
|
extended = b;
|
||||||
map.put(a, extended);
|
map.put(a, extended);
|
||||||
|
} else if ( a.isSymbolic() ) {
|
||||||
|
map.put(a, a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1696,7 +1698,7 @@ public class GATKVariantContextUtils {
|
||||||
// otherVC has a type different than vc and its alleles are a subset of vc: remove otherVC from its list and add it to vc's type list
|
// otherVC has a type different than vc and its alleles are a subset of vc: remove otherVC from its list and add it to vc's type list
|
||||||
vcList.remove(k);
|
vcList.remove(k);
|
||||||
// avoid having empty lists
|
// avoid having empty lists
|
||||||
if (vcList.size() == 0)
|
if (vcList.isEmpty())
|
||||||
mappedVCs.remove(type);
|
mappedVCs.remove(type);
|
||||||
if ( !mappedVCs.containsKey(vcType) )
|
if ( !mappedVCs.containsKey(vcType) )
|
||||||
mappedVCs.put(vcType, new ArrayList<VariantContext>());
|
mappedVCs.put(vcType, new ArrayList<VariantContext>());
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ public class GATKVariantContextUtilsUnitTest extends BaseTest {
|
||||||
Allele ATref;
|
Allele ATref;
|
||||||
Allele Anoref;
|
Allele Anoref;
|
||||||
Allele GT;
|
Allele GT;
|
||||||
|
Allele Symbolic;
|
||||||
|
|
||||||
private GenomeLocParser genomeLocParser;
|
private GenomeLocParser genomeLocParser;
|
||||||
|
|
||||||
|
|
@ -63,6 +64,7 @@ public class GATKVariantContextUtilsUnitTest extends BaseTest {
|
||||||
ATref = Allele.create("AT",true);
|
ATref = Allele.create("AT",true);
|
||||||
Anoref = Allele.create("A",false);
|
Anoref = Allele.create("A",false);
|
||||||
GT = Allele.create("GT",false);
|
GT = Allele.create("GT",false);
|
||||||
|
Symbolic = Allele.create("<Symbolic>", false);
|
||||||
genomeLocParser = new GenomeLocParser(new CachingIndexedFastaSequenceFile(new File(hg18Reference)));
|
genomeLocParser = new GenomeLocParser(new CachingIndexedFastaSequenceFile(new File(hg18Reference)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1607,5 +1609,25 @@ public class GATKVariantContextUtilsUnitTest extends BaseTest {
|
||||||
BaseUtils.fillWithRandomBases(bases, 1, bases.length);
|
BaseUtils.fillWithRandomBases(bases, 1, bases.length);
|
||||||
return bases;
|
return bases;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateAlleleMapping(){
|
||||||
|
final List<Allele> alleles = Arrays.asList(Aref,Symbolic,T);
|
||||||
|
final VariantContext vc = new VariantContextBuilder().chr("chr1").alleles(alleles).make();
|
||||||
|
Map<Allele, Allele> map = GATKVariantContextUtils.createAlleleMapping(ATref, vc, alleles);
|
||||||
|
|
||||||
|
final List<Allele> expectedAlleles = Arrays.asList(Allele.create("<Symbolic>", false), Allele.create("TT", false));
|
||||||
|
for ( int i = 0; i < vc.getAlternateAlleles().size(); i++ ){
|
||||||
|
Assert.assertEquals(map.get(vc.getAlternateAlleles().get(i)), expectedAlleles.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test(expectedExceptions = IllegalStateException.class)
|
||||||
|
public void testCreateAlleleMappingException(){
|
||||||
|
final List<Allele> alleles = Arrays.asList(Aref, Symbolic, T);
|
||||||
|
final VariantContext vc = new VariantContextBuilder().chr("chr1").alleles(alleles).make();
|
||||||
|
// Throws an exception if the ref allele length <= ref allele length to extend
|
||||||
|
Map<Allele, Allele> map = GATKVariantContextUtils.createAlleleMapping(Aref, vc, alleles);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue