Slightly modifying the way to use the IUPAC ambiguity codes in the FastaAlternateReferenceMaker.

Previously it required you to create a single sample VCF and then to pass that in to the tool, but
Geraldine convinced me that this was a pain for users (because they usually have multi-sample VCFs).
Instead now you can pass in a multi-sample VCF and specify which sample's genotypes should be used
for the IUPAC encoding.  Therefore the argument changed from '--useIUPAC' to '--use_IUPAC_sample NA12878'.
This commit is contained in:
Eric Banks 2014-04-02 21:34:25 -04:00
parent 6bba8d7147
commit 0b73573abc
2 changed files with 8 additions and 10 deletions

View File

@ -90,7 +90,7 @@ public class FastaAlternateReferenceIntegrationTest extends WalkerTest {
// cannot use 'expectedExceptions = UserException.BadInput.class' because it technically gets thrown as a RuntimeException by the engine
try {
WalkerTestSpec spec = new WalkerTestSpec(
"-T FastaAlternateReferenceMaker -R " + b36KGReference + " --useIUPAC -V " + GATKDataLocation + "dbsnp_129_b36.vcf -L 1:10,023,400-10,023,500 -L 1:10,029,200-10,029,500 -o %s",
"-T FastaAlternateReferenceMaker -R " + b37KGReference + " --use_IUPAC_sample NAXXXXX -V " + privateTestDir + "NA12878.WGS.b37.chr20.firstMB.vcf -L 20:61050-66380 -o %s",
1,
Arrays.asList("FAILFAILFAILFAILFAILFAILFAILFAIL"));
executeTest("test bad input", spec);
@ -101,7 +101,7 @@ public class FastaAlternateReferenceIntegrationTest extends WalkerTest {
public void testIupac() {
WalkerTestSpec spec = new WalkerTestSpec(
"-T FastaAlternateReferenceMaker -R " + b37KGReference + " --useIUPAC -V " + privateTestDir + "NA12878.WGS.b37.chr20.firstMB.vcf -L 20:61050-66380 -o %s",
"-T FastaAlternateReferenceMaker -R " + b37KGReference + " --use_IUPAC_sample NA12878 -V " + privateTestDir + "NA12878.WGS.b37.chr20.firstMB.vcf -L 20:61050-66380 -o %s",
1,
Arrays.asList("5feb2a576ff2ed1745a007eaa36448b3"));
executeTest("test iupac", spec);

View File

@ -109,11 +109,10 @@ public class FastaAlternateReferenceMaker extends FastaReferenceMaker {
protected RodBinding<VariantContext> snpmask;
/**
* This option works only for VCFs with genotypes for exactly one sample; anything else will generate an error.
* This option will generate an error if the specified sample does not exist in the VCF.
* Non-diploid (or non-called) genotypes are ignored.
*/
@Argument(fullName="useIUPAC", shortName="useIUPAC", doc = "If specified, heterozygous SNP sites will be output using IUPAC codes", required=false)
protected boolean useIUPACcodes = false;
@Argument(fullName="use_IUPAC_sample", shortName="IUPAC", doc = "If specified, heterozygous SNP sites will be output using IUPAC ambiguity codes given the genotypes for this sample", required=false)
private String iupacSample = null;
private int deletionBasesRemaining = 0;
@ -121,12 +120,11 @@ public class FastaAlternateReferenceMaker extends FastaReferenceMaker {
@Override
public void initialize() {
super.initialize();
if ( useIUPACcodes ) {
if ( iupacSample != null ) {
final List<String> rodName = Arrays.asList(variantCollection.variants.getName());
final Set<String> samples = SampleUtils.getUniqueSamplesFromRods(getToolkit(), rodName);
if ( samples.size() != 1 )
throw new UserException.BadInput("the --useIUPAC option works only on VCF files with genotypes for exactly one sample, but the input file has " + samples.size() + " samples");
iupacSample = samples.iterator().next();
if ( !samples.contains(iupacSample) )
throw new UserException.BadInput("the IUPAC sample specified is not present in the provided VCF file");
}
}
@ -152,7 +150,7 @@ public class FastaAlternateReferenceMaker extends FastaReferenceMaker {
} else if ( vc.isSimpleInsertion()) {
return new Pair<>(context.getLocation(), vc.getAlternateAllele(0).toString());
} else if (vc.isSNP()) {
final String base = useIUPACcodes ? getIUPACbase(vc.getGenotype(iupacSample), refBase) : vc.getAlternateAllele(0).toString();
final String base = (iupacSample != null) ? getIUPACbase(vc.getGenotype(iupacSample), refBase) : vc.getAlternateAllele(0).toString();
return new Pair<>(context.getLocation(), base);
}
}