Merge pull request #145 from broadinstitute/eb_various_minor_fixes
Eb various minor fixes
This commit is contained in:
commit
56f4529ef3
|
|
@ -47,6 +47,7 @@
|
|||
package org.broadinstitute.sting.gatk.walkers.filters;
|
||||
|
||||
import org.broadinstitute.sting.WalkerTest;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
|
@ -106,6 +107,13 @@ public class VariantFiltrationIntegrationTest extends WalkerTest {
|
|||
executeTest("test filter sites not in mask", spec3);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIllegalFilterName() {
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
baseTestString() + " -filter 'DoC < 20 || FisherStrand > 20.0' -filterName 'foo < foo' --variant " + privateTestDir + "vcfexample2.vcf -L 1:10,020,000-10,021,000", 1,
|
||||
UserException.class);
|
||||
executeTest("test illegal filter name", spec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilter1() {
|
||||
|
|
|
|||
|
|
@ -242,6 +242,32 @@ public class SelectVariantsIntegrationTest extends WalkerTest {
|
|||
executeTest("testRemoveMLE--" + testFile, spec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeepOriginalAC() {
|
||||
String testFile = privateTestDir + "vcfexample.loseAlleleInSelection.vcf";
|
||||
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
"-T SelectVariants --keepOriginalAC -R " + b36KGReference + " -sn NA12892 --variant " + testFile + " -o %s --no_cmdline_in_header",
|
||||
1,
|
||||
Arrays.asList("ad7e8b25e431a3229a78cec063876559")
|
||||
);
|
||||
|
||||
executeTest("testKeepOriginalAC--" + testFile, spec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeepOriginalACAndENV() {
|
||||
String testFile = privateTestDir + "vcfexample.loseAlleleInSelection.vcf";
|
||||
|
||||
WalkerTestSpec spec = new WalkerTestSpec(
|
||||
"-T SelectVariants --keepOriginalAC -env -R " + b36KGReference + " -sn NA12892 --variant " + testFile + " -o %s --no_cmdline_in_header",
|
||||
1,
|
||||
Arrays.asList("e9b8292212545684cdb163423329ee7e")
|
||||
);
|
||||
|
||||
executeTest("testKeepOriginalACAndENV--" + testFile, spec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleRecordsAtOnePosition() {
|
||||
String testFile = privateTestDir + "selectVariants.onePosition.vcf";
|
||||
|
|
|
|||
|
|
@ -276,10 +276,10 @@ public class ArgumentMatch implements Iterable<ArgumentMatch> {
|
|||
* @return A collection of the string representation of these value.
|
||||
*/
|
||||
public List<ArgumentMatchValue> values() {
|
||||
List<ArgumentMatchValue> values = new ArrayList<ArgumentMatchValue>();
|
||||
for( ArgumentMatchSite site: sites.keySet() ) {
|
||||
if( sites.get(site) != null )
|
||||
values.addAll(sites.get(site));
|
||||
final List<ArgumentMatchValue> values = new ArrayList<ArgumentMatchValue>();
|
||||
for ( final List<ArgumentMatchValue> siteValue : sites.values() ) {
|
||||
if ( siteValue != null )
|
||||
values.addAll(siteValue);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -186,18 +186,22 @@ public class VariantFiltration extends RodWalker<Integer, Integer> {
|
|||
if ( clusterWindow > 0 )
|
||||
hInfo.add(new VCFFilterHeaderLine(CLUSTERED_SNP_FILTER_NAME, "SNPs found in clusters"));
|
||||
|
||||
for ( VariantContextUtils.JexlVCMatchExp exp : filterExps )
|
||||
hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString()));
|
||||
for ( VariantContextUtils.JexlVCMatchExp exp : genotypeFilterExps )
|
||||
hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString()));
|
||||
|
||||
if ( genotypeFilterExps.size() > 0 )
|
||||
hInfo.add(VCFStandardHeaderLines.getFormatLine(VCFConstants.GENOTYPE_FILTER_KEY));
|
||||
|
||||
if ( mask.isBound() ) {
|
||||
if (filterRecordsNotInMask)
|
||||
hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Doesn't overlap a user-input mask"));
|
||||
else hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Overlaps a user-input mask"));
|
||||
try {
|
||||
for ( VariantContextUtils.JexlVCMatchExp exp : filterExps )
|
||||
hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString()));
|
||||
for ( VariantContextUtils.JexlVCMatchExp exp : genotypeFilterExps )
|
||||
hInfo.add(new VCFFilterHeaderLine(exp.name, exp.exp.toString()));
|
||||
|
||||
if ( mask.isBound() ) {
|
||||
if (filterRecordsNotInMask)
|
||||
hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Doesn't overlap a user-input mask"));
|
||||
else hInfo.add(new VCFFilterHeaderLine(MASK_NAME, "Overlaps a user-input mask"));
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new UserException.BadInput(e.getMessage());
|
||||
}
|
||||
|
||||
writer.writeHeader(new VCFHeader(hInfo, SampleUtils.getUniqueSamplesFromRods(getToolkit(), inputNames)));
|
||||
|
|
|
|||
|
|
@ -406,8 +406,8 @@ public class SelectVariants extends RodWalker<Integer, Integer> implements TreeR
|
|||
headerLines.add(new VCFHeaderLine("source", "SelectVariants"));
|
||||
|
||||
if (KEEP_ORIGINAL_CHR_COUNTS) {
|
||||
headerLines.add(new VCFInfoHeaderLine("AC_Orig", 1, VCFHeaderLineType.Integer, "Original AC"));
|
||||
headerLines.add(new VCFInfoHeaderLine("AF_Orig", 1, VCFHeaderLineType.Float, "Original AF"));
|
||||
headerLines.add(new VCFInfoHeaderLine("AC_Orig", VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC"));
|
||||
headerLines.add(new VCFInfoHeaderLine("AF_Orig", VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF"));
|
||||
headerLines.add(new VCFInfoHeaderLine("AN_Orig", 1, VCFHeaderLineType.Integer, "Original AN"));
|
||||
}
|
||||
headerLines.addAll(Arrays.asList(ChromosomeCountConstants.descriptions));
|
||||
|
|
@ -670,7 +670,8 @@ public class SelectVariants extends RodWalker<Integer, Integer> implements TreeR
|
|||
GenotypesContext newGC = sub.getGenotypes();
|
||||
|
||||
// if we have fewer alternate alleles in the selected VC than in the original VC, we need to strip out the GL/PLs and AD (because they are no longer accurate)
|
||||
if ( vc.getAlleles().size() != sub.getAlleles().size() )
|
||||
final boolean lostAllelesInSelection = vc.getAlleles().size() != sub.getAlleles().size();
|
||||
if ( lostAllelesInSelection )
|
||||
newGC = GATKVariantContextUtils.stripPLsAndAD(sub.getGenotypes());
|
||||
|
||||
// if we have fewer samples in the selected VC than in the original VC, we need to strip out the MLE tags
|
||||
|
|
@ -697,15 +698,22 @@ public class SelectVariants extends RodWalker<Integer, Integer> implements TreeR
|
|||
|
||||
builder.genotypes(newGC);
|
||||
|
||||
addAnnotations(builder, sub);
|
||||
addAnnotations(builder, sub, lostAllelesInSelection);
|
||||
|
||||
return builder.make();
|
||||
}
|
||||
|
||||
private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC) {
|
||||
/*
|
||||
* Add annotations to the new VC
|
||||
*
|
||||
* @param builder the new VC to annotate
|
||||
* @param originalVC the original -- but post-selection -- VC
|
||||
* @param lostAllelesInSelection true if the original (pre-selection) VC has more alleles than the new one
|
||||
*/
|
||||
private void addAnnotations(final VariantContextBuilder builder, final VariantContext originalVC, final boolean lostAllelesInSelection) {
|
||||
if ( fullyDecode ) return; // TODO -- annotations are broken with fully decoded data
|
||||
|
||||
if (KEEP_ORIGINAL_CHR_COUNTS) {
|
||||
if ( KEEP_ORIGINAL_CHR_COUNTS && !lostAllelesInSelection ) {
|
||||
if ( originalVC.hasAttribute(VCFConstants.ALLELE_COUNT_KEY) )
|
||||
builder.attribute("AC_Orig", originalVC.getAttribute(VCFConstants.ALLELE_COUNT_KEY));
|
||||
if ( originalVC.hasAttribute(VCFConstants.ALLELE_FREQUENCY_KEY) )
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,3 +1,3 @@
|
|||
<ivy-module version="1.0">
|
||||
<info organisation="org.broadinstitute" module="variant" revision="1.85.1357" status="integration" />
|
||||
<info organisation="org.broadinstitute" module="variant" revision="1.88.1401" status="integration" />
|
||||
</ivy-module>
|
||||
Loading…
Reference in New Issue