changeset 0:c06c30bfcf1b draft default tip

Imported from capsule None
author devteam
date Tue, 01 Apr 2014 09:11:48 -0400
parents
children
files gatk_macros.xml gatk_wrapper.py test-data/a.tab tool-data/gatk_sorted_picard_index.loc.sample tool_data_table_conf.xml.sample tool_dependencies.xml variant_apply_recalibration.xml
diffstat 7 files changed, 625 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gatk_macros.xml	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,305 @@
+<macros>
+  <template name="standard_gatk_options">      
+    ##start standard gatk options
+    #if $gatk_param_type.gatk_param_type_selector == "advanced":
+        #for $pedigree in $gatk_param_type.pedigree:
+            -p '--pedigree "${pedigree.pedigree_file}"'
+        #end for
+        #for $pedigree_string in $gatk_param_type.pedigree_string_repeat:
+            -p '--pedigreeString "${pedigree_string.pedigree_string}"'
+        #end for
+        -p '--pedigreeValidationType "${gatk_param_type.pedigree_validation_type}"'
+        #for $read_filter in $gatk_param_type.read_filter:
+            -p '--read_filter "${read_filter.read_filter_type.read_filter_type_selector}"
+            ###raise Exception( str( dir( $read_filter ) ) )
+            #for $name, $param in $read_filter.read_filter_type.iteritems():
+                #if $name not in [ "__current_case__", "read_filter_type_selector" ]:
+                    #if hasattr( $param.input, 'truevalue' ):
+                        ${param}
+                    #else:
+                        --${name} "${param}"
+                    #end if
+                #end if
+            #end for
+            '
+        #end for
+        #for $interval_count, $input_intervals in enumerate( $gatk_param_type.input_interval_repeat ):
+            -d "--intervals" "${input_intervals.input_intervals}" "${input_intervals.input_intervals.ext}" "input_intervals_${interval_count}"
+        #end for
+        
+        #for $interval_count, $input_intervals in enumerate( $gatk_param_type.input_exclude_interval_repeat ):
+            -d "--excludeIntervals" "${input_intervals.input_exclude_intervals}" "${input_intervals.input_exclude_intervals.ext}" "input_exlude_intervals_${interval_count}"
+        #end for
+
+        -p '--interval_set_rule "${gatk_param_type.interval_set_rule}"'
+        
+        -p '--downsampling_type "${gatk_param_type.downsampling_type.downsampling_type_selector}"'
+        #if str( $gatk_param_type.downsampling_type.downsampling_type_selector ) != "NONE":
+            -p '--${gatk_param_type.downsampling_type.downsample_to_type.downsample_to_type_selector} "${gatk_param_type.downsampling_type.downsample_to_type.downsample_to_value}"'
+        #end if
+        -p '
+        --baq "${gatk_param_type.baq}"
+        --baqGapOpenPenalty "${gatk_param_type.baq_gap_open_penalty}"
+        ${gatk_param_type.use_original_qualities}
+        --defaultBaseQualities "${gatk_param_type.default_base_qualities}"
+        --validation_strictness "${gatk_param_type.validation_strictness}"
+        --interval_merging "${gatk_param_type.interval_merging}"
+        ${gatk_param_type.disable_experimental_low_memory_sharding}
+        ${gatk_param_type.non_deterministic_random_seed}
+        '
+        #for $rg_black_list_count, $rg_black_list in enumerate( $gatk_param_type.read_group_black_list_repeat ):
+            #if $rg_black_list.read_group_black_list_type.read_group_black_list_type_selector == "file":
+                -d "--read_group_black_list" "${rg_black_list.read_group_black_list_type.read_group_black_list}" "txt" "input_read_group_black_list_${rg_black_list_count}"
+            #else
+                -p '--read_group_black_list "${rg_black_list.read_group_black_list_type.read_group_black_list}"'
+            #end if
+        #end for
+    #end if
+    
+    #if str( $reference_source.reference_source_selector ) == "history":
+        -d "-R" "${reference_source.ref_file}" "${reference_source.ref_file.ext}" "gatk_input"
+    #end if
+    ##end standard gatk options
+  </template>
+  <xml name="gatk_param_type_conditional">
+    <conditional name="gatk_param_type">
+      <param name="gatk_param_type_selector" type="select" label="Basic or Advanced GATK options">
+        <option value="basic" selected="True">Basic</option>
+        <option value="advanced">Advanced</option>
+      </param>
+      <when value="basic">
+        <!-- Do nothing here -->
+      </when>
+      <when value="advanced">
+        <repeat name="pedigree" title="Pedigree file" help="-ped,--pedigree &amp;lt;pedigree&amp;gt;">
+            <param name="pedigree_file" type="data" format="txt" label="Pedigree files for samples"/>
+        </repeat>
+        <repeat name="pedigree_string_repeat" title="Pedigree string" help="-pedString,--pedigreeString &amp;lt;pedigreeString&amp;gt;">
+            <param name="pedigree_string" type="text" value="" label="Pedigree string for samples"/>
+        </repeat>
+        <param name="pedigree_validation_type" type="select" label="How strict should we be in validating the pedigree information" help="-pedValidationType,--pedigreeValidationType &amp;lt;pedigreeValidationType&amp;gt;">
+          <option value="STRICT" selected="True">STRICT</option>
+          <option value="SILENT">SILENT</option>
+        </param>
+        <repeat name="read_filter" title="Read Filter" help="-rf,--read_filter &amp;lt;read_filter&amp;gt;">
+            <conditional name="read_filter_type">
+              <param name="read_filter_type_selector" type="select" label="Read Filter Type">
+                <option value="BadCigar">BadCigar</option>
+                <option value="BadMate">BadMate</option>
+                <option value="DuplicateRead">DuplicateRead</option>
+                <option value="FailsVendorQualityCheck">FailsVendorQualityCheck</option>
+                <option value="MalformedRead">MalformedRead</option>
+                <option value="MappingQuality">MappingQuality</option>
+                <option value="MappingQualityUnavailable">MappingQualityUnavailable</option>
+                <option value="MappingQualityZero">MappingQualityZero</option>
+                <option value="MateSameStrand">MateSameStrand</option>
+                <option value="MaxInsertSize">MaxInsertSize</option>
+                <option value="MaxReadLength" selected="True">MaxReadLength</option>
+                <option value="MissingReadGroup">MissingReadGroup</option>
+                <option value="NoOriginalQualityScores">NoOriginalQualityScores</option>
+                <option value="NotPrimaryAlignment">NotPrimaryAlignment</option>
+                <option value="Platform454">Platform454</option>
+                <option value="Platform">Platform</option>
+                <option value="PlatformUnit">PlatformUnit</option>
+                <option value="ReadGroupBlackList">ReadGroupBlackList</option>
+                <option value="ReadName">ReadName</option>
+                <option value="ReadStrand">ReadStrand</option>
+                <option value="ReassignMappingQuality">ReassignMappingQuality</option>
+                <option value="Sample">Sample</option>
+                <option value="SingleReadGroup">SingleReadGroup</option>
+                <option value="UnmappedRead">UnmappedRead</option>
+              </param>
+              <when value="BadCigar">
+                  <!-- no extra options -->
+              </when>
+              <when value="BadMate">
+                  <!-- no extra options -->
+              </when>
+              <when value="DuplicateRead">
+                  <!-- no extra options -->
+              </when>
+              <when value="FailsVendorQualityCheck">
+                  <!-- no extra options -->
+              </when>
+              <when value="MalformedRead">
+                  <!-- no extra options -->
+              </when>
+              <when value="MappingQuality">
+                  <param name="min_mapping_quality_score" type="integer" value="10" label="Minimum read mapping quality required to consider a read for calling"/>
+              </when>
+              <when value="MappingQualityUnavailable">
+                  <!-- no extra options -->
+              </when>
+              <when value="MappingQualityZero">
+                  <!-- no extra options -->
+              </when>
+              <when value="MateSameStrand">
+                  <!-- no extra options -->
+              </when>
+              <when value="MaxInsertSize">
+                  <param name="maxInsertSize" type="integer" value="1000000" label="Discard reads with insert size greater than the specified value"/>
+              </when>
+              <when value="MaxReadLength">
+                  <param name="maxReadLength" type="integer" value="76" label="Max Read Length"/>
+              </when>
+              <when value="MissingReadGroup">
+                  <!-- no extra options -->
+              </when>
+              <when value="NoOriginalQualityScores">
+                  <!-- no extra options -->
+              </when>
+              <when value="NotPrimaryAlignment">
+                  <!-- no extra options -->
+              </when>
+              <when value="Platform454">
+                  <!-- no extra options -->
+              </when>
+              <when value="Platform">
+                  <param name="PLFilterName" type="text" value="" label="Discard reads with RG:PL attribute containing this string"/>
+              </when>
+              <when value="PlatformUnit">
+                  <!-- no extra options -->
+              </when>
+              <when value="ReadGroupBlackList">
+                  <!-- no extra options -->
+              </when>
+              <when value="ReadName">
+                  <param name="readName" type="text" value="" label="Filter out all reads except those with this read name"/>
+              </when>
+              <when value="ReadStrand">
+                  <param name="filterPositive" type="boolean" truevalue="--filterPositive" falsevalue="" label="Discard reads on the forward strand"/>
+              </when>
+              <when value="ReassignMappingQuality">
+                  <param name="default_mapping_quality" type="integer" value="60" label="Default read mapping quality to assign to all reads"/>
+              </when>
+              <when value="Sample">
+                  <param name="sample_to_keep" type="text" value="" label="The name of the sample(s) to keep, filtering out all others"/>
+              </when>
+              <when value="SingleReadGroup">
+                  <param name="read_group_to_keep" type="integer" value="76" label="The name of the read group to keep, filtering out all others"/>
+              </when>
+              <when value="UnmappedRead">
+                  <!-- no extra options -->
+              </when>
+            </conditional>
+        </repeat>
+        <repeat name="input_interval_repeat" title="Operate on Genomic intervals" help="-L,--intervals &amp;lt;intervals&amp;gt;">
+          <param name="input_intervals" type="data" format="bed,gatk_interval,picard_interval_list,vcf" label="Genomic intervals" />
+        </repeat>
+        <repeat name="input_exclude_interval_repeat" title="Exclude Genomic intervals" help="-XL,--excludeIntervals &amp;lt;excludeIntervals&amp;gt;">
+          <param name="input_exclude_intervals" type="data" format="bed,gatk_interval,picard_interval_list,vcf" label="Genomic intervals" />
+        </repeat>
+        
+        <param name="interval_set_rule" type="select" label="Interval set rule" help="-isr,--interval_set_rule &amp;lt;interval_set_rule&amp;gt;">
+          <option value="UNION" selected="True">UNION</option>
+          <option value="INTERSECTION">INTERSECTION</option>
+        </param>
+        
+        <conditional name="downsampling_type">
+          <param name="downsampling_type_selector" type="select" label="Type of reads downsampling to employ at a given locus" help="-dt,--downsampling_type &amp;lt;downsampling_type&amp;gt;">
+            <option value="NONE" selected="True">NONE</option>
+            <option value="ALL_READS">ALL_READS</option>
+            <option value="BY_SAMPLE">BY_SAMPLE</option>
+          </param>
+          <when value="NONE">
+              <!-- no more options here -->
+          </when>
+          <when value="ALL_READS">
+              <conditional name="downsample_to_type">
+                  <param name="downsample_to_type_selector" type="select" label="Downsample method">
+                      <option value="downsample_to_fraction" selected="True">Downsample by Fraction</option>
+                      <option value="downsample_to_coverage">Downsample by Coverage</option>
+                  </param>
+                  <when value="downsample_to_fraction">
+                      <param name="downsample_to_value" type="float" label="Fraction [0.0-1.0] of reads to downsample to" value="1" min="0" max="1" help="-dfrac,--downsample_to_fraction &amp;lt;downsample_to_fraction&amp;gt;"/>
+                  </when>
+                  <when value="downsample_to_coverage">
+                      <param name="downsample_to_value" type="integer" label="Coverage to downsample to at any given locus" value="0" help="-dcov,--downsample_to_coverage &amp;lt;downsample_to_coverage&amp;gt;"/>
+                  </when>
+              </conditional>
+          </when>
+          <when value="BY_SAMPLE">
+              <conditional name="downsample_to_type">
+                  <param name="downsample_to_type_selector" type="select" label="Downsample method">
+                      <option value="downsample_to_fraction" selected="True">Downsample by Fraction</option>
+                      <option value="downsample_to_coverage">Downsample by Coverage</option>
+                  </param>
+                  <when value="downsample_to_fraction">
+                      <param name="downsample_to_value" type="float" label="Fraction [0.0-1.0] of reads to downsample to" value="1" min="0" max="1" help="-dfrac,--downsample_to_fraction &amp;lt;downsample_to_fraction&amp;gt;"/>
+                  </when>
+                  <when value="downsample_to_coverage">
+                      <param name="downsample_to_value" type="integer" label="Coverage to downsample to at any given locus" value="0" help="-dcov,--downsample_to_coverage &amp;lt;downsample_to_coverage&amp;gt;"/>
+                  </when>
+              </conditional>
+          </when>
+        </conditional>
+        <param name="baq" type="select" label="Type of BAQ calculation to apply in the engine" help="-baq,--baq &amp;lt;baq&amp;gt;">
+          <option value="OFF" selected="True">OFF</option>
+          <option value="CALCULATE_AS_NECESSARY">CALCULATE_AS_NECESSARY</option>
+          <option value="RECALCULATE">RECALCULATE</option>
+        </param>
+        <param name="baq_gap_open_penalty" type="float" label="BAQ gap open penalty (Phred Scaled)" value="40" help="Default value is 40. 30 is perhaps better for whole genome call sets. -baqGOP,--baqGapOpenPenalty &amp;lt;baqGapOpenPenalty&amp;gt;" />
+        <param name="use_original_qualities" type="boolean" truevalue="--useOriginalQualities" falsevalue="" label="Use the original base quality scores from the OQ tag" help="-OQ,--useOriginalQualities" />
+        <param name="default_base_qualities" type="integer" label="Value to be used for all base quality scores, when some are missing" value="-1" help="-DBQ,--defaultBaseQualities &amp;lt;defaultBaseQualities&amp;gt;"/>
+        <param name="validation_strictness" type="select" label="How strict should we be with validation" help="-S,--validation_strictness &amp;lt;validation_strictness&amp;gt;">
+          <option value="STRICT" selected="True">STRICT</option>
+          <option value="LENIENT">LENIENT</option>
+          <option value="SILENT">SILENT</option>
+          <!-- <option value="DEFAULT_STRINGENCY">DEFAULT_STRINGENCY</option> listed in docs, but not valid value...-->
+        </param>
+        <param name="interval_merging" type="select" label="Interval merging rule" help="-im,--interval_merging &amp;lt;interval_merging&amp;gt;">
+          <option value="ALL" selected="True">ALL</option>
+          <option value="OVERLAPPING_ONLY">OVERLAPPING_ONLY</option>
+        </param>
+        
+        <repeat name="read_group_black_list_repeat" title="Read group black list" help="-rgbl,--read_group_black_list &amp;lt;read_group_black_list&amp;gt;">
+          <conditional name="read_group_black_list_type">
+            <param name="read_group_black_list_type_selector" type="select" label="Type of reads read group black list">
+              <option value="file" selected="True">Filters in file</option>
+              <option value="text">Specify filters as a string</option>
+            </param>
+            <when value="file">
+              <param name="read_group_black_list" type="data" format="txt" label="Read group black list file" />
+            </when>
+            <when value="text">
+              <param name="read_group_black_list" type="text" value="tag:string" label="Read group black list tag:string" />
+            </when>
+          </conditional>
+        </repeat>
+        
+        <param name="disable_experimental_low_memory_sharding" type="boolean" truevalue="--disable_experimental_low_memory_sharding" falsevalue="" label="Disable experimental low-memory sharding functionality." checked="False" help="--disable_experimental_low_memory_sharding"/>
+        <param name="non_deterministic_random_seed" type="boolean" truevalue="--nonDeterministicRandomSeed" falsevalue="" label="Makes the GATK behave non deterministically, that is, the random numbers generated will be different in every run" checked="False"  help="-ndrs,--nonDeterministicRandomSeed"/>
+        
+      </when>
+    </conditional>    
+  </xml>
+  <xml name="analysis_type_conditional">
+    <conditional name="analysis_param_type">
+      <param name="analysis_param_type_selector" type="select" label="Basic or Advanced Analysis options">
+        <option value="basic" selected="True">Basic</option>
+        <option value="advanced">Advanced</option>
+      </param>
+      <when value="basic">
+        <!-- Do nothing here -->
+      </when>
+      <when value="advanced">
+        <yield />
+      </when>
+    </conditional>
+  </xml>
+  <xml name="reference_source_selector_param">
+    <param name="reference_source_selector" type="select" label="Choose the source for the reference list">
+      <option value="cached">Locally cached</option>
+      <option value="history">History</option>
+    </param>
+  </xml>
+  <token name="@CITATION_SECTION@">------
+
+**Citation**
+
+For the underlying tool, please cite `DePristo MA, Banks E, Poplin R, Garimella KV, Maguire JR, Hartl C, Philippakis AA, del Angel G, Rivas MA, Hanna M, McKenna A, Fennell TJ, Kernytsky AM, Sivachenko AY, Cibulskis K, Gabriel SB, Altshuler D, Daly MJ. A framework for variation discovery and genotyping using next-generation DNA sequencing data. Nat Genet. 2011 May;43(5):491-8. &lt;http://www.ncbi.nlm.nih.gov/pubmed/21478889&gt;`_
+
+If you use this tool in Galaxy, please cite Blankenberg D, et al. *In preparation.*
+
+  </token>
+</macros>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gatk_wrapper.py	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+#Dan Blankenberg
+
+"""
+A wrapper script for running the GenomeAnalysisTK.jar commands.
+"""
+
+import sys, optparse, os, tempfile, subprocess, shutil
+from binascii import unhexlify
+from string import Template
+
+GALAXY_EXT_TO_GATK_EXT = { 'gatk_interval':'intervals', 'bam_index':'bam.bai', 'gatk_dbsnp':'dbSNP', 'picard_interval_list':'interval_list' } #items not listed here will use the galaxy extension as-is
+GALAXY_EXT_TO_GATK_FILE_TYPE = GALAXY_EXT_TO_GATK_EXT #for now, these are the same, but could be different if needed
+DEFAULT_GATK_PREFIX = "gatk_file"
+CHUNK_SIZE = 2**20 #1mb
+
+
+def cleanup_before_exit( tmp_dir ):
+    if tmp_dir and os.path.exists( tmp_dir ):
+        shutil.rmtree( tmp_dir )
+
+def gatk_filename_from_galaxy( galaxy_filename, galaxy_ext, target_dir = None, prefix = None ):
+    suffix = GALAXY_EXT_TO_GATK_EXT.get( galaxy_ext, galaxy_ext )
+    if prefix is None:
+        prefix = DEFAULT_GATK_PREFIX
+    if target_dir is None:
+        target_dir = os.getcwd()
+    gatk_filename = os.path.join( target_dir, "%s.%s" % ( prefix, suffix ) )
+    os.symlink( galaxy_filename, gatk_filename )
+    return gatk_filename
+
+def gatk_filetype_argument_substitution( argument, galaxy_ext ):
+    return argument % dict( file_type = GALAXY_EXT_TO_GATK_FILE_TYPE.get( galaxy_ext, galaxy_ext ) )
+
+def open_file_from_option( filename, mode = 'rb' ):
+    if filename:
+        return open( filename, mode = mode )
+    return None
+
+def html_report_from_directory( html_out, dir ):
+    html_out.write( '<html>\n<head>\n<title>Galaxy - GATK Output</title>\n</head>\n<body>\n<p/>\n<ul>\n' )
+    for fname in sorted( os.listdir( dir ) ):
+        html_out.write(  '<li><a href="%s">%s</a></li>\n' % ( fname, fname ) )
+    html_out.write( '</ul>\n</body>\n</html>\n' )
+
+def index_bam_files( bam_filenames, tmp_dir ):
+    for bam_filename in bam_filenames:
+        bam_index_filename = "%s.bai" % bam_filename
+        if not os.path.exists( bam_index_filename ):
+            #need to index this bam file
+            stderr_name = tempfile.NamedTemporaryFile( prefix = "bam_index_stderr" ).name
+            command = 'samtools index %s %s' % ( bam_filename, bam_index_filename )
+            proc = subprocess.Popen( args=command, shell=True, stderr=open( stderr_name, 'wb' ) )
+            return_code = proc.wait()
+            if return_code:
+                for line in open( stderr_name ):
+                    print >> sys.stderr, line
+                os.unlink( stderr_name ) #clean up
+                cleanup_before_exit( tmp_dir )
+                raise Exception( "Error indexing BAM file" )
+            os.unlink( stderr_name ) #clean up
+
+def __main__():
+    #Parse Command Line
+    parser = optparse.OptionParser()
+    parser.add_option( '-p', '--pass_through', dest='pass_through_options', action='append', type="string", help='These options are passed through directly to GATK, without any modification.' )
+    parser.add_option( '-o', '--pass_through_options', dest='pass_through_options_encoded', action='append', type="string", help='These options are passed through directly to GATK, with decoding from binascii.unhexlify.' )
+    parser.add_option( '-d', '--dataset', dest='datasets', action='append', type="string", nargs=4, help='"-argument" "original_filename" "galaxy_filetype" "name_prefix"' )
+    parser.add_option( '', '--max_jvm_heap', dest='max_jvm_heap', action='store', type="string", default=None, help='If specified, the maximum java virtual machine heap size will be set to the provide value.' )
+    parser.add_option( '', '--max_jvm_heap_fraction', dest='max_jvm_heap_fraction', action='store', type="int", default=None, help='If specified, the maximum java virtual machine heap size will be set to the provide value as a fraction of total physical memory.' )
+    parser.add_option( '', '--stdout', dest='stdout', action='store', type="string", default=None, help='If specified, the output of stdout will be written to this file.' )
+    parser.add_option( '', '--stderr', dest='stderr', action='store', type="string", default=None, help='If specified, the output of stderr will be written to this file.' )
+    parser.add_option( '', '--html_report_from_directory', dest='html_report_from_directory', action='append', type="string", nargs=2, help='"Target HTML File" "Directory"')
+    (options, args) = parser.parse_args()
+    
+    tmp_dir = tempfile.mkdtemp( prefix='tmp-gatk-' )
+    if options.pass_through_options:
+        cmd = ' '.join( options.pass_through_options )
+    else:
+        cmd = ''
+    if options.pass_through_options_encoded:
+        cmd = '%s %s' % ( cmd, ' '.join( map( unhexlify, options.pass_through_options_encoded ) ) )
+    if options.max_jvm_heap is not None:
+        cmd = cmd.replace( 'java ', 'java -Xmx%s ' % ( options.max_jvm_heap ), 1 )
+    elif options.max_jvm_heap_fraction is not None:
+        cmd = cmd.replace( 'java ', 'java -XX:DefaultMaxRAMFraction=%s  -XX:+UseParallelGC ' % ( options.max_jvm_heap_fraction ), 1 )
+    bam_filenames = []
+    if options.datasets:
+        for ( dataset_arg, filename, galaxy_ext, prefix ) in options.datasets:
+            gatk_filename = gatk_filename_from_galaxy( filename, galaxy_ext, target_dir = tmp_dir, prefix = prefix )
+            if dataset_arg:
+                cmd = '%s %s "%s"' % ( cmd, gatk_filetype_argument_substitution( dataset_arg, galaxy_ext ), gatk_filename )
+            if galaxy_ext == "bam":
+                bam_filenames.append( gatk_filename )
+    index_bam_files( bam_filenames, tmp_dir )
+    #set up stdout and stderr output options
+    stdout = open_file_from_option( options.stdout, mode = 'wb' )
+    stderr = open_file_from_option( options.stderr, mode = 'wb' )
+    #if no stderr file is specified, we'll use our own
+    if stderr is None:
+        stderr = tempfile.NamedTemporaryFile( prefix="gatk-stderr-", dir=tmp_dir )
+    
+    proc = subprocess.Popen( args=cmd, stdout=stdout, stderr=stderr, shell=True, cwd=tmp_dir )
+    return_code = proc.wait()
+    
+    if return_code:
+        stderr_target = sys.stderr
+    else:
+        stderr_target = sys.stdout
+    stderr.flush()
+    stderr.seek(0)
+    while True:
+        chunk = stderr.read( CHUNK_SIZE )
+        if chunk:
+            stderr_target.write( chunk )
+        else:
+            break
+    stderr.close()
+    #generate html reports
+    if options.html_report_from_directory:
+        for ( html_filename, html_dir ) in options.html_report_from_directory:
+            html_report_from_directory( open( html_filename, 'wb' ), html_dir )
+    
+    cleanup_before_exit( tmp_dir )
+
+if __name__=="__main__": __main__()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-data/a.tab	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,15 @@
+CHR	SNP	BP	A1	TEST	NMISS	BETA	STAT	P
+1	rs1181876	3671541	T	DOMDEV	958	-1.415	-3.326	0.0009161
+1	rs10492923	5092886	C	ADD	1007	5.105	4.368	1.382e-05
+1	rs10492923	5092886	C	DOMDEV	1007	-5.612	-4.249	2.35e-05
+1	rs10492923	5092886	C	GENO_2DF	1007	NA	19.9	4.775e-05
+1	rs1801133	11778965	T	ADD	1022	1.23	3.97	7.682e-05
+1	rs1801133	11778965	T	GENO_2DF	1022	NA	16.07	0.0003233
+1	rs1361912	12663121	A	ADD	1021	12.69	4.093	4.596e-05
+1	rs1361912	12663121	A	DOMDEV	1021	-12.37	-3.945	8.533e-05
+1	rs1361912	12663121	A	GENO_2DF	1021	NA	17.05	0.0001982
+1	rs1009806	19373138	G	ADD	1021	-1.334	-3.756	0.0001826
+1	rs1009806	19373138	G	GENO_2DF	1021	NA	19.36	6.244e-05
+1	rs873654	29550948	A	DOMDEV	1012	1.526	3.6	0.0003339
+1	rs10489527	36800027	C	ADD	1016	12.67	4.114	4.211e-05
+1	rs10489527	36800027	C	DOMDEV	1016	-13.05	-4.02	6.249e-05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool-data/gatk_sorted_picard_index.loc.sample	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,26 @@
+#This is a sample file distributed with Galaxy that enables tools
+#to use a directory of Picard dict and associated files. You will need
+#to create these data files and then create a picard_index.loc file 
+#similar to this one (store it in this directory) that points to 
+#the directories in which those files are stored. The picard_index.loc 
+#file has this format (longer white space is the TAB character):
+#
+#<unique_build_id>	<dbkey>		<display_name>		<fasta_file_path>
+#
+#So, for example, if you had hg18 indexed and stored in 
+#/depot/data2/galaxy/srma/hg18/,
+#then the srma_index.loc entry would look like this:
+#
+#hg18	hg18	hg18 Pretty		/depot/data2/galaxy/picard/hg18/hg18.fa
+#
+#and your /depot/data2/galaxy/srma/hg18/ directory
+#would contain the following three files:
+#hg18.fa
+#hg18.dict
+#hg18.fa.fai
+#
+#The dictionary file for each reference (ex. hg18.dict) must be 
+#created via Picard (http://picard.sourceforge.net). Note that
+#the dict file does not have the .fa extension although the
+#path list in the loc file does include it.
+#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_data_table_conf.xml.sample	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,8 @@
+<!-- Use the file tool_data_table_conf.xml.oldlocstyle if you don't want to update your loc files as changed in revision 4550:535d276c92bc-->
+<tables>
+    <!-- Location of Picard dict files valid for GATK -->
+    <table name="gatk_picard_indexes" comment_char="#">
+        <columns>value, dbkey, name, path</columns>
+        <file path="tool-data/gatk_sorted_picard_index.loc" />
+    </table>
+</tables>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tool_dependencies.xml	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<tool_dependency>
+  <package name="gatk" version="1.4">
+      <repository changeset_revision="0cc94f66d00e" name="package_gatk_1_4" owner="devteam" prior_installation_required="False" toolshed="http://testtoolshed.g2.bx.psu.edu" />
+    </package>
+</tool_dependency>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/variant_apply_recalibration.xml	Tue Apr 01 09:11:48 2014 -0400
@@ -0,0 +1,139 @@
+<tool id="gatk_variant_apply_recalibration" name="Apply Variant Recalibration" version="0.0.4">
+  <description></description>
+  <requirements>
+      <requirement type="package" version="1.4">gatk</requirement>
+  </requirements>
+  <macros>
+    <import>gatk_macros.xml</import>
+  </macros>
+  <command interpreter="python">gatk_wrapper.py
+   --max_jvm_heap_fraction "1"
+   --stdout "${output_log}"
+   #for $var_count, $variant in enumerate( $reference_source.variants ):
+      -d "--input:input_${var_count},%(file_type)s" "${variant.input_variants}" "${variant.input_variants.ext}" "input_variants_${var_count}"
+   #end for
+   -p 'java 
+    -jar "\$JAVA_JAR_PATH/GenomeAnalysisTK.jar"
+    -T "ApplyRecalibration"
+    ##--num_threads 4 ##hard coded, for now
+    -et "NO_ET" ##ET no phone home
+    #if $reference_source.reference_source_selector != "history":
+        -R "${reference_source.ref_file.fields.path}"
+    #end if
+    --recal_file "${reference_source.input_recal}"
+    --tranches_file "${reference_source.input_tranches}"
+    --out "${output_variants}"
+   '
+    
+    #include source=$standard_gatk_options#
+    
+    ##start analysis specific options
+    -p '
+    --mode "${mode}"
+    
+    #for $ignore_filter in $ignore_filters:
+        #set $ignore_filter_name = str( $ignore_filter.ignore_filter_type.ignore_filter_type_selector )
+        #if $ignore_filter_name == "custom":
+          #set $ignore_filter_name = str( $ignore_filter.ignore_filter_type.filter_name )
+        #end if
+        --ignore_filter "${ignore_filter_name}"
+    #end for
+    --ts_filter_level "${ts_filter_level}"
+    '
+  </command>
+  <inputs>
+    <conditional name="reference_source">
+      <expand macro="reference_source_selector_param" />
+      <when value="cached">
+        <repeat name="variants" title="Variant" min="1" help="-input,--input &amp;lt;input&amp;gt;">
+          <param name="input_variants" type="data" format="vcf" label="Variant file to annotate"/>
+        </repeat>
+        <param name="input_recal" type="data" format="gatk_recal" label="Variant Recalibration file" help="-recalFile,--recal_file &amp;lt;recal_file&amp;gt;" />
+        <param name="input_tranches" type="data" format="gatk_tranche" label="Variant Tranches file" help="-tranchesFile,--tranches_file &amp;lt;tranches_file&amp;gt;" />
+        <param name="ref_file" type="select" label="Using reference genome" help="-R,--reference_sequence &amp;lt;reference_sequence&amp;gt;">
+          <options from_data_table="gatk_picard_indexes">
+            <!-- <filter type="data_meta" key="dbkey" ref="variants[0].input_variants" column="dbkey"/> -->
+          </options>
+          <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
+        </param>
+      </when>
+      <when value="history"> <!-- FIX ME!!!! -->
+        <repeat name="variants" title="Variant" min="1" help="-input,--input &amp;lt;input&amp;gt;">
+          <param name="input_variants" type="data" format="vcf" label="Variant file to annotate" />
+        </repeat>
+        <param name="input_recal" type="data" format="gatk_recal" label="Variant Recalibration file" help="-recalFile,--recal_file &amp;lt;recal_file&amp;gt;" />
+        <param name="input_tranches" type="data" format="gatk_tranche" label="Variant Tranches file" help="-tranchesFile,--tranches_file &amp;lt;tranches_file&amp;gt;" />
+        <param name="ref_file" type="data" format="fasta" label="Using reference file" help="-R,--reference_sequence &amp;lt;reference_sequence&amp;gt;" />
+      </when>
+    </conditional>
+    
+    <expand macro="gatk_param_type_conditional" />
+    
+        <param name="mode" type="select" label="Recalibration mode" help="-mode,--mode &amp;lt;mode&amp;gt;">
+          <option value="SNP" selected="True">SNP</option>
+          <option value="INDEL">INDEL</option>
+          <option value="BOTH">BOTH</option>
+        </param>
+       <repeat name="ignore_filters" title="Ignore Filter" help="-ignoreFilter,--ignore_filter &amp;lt;ignore_filter&amp;gt;">
+          <conditional name="ignore_filter_type">
+            <param name="ignore_filter_type_selector" type="select" label="Filter Type">
+              <option value="HARD_TO_VALIDATE">HARD_TO_VALIDATE</option>
+              <option value="LowQual" >LowQual</option>
+              <option value="custom" selected="True">Other</option>
+            </param>
+            <when value="custom">
+              <param name="filter_name" type="text" value="" label="Filter name"/>
+            </when>
+            <when value="HARD_TO_VALIDATE" />
+            <when value="LowQual" />
+          </conditional>
+        </repeat>
+    <param name="ts_filter_level" type="float" label="truth sensitivity level at which to start filtering, used here to indicate filtered variants in plots" value="99.0" help="-ts_filter_level,--ts_filter_level &amp;lt;ts_filter_level&amp;gt;"/>
+  </inputs>
+  <outputs>
+    <data format="vcf" name="output_variants" label="${tool.name} on ${on_string} (Variants File)" />
+    <data format="txt" name="output_log" label="${tool.name} on ${on_string} (log)" />
+  </outputs>
+  <tests>
+      <!-- ADD TESTS -->
+  </tests>
+  <help>
+**What it does**
+
+Applies cuts to the input vcf file (by adding filter lines) to achieve the desired novel FDR levels which were specified during VariantRecalibration
+
+For more information on using the ApplyRecalibration module, see this `tool specific page &lt;http://www.broadinstitute.org/gsa/wiki/index.php/Variant_quality_score_recalibration&gt;`_.
+
+To learn about best practices for variant detection using GATK, see this `overview &lt;http://www.broadinstitute.org/gsa/wiki/index.php/Best_Practice_Variant_Detection_with_the_GATK_v3&gt;`_.
+
+If you encounter errors, please view the `GATK FAQ &lt;http://www.broadinstitute.org/gsa/wiki/index.php/Frequently_Asked_Questions&gt;`_.
+
+------
+
+**Inputs**
+
+GenomeAnalysisTK: ApplyRecalibration accepts a variant input file, a recalibration file and a tranches file.
+
+
+**Outputs**
+
+The output is in VCF format.
+
+
+Go `here &lt;http://www.broadinstitute.org/gsa/wiki/index.php/Input_files_for_the_GATK&gt;`_ for details on GATK file formats.
+
+-------
+
+**Settings**::
+
+
+ recal_file         The output recal file used by ApplyRecalibration
+ tranches_file      The input tranches file describing where to cut the data
+ out                The output filtered, recalibrated VCF file
+ ts_filter_level    The truth sensitivity level at which to start filtering
+ ignore_filter      If specified the optimizer will use variants even if the specified filter name is marked in the input VCF file
+ mode               Recalibration mode to employ: 1.) SNP for recalibrating only SNPs (emitting indels untouched in the output VCF); 2.) INDEL for indels; and 3.) BOTH for recalibrating both SNPs and indels simultaneously. (SNP|INDEL|BOTH)
+
+@CITATION_SECTION@
+  </help>
+</tool>