Yet more argument consistency updates
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4089 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
3aedd0055e
commit
ef795825fd
|
|
@ -42,7 +42,6 @@ import org.broadinstitute.sting.utils.BaseUtils;
|
||||||
import org.broadinstitute.sting.utils.SampleUtils;
|
import org.broadinstitute.sting.utils.SampleUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts variants from other file formats to VCF format.
|
* Converts variants from other file formats to VCF format.
|
||||||
|
|
@ -50,17 +49,17 @@ import java.io.PrintStream;
|
||||||
@Requires(value={},referenceMetaData=@RMD(name=VariantsToVCF.INPUT_ROD_NAME, type=VariantContext.class))
|
@Requires(value={},referenceMetaData=@RMD(name=VariantsToVCF.INPUT_ROD_NAME, type=VariantContext.class))
|
||||||
@Reference(window=@Window(start=0,stop=40))
|
@Reference(window=@Window(start=0,stop=40))
|
||||||
public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
||||||
@Output
|
|
||||||
private PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter vcfwriter = null;
|
||||||
|
|
||||||
public static final String INPUT_ROD_NAME = "variant";
|
public static final String INPUT_ROD_NAME = "variant";
|
||||||
|
|
||||||
@Argument(fullName="sample", shortName="sample", doc="The sample name represented by the variant rod (for data like GELI with genotypes)", required=false)
|
@Argument(fullName="sample", shortName="sample", doc="The sample name represented by the variant rod (for data like GELI with genotypes)", required=false)
|
||||||
protected String sampleName = null;
|
protected String sampleName = null;
|
||||||
|
|
||||||
private VCFWriter vcfwriter = null;
|
|
||||||
|
|
||||||
private Set<String> allowedGenotypeFormatStrings = new HashSet<String>();
|
private Set<String> allowedGenotypeFormatStrings = new HashSet<String>();
|
||||||
|
private boolean wroteHeader = false;
|
||||||
|
|
||||||
// Don't allow mixed types for now
|
// Don't allow mixed types for now
|
||||||
private EnumSet<VariantContext.Type> ALLOWED_VARIANT_CONTEXT_TYPES = EnumSet.of(VariantContext.Type.SNP,
|
private EnumSet<VariantContext.Type> ALLOWED_VARIANT_CONTEXT_TYPES = EnumSet.of(VariantContext.Type.SNP,
|
||||||
|
|
@ -95,7 +94,9 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeRecord(VariantContext vc, RefMetaDataTracker tracker, byte ref) {
|
private void writeRecord(VariantContext vc, RefMetaDataTracker tracker, byte ref) {
|
||||||
if ( vcfwriter == null ) {
|
if ( !wroteHeader ) {
|
||||||
|
wroteHeader = true;
|
||||||
|
|
||||||
// setup the header fields
|
// setup the header fields
|
||||||
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
||||||
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
|
hInfo.addAll(VCFUtils.getHeaderFields(getToolkit()));
|
||||||
|
|
@ -129,7 +130,6 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vcfwriter = new StandardVCFWriter(out);
|
|
||||||
vcfwriter.writeHeader(new VCFHeader(hInfo, samples));
|
vcfwriter.writeHeader(new VCFHeader(hInfo, samples));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -145,8 +145,5 @@ public class VariantsToVCF extends RodWalker<Integer, Integer> {
|
||||||
return value + sum;
|
return value + sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTraversalDone(Integer sum) {
|
public void onTraversalDone(Integer sum) {}
|
||||||
if ( vcfwriter != null )
|
|
||||||
vcfwriter.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ import java.util.*;
|
||||||
@Reference(window=@Window(start=-50,stop=50))
|
@Reference(window=@Window(start=-50,stop=50))
|
||||||
public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
||||||
|
|
||||||
@Output(doc="File to which variants should be written",required=true)
|
@Output(doc="File to which variants should be written",required=false)
|
||||||
protected VCFWriter writer = null;
|
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)
|
@Argument(fullName="filterExpression", shortName="filter", doc="One or more expression used with INFO fields to filter (see wiki docs for more info)", required=false)
|
||||||
|
|
@ -85,7 +85,7 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
||||||
private FiltrationContextWindow variantContextWindow;
|
private FiltrationContextWindow variantContextWindow;
|
||||||
private static final int windowSize = 10; // 10 variants on either end of the current one
|
private static final int windowSize = 10; // 10 variants on either end of the current one
|
||||||
private ArrayList<FiltrationContext> windowInitializer = new ArrayList<FiltrationContext>();
|
private ArrayList<FiltrationContext> windowInitializer = new ArrayList<FiltrationContext>();
|
||||||
|
private boolean wroteHeader = false;
|
||||||
|
|
||||||
private void initializeVcfWriter(VariantContext vc) {
|
private void initializeVcfWriter(VariantContext vc) {
|
||||||
// setup the header fields
|
// setup the header fields
|
||||||
|
|
@ -220,8 +220,10 @@ public class VariantFiltrationWalker extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeVCF(VariantContext vc, byte ref) {
|
private void writeVCF(VariantContext vc, byte ref) {
|
||||||
if ( writer == null )
|
if ( !wroteHeader ) {
|
||||||
initializeVcfWriter(vc);
|
initializeVcfWriter(vc);
|
||||||
|
wroteHeader = true;
|
||||||
|
}
|
||||||
writer.add(vc, ref);
|
writer.add(vc, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ import org.broadinstitute.sting.commandline.Argument;
|
||||||
import org.broadinstitute.sting.commandline.Output;
|
import org.broadinstitute.sting.commandline.Output;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts Sequenom files to a VCF annotated with QC metrics (HW-equilibrium, % failed probes)
|
* Converts Sequenom files to a VCF annotated with QC metrics (HW-equilibrium, % failed probes)
|
||||||
|
|
@ -50,8 +49,9 @@ import java.io.PrintStream;
|
||||||
@Reference(window=@Window(start=0,stop=40))
|
@Reference(window=@Window(start=0,stop=40))
|
||||||
@Requires(value={},referenceMetaData=@RMD(name="sequenom",type= Feature.class))
|
@Requires(value={},referenceMetaData=@RMD(name="sequenom",type= Feature.class))
|
||||||
public class SequenomValidationConverter extends RodWalker<Pair<VariantContext, Byte>,Integer> {
|
public class SequenomValidationConverter extends RodWalker<Pair<VariantContext, Byte>,Integer> {
|
||||||
@Output
|
|
||||||
protected PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter vcfwriter = null;
|
||||||
|
|
||||||
@Argument(fullName="maxHardy", doc="Maximum phred-scaled Hardy-Weinberg violation pvalue to consider an assay valid [default:20]", required=false)
|
@Argument(fullName="maxHardy", doc="Maximum phred-scaled Hardy-Weinberg violation pvalue to consider an assay valid [default:20]", required=false)
|
||||||
protected double maxHardy = 20.0;
|
protected double maxHardy = 20.0;
|
||||||
|
|
@ -122,8 +122,6 @@ public class SequenomValidationConverter extends RodWalker<Pair<VariantContext,
|
||||||
if ( sampleNames == null )
|
if ( sampleNames == null )
|
||||||
sampleNames = new TreeSet<String>();
|
sampleNames = new TreeSet<String>();
|
||||||
|
|
||||||
VCFWriter vcfWriter = new StandardVCFWriter(out);
|
|
||||||
|
|
||||||
// set up the info and filter headers
|
// set up the info and filter headers
|
||||||
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
Set<VCFHeaderLine> hInfo = new HashSet<VCFHeaderLine>();
|
||||||
hInfo.add(new VCFHeaderLine("source", "SequenomValidationConverter"));
|
hInfo.add(new VCFHeaderLine("source", "SequenomValidationConverter"));
|
||||||
|
|
@ -161,11 +159,11 @@ public class SequenomValidationConverter extends RodWalker<Pair<VariantContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
VCFHeader header = new VCFHeader(hInfo, sampleNames);
|
VCFHeader header = new VCFHeader(hInfo, sampleNames);
|
||||||
vcfWriter.writeHeader(header);
|
vcfwriter.writeHeader(header);
|
||||||
|
|
||||||
for ( Pair<VariantContext, Byte> record : records )
|
for ( Pair<VariantContext, Byte> record : records )
|
||||||
vcfWriter.add(record.first, record.second);
|
vcfwriter.add(record.first, record.second);
|
||||||
vcfWriter.close();
|
vcfwriter.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,6 @@ import org.broadinstitute.sting.commandline.Output;
|
||||||
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Combines VCF records from different sources; supports both full merges and set unions.
|
* Combines VCF records from different sources; supports both full merges and set unions.
|
||||||
|
|
@ -54,8 +53,9 @@ import java.io.PrintStream;
|
||||||
@Reference(window=@Window(start=-50,stop=50))
|
@Reference(window=@Window(start=-50,stop=50))
|
||||||
@Requires(value={})
|
@Requires(value={})
|
||||||
public class CombineVariants extends RodWalker<Integer, Integer> {
|
public class CombineVariants extends RodWalker<Integer, Integer> {
|
||||||
@Output
|
|
||||||
private PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter vcfWriter = null;
|
||||||
|
|
||||||
// the types of combinations we currently allow
|
// the types of combinations we currently allow
|
||||||
@Argument(shortName="genotypeMergeOptions", doc="How should we merge genotype records for samples shared across the ROD files?", required=false)
|
@Argument(shortName="genotypeMergeOptions", doc="How should we merge genotype records for samples shared across the ROD files?", required=false)
|
||||||
|
|
@ -79,13 +79,11 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="setKey", shortName="setKey", doc="Key, by default set, in the INFO key=value tag emitted describing which set the combined VCF record came from. Set to null if you don't want the set field emitted.", required=false)
|
@Argument(fullName="setKey", shortName="setKey", doc="Key, by default set, in the INFO key=value tag emitted describing which set the combined VCF record came from. Set to null if you don't want the set field emitted.", required=false)
|
||||||
public String SET_KEY = "set";
|
public String SET_KEY = "set";
|
||||||
|
|
||||||
private VCFWriter vcfWriter = null;
|
|
||||||
private List<String> priority = null;
|
private List<String> priority = null;
|
||||||
|
|
||||||
private VariantAnnotatorEngine engine;
|
private VariantAnnotatorEngine engine;
|
||||||
|
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
vcfWriter = new StandardVCFWriter(out);
|
|
||||||
validateAnnotateUnionArguments();
|
validateAnnotateUnionArguments();
|
||||||
|
|
||||||
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), null);
|
Map<String, VCFHeader> vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), null);
|
||||||
|
|
@ -154,8 +152,5 @@ public class CombineVariants extends RodWalker<Integer, Integer> {
|
||||||
return counter + sum;
|
return counter + sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onTraversalDone(Integer sum) {
|
public void onTraversalDone(Integer sum) {}
|
||||||
if ( vcfWriter != null )
|
|
||||||
vcfWriter.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
package org.broadinstitute.sting.gatk.walkers.variantutils;
|
package org.broadinstitute.sting.gatk.walkers.variantutils;
|
||||||
|
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
import org.broad.tribble.vcf.StandardVCFWriter;
|
|
||||||
import org.broad.tribble.vcf.VCFWriter;
|
import org.broad.tribble.vcf.VCFWriter;
|
||||||
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
||||||
import org.broadinstitute.sting.utils.SampleUtils;
|
import org.broadinstitute.sting.utils.SampleUtils;
|
||||||
|
|
@ -37,17 +36,15 @@ import org.broadinstitute.sting.commandline.Output;
|
||||||
import org.broad.tribble.vcf.VCFHeader;
|
import org.broad.tribble.vcf.VCFHeader;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters a lifted-over VCF file for ref bases that have been changed.
|
* Filters a lifted-over VCF file for ref bases that have been changed.
|
||||||
*/
|
*/
|
||||||
@Requires(value={},referenceMetaData=@RMD(name="variant",type= VariantContext.class))
|
@Requires(value={},referenceMetaData=@RMD(name="variant",type= VariantContext.class))
|
||||||
public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
|
public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
|
||||||
@Output
|
|
||||||
PrintStream out;
|
|
||||||
|
|
||||||
private VCFWriter writer;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter writer = null;
|
||||||
|
|
||||||
private long failedLocs = 0, totalLocs = 0;
|
private long failedLocs = 0, totalLocs = 0;
|
||||||
|
|
||||||
|
|
@ -55,7 +52,6 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
|
||||||
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
|
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
|
||||||
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
|
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
|
||||||
|
|
||||||
writer = new StandardVCFWriter(out);
|
|
||||||
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
|
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
|
||||||
writer.writeHeader(vcfHeader);
|
writer.writeHeader(vcfHeader);
|
||||||
}
|
}
|
||||||
|
|
@ -89,7 +85,6 @@ public class FilterLiftedVariants extends RodWalker<Integer, Integer> {
|
||||||
public Integer reduce(Integer value, Integer sum) { return 0; }
|
public Integer reduce(Integer value, Integer sum) { return 0; }
|
||||||
|
|
||||||
public void onTraversalDone(Integer result) {
|
public void onTraversalDone(Integer result) {
|
||||||
writer.close();
|
|
||||||
System.out.println("Filtered " + failedLocs + " records out of " + totalLocs + " total records.");
|
System.out.println("Filtered " + failedLocs + " records out of " + totalLocs + " total records.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
package org.broadinstitute.sting.gatk.walkers.variantutils;
|
package org.broadinstitute.sting.gatk.walkers.variantutils;
|
||||||
|
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
import org.broad.tribble.vcf.StandardVCFWriter;
|
|
||||||
import org.broad.tribble.vcf.VCFWriter;
|
import org.broad.tribble.vcf.VCFWriter;
|
||||||
import org.broadinstitute.sting.commandline.Argument;
|
import org.broadinstitute.sting.commandline.Argument;
|
||||||
import org.broadinstitute.sting.commandline.Output;
|
import org.broadinstitute.sting.commandline.Output;
|
||||||
|
|
@ -40,7 +39,6 @@ import org.broadinstitute.sting.gatk.contexts.variantcontext.VariantContextUtils
|
||||||
import org.broad.tribble.vcf.VCFHeader;
|
import org.broad.tribble.vcf.VCFHeader;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import net.sf.picard.liftover.LiftOver;
|
import net.sf.picard.liftover.LiftOver;
|
||||||
|
|
@ -53,8 +51,9 @@ import net.sf.samtools.SAMFileReader;
|
||||||
*/
|
*/
|
||||||
@Requires(value={},referenceMetaData=@RMD(name="variant", type=VariantContext.class))
|
@Requires(value={},referenceMetaData=@RMD(name="variant", type=VariantContext.class))
|
||||||
public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
public class LiftoverVariants 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="chain", shortName="chain", doc="Chain file", required=true)
|
@Argument(fullName="chain", shortName="chain", doc="Chain file", required=true)
|
||||||
protected File CHAIN = null;
|
protected File CHAIN = null;
|
||||||
|
|
@ -62,8 +61,6 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
||||||
@Argument(fullName="newSequenceDictionary", shortName="dict", doc="Sequence .dict file for the new build", required=true)
|
@Argument(fullName="newSequenceDictionary", shortName="dict", doc="Sequence .dict file for the new build", required=true)
|
||||||
protected File NEW_SEQ_DICT = null;
|
protected File NEW_SEQ_DICT = null;
|
||||||
|
|
||||||
private VCFWriter writer;
|
|
||||||
|
|
||||||
private LiftOver liftOver;
|
private LiftOver liftOver;
|
||||||
|
|
||||||
private long successfulIntervals = 0, failedIntervals = 0;
|
private long successfulIntervals = 0, failedIntervals = 0;
|
||||||
|
|
@ -78,7 +75,6 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
||||||
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
|
Set<String> samples = SampleUtils.getSampleListWithVCFHeader(getToolkit(), Arrays.asList("variant"));
|
||||||
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
|
Map<String, VCFHeader> vcfHeaders = VCFUtils.getVCFHeadersFromRods(getToolkit(), Arrays.asList("variant"));
|
||||||
|
|
||||||
writer = new StandardVCFWriter(out);
|
|
||||||
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
|
final VCFHeader vcfHeader = new VCFHeader(vcfHeaders.containsKey("variant") ? vcfHeaders.get("variant").getMetaData() : null, samples);
|
||||||
writer.writeHeader(vcfHeader);
|
writer.writeHeader(vcfHeader);
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +109,6 @@ public class LiftoverVariants extends RodWalker<Integer, Integer> {
|
||||||
public Integer reduce(Integer value, Integer sum) { return 0; }
|
public Integer reduce(Integer value, Integer sum) { return 0; }
|
||||||
|
|
||||||
public void onTraversalDone(Integer result) {
|
public void onTraversalDone(Integer result) {
|
||||||
writer.close();
|
|
||||||
System.out.println("Converted " + successfulIntervals + " records; failed to convert " + failedIntervals + " records.");
|
System.out.println("Converted " + successfulIntervals + " records; failed to convert " + failedIntervals + " records.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,6 @@ package org.broadinstitute.sting.gatk.walkers.variantutils;
|
||||||
|
|
||||||
import org.broad.tribble.util.variantcontext.Genotype;
|
import org.broad.tribble.util.variantcontext.Genotype;
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
import org.broad.tribble.vcf.StandardVCFWriter;
|
|
||||||
import org.broad.tribble.vcf.VCFHeader;
|
import org.broad.tribble.vcf.VCFHeader;
|
||||||
import org.broad.tribble.vcf.VCFHeaderLine;
|
import org.broad.tribble.vcf.VCFHeaderLine;
|
||||||
import org.broad.tribble.vcf.VCFWriter;
|
import org.broad.tribble.vcf.VCFWriter;
|
||||||
|
|
@ -46,7 +45,6 @@ import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
|
@ -56,8 +54,9 @@ import java.io.FileNotFoundException;
|
||||||
*/
|
*/
|
||||||
@Requires(value={},referenceMetaData=@RMD(name="variant", type=VariantContext.class))
|
@Requires(value={},referenceMetaData=@RMD(name="variant", type=VariantContext.class))
|
||||||
public class SelectVariants extends RodWalker<Integer, Integer> {
|
public class SelectVariants extends RodWalker<Integer, Integer> {
|
||||||
@Output
|
|
||||||
private PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter vcfWriter = null;
|
||||||
|
|
||||||
@Argument(fullName="sample", shortName="sn", doc="Sample(s) to include. Can be a single sample, specified multiple times for many samples, a file containing sample names, a regular expression to select many samples, or any combination thereof.", required=false)
|
@Argument(fullName="sample", shortName="sn", doc="Sample(s) to include. Can be a single sample, specified multiple times for many samples, a file containing sample names, a regular expression to select many samples, or any combination thereof.", required=false)
|
||||||
public Set<String> SAMPLE_EXPRESSIONS;
|
public Set<String> SAMPLE_EXPRESSIONS;
|
||||||
|
|
@ -78,14 +77,10 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
|
||||||
private Set<String> possibleSampleRegexs = new HashSet<String>();
|
private Set<String> possibleSampleRegexs = new HashSet<String>();
|
||||||
private Set<String> sampleExpressionsThatDidNotWork = new HashSet<String>();
|
private Set<String> sampleExpressionsThatDidNotWork = new HashSet<String>();
|
||||||
|
|
||||||
private VCFWriter vcfWriter = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set up the VCF writer, the sample expressions and regexs, and the JEXL matcher
|
* Set up the VCF writer, the sample expressions and regexs, and the JEXL matcher
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
vcfWriter = new StandardVCFWriter(out);
|
|
||||||
|
|
||||||
ArrayList<String> rodNames = new ArrayList<String>();
|
ArrayList<String> rodNames = new ArrayList<String>();
|
||||||
rodNames.add("variant");
|
rodNames.add("variant");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -31,8 +30,10 @@ import java.util.*;
|
||||||
* @Date Apr 21, 2010
|
* @Date Apr 21, 2010
|
||||||
*/
|
*/
|
||||||
public class IndelAnnotator extends RodWalker<Integer,Long>{
|
public class IndelAnnotator extends RodWalker<Integer,Long>{
|
||||||
@Output
|
|
||||||
PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter vcfWriter = null;
|
||||||
|
|
||||||
@Argument(fullName="refseq", shortName="refseq",
|
@Argument(fullName="refseq", shortName="refseq",
|
||||||
doc="Name of RefSeq transcript annotation file. If specified, indels will be annotated with GENOMIC/UTR/INTRON/CODING and with the gene name", required=true)
|
doc="Name of RefSeq transcript annotation file. If specified, indels will be annotated with GENOMIC/UTR/INTRON/CODING and with the gene name", required=true)
|
||||||
String RefseqFileName = null;
|
String RefseqFileName = null;
|
||||||
|
|
@ -44,7 +45,6 @@ public class IndelAnnotator extends RodWalker<Integer,Long>{
|
||||||
private static String annUnknown = "UNKNOWN";
|
private static String annUnknown = "UNKNOWN";
|
||||||
|
|
||||||
private SeekableRODIterator refseqIterator;
|
private SeekableRODIterator refseqIterator;
|
||||||
private VCFWriter vcfWriter;
|
|
||||||
|
|
||||||
private String getAnnotationString(RODRecordList ann) {
|
private String getAnnotationString(RODRecordList ann) {
|
||||||
if ( ann == null ) return annGenomic;
|
if ( ann == null ) return annGenomic;
|
||||||
|
|
@ -88,7 +88,6 @@ public class IndelAnnotator extends RodWalker<Integer,Long>{
|
||||||
anno.add(new VCFInfoHeaderLine("type",1, VCFHeaderLineType.String,"Genomic interpretation (according to RefSeq)"));
|
anno.add(new VCFInfoHeaderLine("type",1, VCFHeaderLineType.String,"Genomic interpretation (according to RefSeq)"));
|
||||||
hInfo.addAll(anno);
|
hInfo.addAll(anno);
|
||||||
|
|
||||||
vcfWriter = new StandardVCFWriter(out);
|
|
||||||
VCFHeader vcfHeader = new VCFHeader(hInfo, SampleUtils.getUniqueSamplesFromRods(getToolkit()));
|
VCFHeader vcfHeader = new VCFHeader(hInfo, SampleUtils.getUniqueSamplesFromRods(getToolkit()));
|
||||||
vcfWriter.writeHeader(vcfHeader);
|
vcfWriter.writeHeader(vcfHeader);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,6 @@ import org.broadinstitute.sting.utils.SampleUtils;
|
||||||
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
import org.broadinstitute.sting.utils.vcf.VCFUtils;
|
||||||
import org.broad.tribble.vcf.*;
|
import org.broad.tribble.vcf.*;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import static java.lang.Math.log10;
|
import static java.lang.Math.log10;
|
||||||
|
|
||||||
|
|
@ -63,20 +62,18 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
|
||||||
public static final String PROBS_ROD_NAME = "beagleProbs";
|
public static final String PROBS_ROD_NAME = "beagleProbs";
|
||||||
public static final String PHASED_ROD_NAME = "beaglePhased";
|
public static final String PHASED_ROD_NAME = "beaglePhased";
|
||||||
|
|
||||||
@Output
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
private PrintStream out;
|
protected VCFWriter vcfWriter = null;
|
||||||
|
|
||||||
@Argument(fullName="output_file", shortName="output", doc="VCF file to which output should be written", required=true)
|
@Argument(fullName="output_file", shortName="output", doc="Please use --out instead")
|
||||||
private String OUTPUT_FILE = null;
|
@Deprecated
|
||||||
|
private String oldOutputArg;
|
||||||
|
|
||||||
@Argument(fullName="no" +
|
@Argument(fullName="no" +
|
||||||
"call_threshold", shortName="ncthr", doc="Threshold of confidence at which a genotype won't be called", required=false)
|
"call_threshold", shortName="ncthr", doc="Threshold of confidence at which a genotype won't be called", required=false)
|
||||||
private double noCallThreshold = 0.0;
|
private double noCallThreshold = 0.0;
|
||||||
|
|
||||||
protected static String line = null;
|
protected static String line = null;
|
||||||
private VCFWriter vcfWriter;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private final double MIN_PROB_ERROR = 0.000001;
|
private final double MIN_PROB_ERROR = 0.000001;
|
||||||
private final double MAX_GENOTYPE_QUALITY = 6.0;
|
private final double MAX_GENOTYPE_QUALITY = 6.0;
|
||||||
|
|
@ -94,7 +91,6 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
|
||||||
hInfo.add(new VCFHeaderLine("source", "BeagleImputation"));
|
hInfo.add(new VCFHeaderLine("source", "BeagleImputation"));
|
||||||
|
|
||||||
// Open output file specified by output VCF ROD
|
// Open output file specified by output VCF ROD
|
||||||
vcfWriter = new StandardVCFWriter(new File(OUTPUT_FILE));
|
|
||||||
final List<ReferenceOrderedDataSource> dataSources = this.getToolkit().getRodDataSources();
|
final List<ReferenceOrderedDataSource> dataSources = this.getToolkit().getRodDataSources();
|
||||||
|
|
||||||
for( final ReferenceOrderedDataSource source : dataSources ) {
|
for( final ReferenceOrderedDataSource source : dataSources ) {
|
||||||
|
|
@ -354,8 +350,6 @@ public class BeagleOutputToVCFWalker extends RodWalker<Integer, Integer> {
|
||||||
* @param result the number of loci seen.
|
* @param result the number of loci seen.
|
||||||
*/
|
*/
|
||||||
public void onTraversalDone(Integer result) {
|
public void onTraversalDone(Integer result) {
|
||||||
out.printf("Processed %d loci.\n", result);
|
System.out.printf("Processed %d loci.\n", result);
|
||||||
|
|
||||||
vcfWriter.close();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -55,8 +55,9 @@ import java.util.*;
|
||||||
@ReadFilters( {ZeroMappingQualityReadFilter.class} ) // Filter out all reads with zero mapping quality
|
@ReadFilters( {ZeroMappingQualityReadFilter.class} ) // Filter out all reads with zero mapping quality
|
||||||
|
|
||||||
public class ReadBackedPhasingWalker extends LocusWalker<PhasingStatsAndOutput, PhasingStats> {
|
public class ReadBackedPhasingWalker extends LocusWalker<PhasingStatsAndOutput, PhasingStats> {
|
||||||
@Output
|
|
||||||
protected PrintStream out;
|
@Output(doc="File to which variants should be written",required=true)
|
||||||
|
protected VCFWriter writer = null;
|
||||||
|
|
||||||
@Argument(fullName = "cacheWindowSize", shortName = "cacheWindow", doc = "The window size (in bases) to cache variant sites and their reads; [default:20000]", required = false)
|
@Argument(fullName = "cacheWindowSize", shortName = "cacheWindow", doc = "The window size (in bases) to cache variant sites and their reads; [default:20000]", required = false)
|
||||||
protected Integer cacheWindow = 20000;
|
protected Integer cacheWindow = 20000;
|
||||||
|
|
@ -67,13 +68,9 @@ public class ReadBackedPhasingWalker extends LocusWalker<PhasingStatsAndOutput,
|
||||||
@Argument(fullName = "phaseQualityThresh", shortName = "phaseThresh", doc = "The minimum phasing quality score required to output phasing; [default:4.77]", required = false)
|
@Argument(fullName = "phaseQualityThresh", shortName = "phaseThresh", doc = "The minimum phasing quality score required to output phasing; [default:4.77]", required = false)
|
||||||
protected Double phaseQualityThresh = 4.77; // PQ = 4.77 <=> P(error) = 10^(-4.77/10) = 0.33, P(correct) = 0.66, so that we have odds ratio of >= 2
|
protected Double phaseQualityThresh = 4.77; // PQ = 4.77 <=> P(error) = 10^(-4.77/10) = 0.33, P(correct) = 0.66, so that we have odds ratio of >= 2
|
||||||
|
|
||||||
@Argument(fullName = "phasedVCFFile", shortName = "phasedVCF", doc = "The name of the phased VCF file output", required = true)
|
|
||||||
protected String phasedVCFFile = null;
|
|
||||||
|
|
||||||
@Argument(fullName = "variantStatsFilePrefix", shortName = "variantStats", doc = "The prefix of the VCF/phasing statistics files", required = false)
|
@Argument(fullName = "variantStatsFilePrefix", shortName = "variantStats", doc = "The prefix of the VCF/phasing statistics files", required = false)
|
||||||
protected String variantStatsFilePrefix = null;
|
protected String variantStatsFilePrefix = null;
|
||||||
|
|
||||||
private VCFWriter writer = null;
|
|
||||||
private PhasingQualityStatsWriter statsWriter = null;
|
private PhasingQualityStatsWriter statsWriter = null;
|
||||||
|
|
||||||
private LinkedList<VariantAndReads> siteQueue = null;
|
private LinkedList<VariantAndReads> siteQueue = null;
|
||||||
|
|
@ -90,7 +87,6 @@ public class ReadBackedPhasingWalker extends LocusWalker<PhasingStatsAndOutput,
|
||||||
hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName()));
|
hInfo.add(new VCFHeaderLine("reference", getToolkit().getArguments().referenceFile.getName()));
|
||||||
hInfo.add(new VCFFormatHeaderLine("PQ", 1, VCFHeaderLineType.Float, "Read-backed phasing quality"));
|
hInfo.add(new VCFFormatHeaderLine("PQ", 1, VCFHeaderLineType.Float, "Read-backed phasing quality"));
|
||||||
|
|
||||||
writer = new StandardVCFWriter(new File(phasedVCFFile));
|
|
||||||
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(vc.getSampleNames())));
|
writer.writeHeader(new VCFHeader(hInfo, new TreeSet<String>(vc.getSampleNames())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,21 +400,19 @@ public class ReadBackedPhasingWalker extends LocusWalker<PhasingStatsAndOutput,
|
||||||
public void onTraversalDone(PhasingStats result) {
|
public void onTraversalDone(PhasingStats result) {
|
||||||
List<VariantContext> finalList = processQueue(null, result);
|
List<VariantContext> finalList = processQueue(null, result);
|
||||||
writeVarContList(finalList);
|
writeVarContList(finalList);
|
||||||
if (writer != null)
|
|
||||||
writer.close();
|
|
||||||
if (statsWriter != null)
|
if (statsWriter != null)
|
||||||
statsWriter.close();
|
statsWriter.close();
|
||||||
|
|
||||||
out.println("Number of reads observed: " + result.getNumReads());
|
System.out.println("Number of reads observed: " + result.getNumReads());
|
||||||
out.println("Number of variant sites observed: " + result.getNumVarSites());
|
System.out.println("Number of variant sites observed: " + result.getNumVarSites());
|
||||||
out.println("Average coverage: " + ((double) result.getNumReads() / result.getNumVarSites()));
|
System.out.println("Average coverage: " + ((double) result.getNumReads() / result.getNumVarSites()));
|
||||||
|
|
||||||
out.println("\n-- Phasing summary [minimal haplotype probability: " + phaseQualityThresh + "] --");
|
System.out.println("\n-- Phasing summary [minimal haplotype probability: " + phaseQualityThresh + "] --");
|
||||||
for (Map.Entry<String, PhaseCounts> sampPhaseCountEntry : result.getPhaseCounts()) {
|
for (Map.Entry<String, PhaseCounts> sampPhaseCountEntry : result.getPhaseCounts()) {
|
||||||
PhaseCounts pc = sampPhaseCountEntry.getValue();
|
PhaseCounts pc = sampPhaseCountEntry.getValue();
|
||||||
out.println("Sample: " + sampPhaseCountEntry.getKey() + "\tNumber of tested sites: " + pc.numTestedSites + "\tNumber of phased sites: " + pc.numPhased);
|
System.out.println("Sample: " + sampPhaseCountEntry.getKey() + "\tNumber of tested sites: " + pc.numTestedSites + "\tNumber of phased sites: " + pc.numPhased);
|
||||||
}
|
}
|
||||||
out.println("");
|
System.out.println("");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void writeVarContList(List<VariantContext> varContList) {
|
protected void writeVarContList(List<VariantContext> varContList) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue