diff --git a/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java b/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java index 26079d94b..ebd13e843 100755 --- a/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java +++ b/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/VariantsToTable.java @@ -47,7 +47,7 @@ public class VariantsToTable extends RodWalker { protected PrintStream out; @Argument(fullName="fields", shortName="F", doc="Fields to emit from the VCF, allows any VCF field, any info field, and some meta fields like nHets", required=true) - public String FIELDS; + public List fieldsToTake = null; @Argument(fullName="showFiltered", shortName="raw", doc="Include filtered records") public boolean showFiltered = false; @@ -59,11 +59,7 @@ public class VariantsToTable extends RodWalker { @Argument(fullName="ignoreMultiAllelic", shortName="IMA", doc="If provided, we will not require the site to be biallelic", required=false) public boolean ignoreMultiAllelic = false; - private List fieldsToTake; - public void initialize() { - fieldsToTake = Arrays.asList(FIELDS.split(",")); - out.println(Utils.join("\t", fieldsToTake)); } diff --git a/scala/qscript/lib/Vcf2Table.q b/scala/qscript/lib/Vcf2Table.q index c6028b2b4..1b66a648b 100755 --- a/scala/qscript/lib/Vcf2Table.q +++ b/scala/qscript/lib/Vcf2Table.q @@ -1,7 +1,6 @@ import org.broadinstitute.sting.commandline.Hidden +import org.broadinstitute.sting.queue.extensions.gatk.{RodBind, VariantsToTable} import org.broadinstitute.sting.queue.QScript - -import org.broadinstitute.sting.queue.library.ipf.vcf.VCFInfoToTable import collection.JavaConversions._ class Vcf2Table extends QScript { @@ -9,14 +8,21 @@ class Vcf2Table extends QScript { @Argument(shortName="f",doc="Info fields to extract",required=false) var fields : java.util.List[String] = new java.util.ArrayList[String] @Argument(shortName="o",doc="Output file",required=true) var output : File = _ @Argument(shortName="useFilters",doc="Use filtered sites?",required=false) var useFilters : Boolean = false - @Hidden @Argument(shortName="pass",doc="set the hack filter string to this value",required=false) var filterString : String = "PASS" - @Hidden @Argument(shortName="notfound",doc="set the hack no entry string to this value",required=false) var keyNotFound : String = "NA" + @Argument(shortName="r",doc="Reference file") var ref : File = _ + @Argument(shortName="i",doc="Intervals",required=false) var ints : java.util.List[File] = new java.util.ArrayList[File] + @Argument(shortName="g",doc="gatk jar",required=true) var gatk: File = _ + def script = { - var vcf2table : VCFInfoToTable = new VCFInfoToTable(vcf,output,fields,useFilters) - vcf2table.PF_KEY = filterString - vcf2table.NO_KEY = keyNotFound + var vcf2table : VariantsToTable = new VariantsToTable + vcf2table.rodBind :+= new RodBind("variant","vcf",vcf) + vcf2table.reference_sequence = ref + vcf2table.intervals = ints.toList + vcf2table.raw = useFilters + vcf2table.out = output + vcf2table.F = fields.toList + vcf2table.jarFile = gatk add(vcf2table) - this.functions.foreach(u => logger.debug("added: %s%n".format(u.toString))) + } } \ No newline at end of file diff --git a/scala/src/org/broadinstitute/sting/queue/library/ipf/vcf/VCFInfoToTable.scala b/scala/src/org/broadinstitute/sting/queue/library/ipf/vcf/VCFInfoToTable.scala deleted file mode 100755 index 59f659cb3..000000000 --- a/scala/src/org/broadinstitute/sting/queue/library/ipf/vcf/VCFInfoToTable.scala +++ /dev/null @@ -1,56 +0,0 @@ -package org.broadinstitute.sting.queue.library.ipf.vcf - -import org.broadinstitute.sting.commandline._ -import org.broadinstitute.sting.utils.text.XReadLines -import collection.JavaConversions._ -import java.io.{PrintStream, PrintWriter, File} -import collection.immutable.HashSet -import collection.mutable.HashMap -import org.broadinstitute.sting.queue.function.InProcessFunction - -class VCFInfoToTable(vcf: File, table: File, annots: List[String], keepFilter: Boolean) extends InProcessFunction { - def this(in: File, out: File, anns: List[String]) = this(in,out,anns,true) - def this(in: File, out: File) = this(in,out,Nil,true) - def this(in: File) = this(in, new File(in.getAbsolutePath.replace(".vcf",".info.table")), Nil, true) - def this(in: File, anns: List[String]) = this(in, new File(in.getAbsolutePath.replace(".vcf",".info.table")),anns,true) - def this(in: File, anns: java.util.List[String]) = this(in, new File(in.getAbsolutePath.replace(".vcf",".info.table")),anns.toList,true) - def this(in: File, anns: List[String], keep: Boolean) = this(in, new File(in.getAbsolutePath.replace(".vcf",".info.table")),anns,keep) - def this(in: File, anns: java.util.List[String], keep: Boolean) = this(in, new File(in.getAbsolutePath.replace(".vcf",".info.table")),anns.toList,keep) - def this(in: File, out: File, anns: java.util.List[String], keep: Boolean) = this(in,out,anns.toList,keep) - - @Input(doc="VCF file from which to extract annotion") var inVCF: File = vcf - @Output(doc="Table file to which to write") var outTable: File = table - @Argument(doc="Annotations to extract from info field") var annotations: List[String] = annots - @Argument(doc="Keep filtered records?") var keepFilteredRecs: Boolean = keepFilter - - // set as vars so pipelnes can hack these values - var NO_KEY : String = "NA" - var PF_KEY : String = "PASS" - - var out : PrintWriter = _ - var annotation_set : HashSet[String] = new HashSet[String] - - //todo -- Khalid: Why is run not being called? - def run = { - logger.debug("RUN IS CALLED") - annotation_set ++= annotations - out = new PrintWriter(new PrintStream(outTable)) - asScalaIterator(new XReadLines(inVCF)).foreach(lineToTable) - } - - def lineToTable(line : String) = { - if ( ! line.startsWith("#") ) { - val spline = line.split("\t") - if ( spline(6).equals(PF_KEY) || keepFilteredRecs ) { - val iMap = spline(7).split(";").map(_.split("=")).filter(p => annotation_set.contains(p.apply(0))).foldLeft(new HashMap[String,String])( (a,b) => a += new Tuple2(b.apply(0),b.apply(1)) ) - out.print("%s%n".format(annotations.map( u => { - if ( iMap.contains(u) ) { - iMap.get(u) - } else { - NO_KEY - } - }).reduceLeft((a,b) => a + "\t" + b))) - } - } - } -} \ No newline at end of file