More output consistency changes (updating wiki docs as I go along).

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4086 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2010-08-23 18:46:08 +00:00
parent c9c6ff49c2
commit ccda4f6ec1
5 changed files with 27 additions and 45 deletions

View File

@ -45,7 +45,6 @@ import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.util.*;
import java.io.PrintStream;
/**
@ -56,8 +55,9 @@ import java.io.PrintStream;
@Reference(window=@Window(start=-50,stop=50))
@By(DataSource.REFERENCE)
public class VariantAnnotator extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Output(doc="File to which variants should be written",required=true)
protected VCFWriter vcfWriter = null;
@Argument(fullName="sampleName", shortName="sample", doc="The sample (NA-ID) corresponding to the variant input (for non-VCF input only)", required=false)
protected String sampleName = null;
@ -83,8 +83,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
@Argument(fullName = "NO_HEADER", shortName = "NO_HEADER", doc = "Don't output the usual VCF header tag with the command line. FOR DEBUGGING PURPOSES ONLY. This option is required in order to pass integration tests.", required = false)
protected Boolean NO_VCF_HEADER_LINE = false;
private VCFWriter vcfWriter;
private HashMap<String, String> nonVCFsampleName = new HashMap<String, String>();
private VariantAnnotatorEngine engine;
@ -94,19 +92,19 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
private void listAnnotationsAndExit() {
List<Class<? extends InfoFieldAnnotation>> infoAnnotationClasses = PackageUtils.getClassesImplementingInterface(InfoFieldAnnotation.class);
out.println("\nAvailable annotations for the VCF INFO field:");
System.out.println("\nAvailable annotations for the VCF INFO field:");
for (int i = 0; i < infoAnnotationClasses.size(); i++)
out.println("\t" + infoAnnotationClasses.get(i).getSimpleName());
out.println();
System.out.println("\t" + infoAnnotationClasses.get(i).getSimpleName());
System.out.println();
List<Class<? extends GenotypeAnnotation>> genotypeAnnotationClasses = PackageUtils.getClassesImplementingInterface(GenotypeAnnotation.class);
out.println("\nAvailable annotations for the VCF FORMAT field:");
System.out.println("\nAvailable annotations for the VCF FORMAT field:");
for (int i = 0; i < genotypeAnnotationClasses.size(); i++)
out.println("\t" + genotypeAnnotationClasses.get(i).getSimpleName());
out.println();
out.println("\nAvailable classes/groups of annotations:");
System.out.println("\t" + genotypeAnnotationClasses.get(i).getSimpleName());
System.out.println();
System.out.println("\nAvailable classes/groups of annotations:");
for ( Class c : PackageUtils.getInterfacesExtendingInterface(AnnotationType.class) )
out.println("\t" + c.getSimpleName());
out.println();
System.out.println("\t" + c.getSimpleName());
System.out.println();
System.exit(0);
}
@ -153,7 +151,6 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
hInfo.add(new VCFHeaderLine("VariantAnnotator", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\""));
}
vcfWriter = new StandardVCFWriter(out);
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
vcfWriter.writeHeader(vcfHeader);
@ -261,6 +258,5 @@ public class VariantAnnotator extends RodWalker<Integer, Integer> {
*/
public void onTraversalDone(Integer result) {
logger.info("Processed " + result + " loci.\n");
vcfWriter.close();
}
}

View File

@ -41,7 +41,6 @@ import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.utils.vcf.VCFUtils;
import java.util.*;
import java.io.PrintStream;
/**
@ -50,8 +49,9 @@ import java.io.PrintStream;
@Requires(value={},referenceMetaData=@RMD(name="variant", type=VariantContext.class))
@Reference(window=@Window(start=-50,stop=50))
public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
@Output
protected PrintStream out;
@Output(doc="File to which variants should be written",required=true)
protected VCFWriter writer = null;
@Argument(fullName="filterExpression", shortName="filter", doc="One or more expression used with INFO fields to filter (see wiki docs for more info)", required=false)
protected ArrayList<String> FILTER_EXPS = new ArrayList<String>();
@ -78,9 +78,6 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
List<VariantContextUtils.JexlVCMatchExp> filterExps;
List<VariantContextUtils.JexlVCMatchExp> genotypeFilterExps;
private VCFWriter writer = null;
public static final String CLUSTERED_SNP_FILTER_NAME = "SnpCluster";
private ClusteredSnps clusteredSNPs = null;
@ -120,7 +117,6 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
hInfo.add(new VCFHeaderLine("VariantFiltration", "\"" + CommandLineUtils.createApproximateCommandLineArgumentString(getToolkit(), args, getClass()) + "\""));
}
writer = new StandardVCFWriter(out);
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(vc.getSampleNames())));
}
@ -249,8 +245,5 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
variantContextWindow.moveWindow(null);
filter();
}
if ( writer != null )
writer.close();
}
}

View File

@ -48,11 +48,12 @@ import java.io.FileNotFoundException;
@Reference(window=@Window(start=-20,stop=20))
@By(DataSource.REFERENCE)
public class UnifiedGenotyper extends LocusWalker<VariantCallContext, UnifiedGenotyper.UGStatistics> implements TreeReducible<UnifiedGenotyper.UGStatistics> {
@ArgumentCollection private UnifiedArgumentCollection UAC = new UnifiedArgumentCollection();
// control the output
@Output(doc="File to which variants should be written",required=false)
public VCFWriter writer = null;
@Output(doc="File to which variants should be written",required=true)
protected VCFWriter writer = null;
@Argument(fullName="variants_out",shortName="varout",doc="Please use --out instead",required=false)
@Deprecated

View File

@ -26,9 +26,7 @@
package org.broadinstitute.sting.playground.gatk.walkers.annotator;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -43,7 +41,6 @@ import java.util.TreeSet;
import java.util.Map.Entry;
import org.broad.tribble.util.variantcontext.VariantContext;
import org.broad.tribble.vcf.StandardVCFWriter;
import org.broad.tribble.vcf.VCFHeader;
import org.broad.tribble.vcf.VCFHeaderLine;
import org.broad.tribble.vcf.VCFWriter;
@ -77,11 +74,13 @@ import org.broadinstitute.sting.utils.vcf.VCFUtils;
//@Reference(window=@Window(start=-50,stop=50))
@By(DataSource.REFERENCE)
public class GenomicAnnotator extends RodWalker<LinkedList<VariantContext>, LinkedList<VariantContext>> implements TreeReducible<LinkedList<VariantContext>> {
@Output
protected PrintStream out;
@Argument(fullName="vcfOutput", shortName="vcf", doc="VCF file to which all variants should be written with annotations", required=true)
protected File VCF_OUT;
@Output(doc="File to which variants should be written",required=true)
protected VCFWriter vcfWriter = null;
@Argument(fullName="vcfOutput", shortName="vcf", doc="Please use --out instead", required=false)
@Deprecated
protected String oldOutArg;
@Argument(fullName="sampleName", shortName="sample", doc="The sample (NA-ID) corresponding to the variant input (for non-VCF input only)", required=false)
protected String sampleName = null;
@ -95,9 +94,6 @@ public class GenomicAnnotator extends RodWalker<LinkedList<VariantContext>, Link
@Argument(fullName="oneToMany", shortName="m", doc="If more than one record from the same file matches a particular locus (for example, multiple dbSNP records with the same position), create multiple entries in the ouptut VCF file - one for each match. If a particular tabular file has J matches, and another tabular file has K matches for a given locus, then J*K output VCF records will be generated - one for each pair of K, J. If this flag is not provided, the multiple records are still generated, but they are stored in the INFO field of a single output VCF record, with their annotation keys differentiated by appending '_i' with i varying from 1 to K*J. ", required=false)
protected Boolean ONE_TO_MANY = false;
private VCFWriter vcfWriter;
private VariantAnnotatorEngine engine;
private boolean strict = true;
@ -246,7 +242,6 @@ public class GenomicAnnotator extends RodWalker<LinkedList<VariantContext>, Link
hInfo.add(new VCFHeaderLine("annotatorReference", getToolkit().getArguments().referenceFile.getName()));
hInfo.addAll(engine.getVCFAnnotationDescriptions());
vcfWriter = new StandardVCFWriter(VCF_OUT);
VCFHeader vcfHeader = new VCFHeader(hInfo, samples);
vcfWriter.writeHeader(vcfHeader);
}
@ -365,11 +360,8 @@ public class GenomicAnnotator extends RodWalker<LinkedList<VariantContext>, Link
final int counter = e.getValue();
//final float percent = 100 * counter /(float) totalOutputVCFRecords;
//out.printf(" %-6.1f%% (%d) annotated with %s.\n", percent, counter, bindingName );
out.printf(" %d annotated with %s.\n", counter, bindingName );
System.out.printf(" %d annotated with %s.\n", counter, bindingName );
}
vcfWriter.close();
}

View File

@ -18,7 +18,7 @@ public class GenomicAnnotatorIntegrationTest extends WalkerTest {
"-B variant,vcf,/humgen/gsa-hpprojects/GATK/data/Annotations/examples/CEU_hapmap_nogt_23_subset.vcf " +
"-B dbsnp,AnnotatorInputTable,/humgen/gsa-hpprojects/GATK/data/Annotations/dbsnp/b130/snp130-b36-only-the-SNPs.txt " +
"-m " + //generate many records from one input record if necessary
"-vcf %s " +
"-o %s " +
"-BTI variant",
1,
Arrays.asList(md5));
@ -32,7 +32,7 @@ public class GenomicAnnotatorIntegrationTest extends WalkerTest {
" -B variant,vcf,/humgen/gsa-hpprojects/GATK/data/Annotations/examples/CEU_hapmap_nogt_23_subset.vcf" +
" -B dbsnp,AnnotatorInputTable,/humgen/gsa-hpprojects/GATK/data/Annotations/dbsnp/b130/snp130-b36-only-the-SNPs.txt" +
" -m" + //generate many records from one input record if necessary
" -vcf %s" +
" -o %s" +
" -BTI variant" +
" -s dbsnp.name,dbsnp.refUCSC,dbsnp.strand,dbsnp.observed,dbsnp.avHet",
1,