changeset 2:91127c200437 draft

Uploaded
author iuc
date Mon, 03 Apr 2017 11:21:10 -0400
parents 944dcc240ab2
children d78ff3764fe5
files multigps.py multigps.xml
diffstat 2 files changed, 392 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/multigps.py	Mon Apr 03 11:21:10 2017 -0400
@@ -0,0 +1,265 @@
+import argparse
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+BUFF_SIZE = 1048576
+DESIGN_FILE = 'design.tabular'
+
+parser = argparse.ArgumentParser()
+parser.add_argument('--all_events_table', dest='all_events_table', help='Output all events table file')
+parser.add_argument('--alphascale', dest='alphascale', type=float, default=None, help='Alpha scaling factor')
+parser.add_argument('--chrom_len_file', dest='chrom_len_file', help='File listing the lengths of all chromosomes')
+parser.add_argument('--control', dest='control', default=None, help='Input control files and data formats')
+parser.add_argument('--diffp', dest='diffp', type=float, default=None, help='Minimum p-value for reporting differential enrichment')
+parser.add_argument('--edgerod', dest='edgerod', type=float, default=None, help='EdgeR over-dispersion parameter value')
+parser.add_argument('--exclude', dest='exclude', default=None, help='File containing a set of regions to ignore during MultiGPS training')
+parser.add_argument('--expt', dest='expt', default=None, help="Input expt files and data formats")
+parser.add_argument('--eventsaretxt', dest='eventsaretxt', default=None, help='Append a .txt extension to the events file for browser rendering')
+parser.add_argument('--fixedalpha', dest='fixedalpha', type=int, default=None, help='Impose this alpha')
+parser.add_argument('--fixedmodelrange', dest='fixedmodelrange', default=None, help='Keep binding model range fixed to inital size')
+parser.add_argument('--fixedpb', dest='fixedpb', type=int, default=None, help='Fixed per-base limit')
+parser.add_argument('--fixedscaling', dest='fixedscaling', type=float, default=None, help='Multiply control counts by total tag count ratio and then by this factor')
+parser.add_argument('--format', dest='format', default=None, help='Input expt file data format')
+parser.add_argument('--gaussmodelsmoothing', dest='gaussmodelsmoothing', default=None, help='Use Gaussian model smoothing')
+parser.add_argument('--gausssmoothparam', dest='gausssmoothparam', type=int, default=None, help='Smoothing factor')
+parser.add_argument('--input_item', dest='input_items', action='append', nargs=7, default=None, help="Input files, attributes and options")
+parser.add_argument('--jointinmodel', dest='jointinmodel', default=None, help='Allow joint events in model updates')
+parser.add_argument('--mappability', dest='mappability', type=float, default=None, help='Fraction of the genome that is mappable for these experiments')
+parser.add_argument('--maxtrainingrounds', dest='maxtrainingrounds', type=int, default=None, help='Maximum number of training rounds for updating binding event read distributions')
+parser.add_argument('--medianscale', dest='medianscale', default=None, help='Use the median signal/control ratio as the scaling factor')
+parser.add_argument('--meme1proc', dest='meme1proc', default=None, help='Do not run the parallel version of meme')
+parser.add_argument('--mememaxw', dest='mememaxw', type=int, default=None, help='Maximum motif width for MEME')
+parser.add_argument('--mememinw', dest='mememinw', type=int, default=None, help='Minimum motif width for MEME')
+parser.add_argument('--memenmotifs', dest='memenmotifs', type=int, default=None, help='Number of motifs MEME should find for each condition')
+parser.add_argument('--minfold', dest='minfold', type=float, default=None, help='Minimum event fold-change vs scaled control')
+parser.add_argument('--minqvalue', dest='minqvalue', type=float, default=None, help='Minimum Q-value (corrected p-value) of reported binding events')
+parser.add_argument('--minmodelupdateevents', dest='minmodelupdateevents', type=int, default=None, help='Minimum number of events to support an update of the read distribution')
+parser.add_argument('--mlconfignotshared', dest='mlconfignotshared', default=None, help='Share component configs in the ML step')
+parser.add_argument('--nocache', dest='nocache', default=None, help='Turn off caching of the entire set of experiments')
+parser.add_argument('--nodifftests', dest='nodifftests', default=None, help='Run differential enrichment tests')
+parser.add_argument('--nomodelsmoothing', dest='nomodelsmoothing', default=None, help='Perform binding model smoothing')
+parser.add_argument('--nomodelupdate', dest='nomodelupdate', default=None, help='Perform binding model updates')
+parser.add_argument('--nomotifprior', dest='nomotifprior', default=None, help='Perform motif-finding only')
+parser.add_argument('--nomotifs', dest='nomotifs', default=None, help='Perform motif-finding and motif priors')
+parser.add_argument('--nonunique', dest='nonunique', default=None, help='Use non-unique reads')
+parser.add_argument('--noposprior', dest='noposprior', default=None, help='Perform inter-experiment positional prior')
+parser.add_argument('--noscaling', dest='noscaling', default=None, help='Do not use signal vs control scaling')
+parser.add_argument('--output_bed', dest='output_bed', help='Output bed results file')
+parser.add_argument('--output_html', dest='output_html', help='Output html results file')
+parser.add_argument('--output_html_files_path', dest='output_html_files_path', help='Output html extra files')
+parser.add_argument('--plotscaling', dest='plotscaling', default=None, help='Plot diagnostic information for the chosen scaling method')
+parser.add_argument('--poissongausspb', dest='poissongausspb', type=int, default=None, help='Poisson threshold for filtering per base')
+parser.add_argument('--prlogconf', dest='prlogconf', type=int, default=None, help='Poisson log threshold for potential region scanning')
+parser.add_argument('--probshared', dest='probshared', type=float, default=None, help='Probability that events are shared across conditions')
+parser.add_argument('--readdistributionfile', dest='readdistributionfile', default=None, help='Optional binding event read distribution file for initializing models')
+parser.add_argument('--regressionscale', dest='regressionscale', default=None, help='Use scaling by regression on binned tag counts')
+parser.add_argument('--replicates_counts', dest='replicates_counts', help='Output replicates counts file')
+parser.add_argument('--scalewin', dest='scalewin', type=int, default=None, help='Window size for estimating scaling ratios')
+parser.add_argument('--seq', dest='seq', default=None, help='Reference genome path')
+parser.add_argument('--sesscale', dest='sesscale', default=None, help='Estimate scaling factor by SES')
+parser.add_argument('--splinesmoothparam', dest='splinesmoothparam', type=int, default=None, help='Spline smoothing parameter')
+parser.add_argument('--threads', dest='threads', type=int, default=4, help='The number of threads to run')
+args = parser.parse_args()
+
+
+def generate_design_file(input_items):
+    design_file = open(DESIGN_FILE, 'w')
+    for item in input_items:
+        file_name, label, file_format, condition_name, replicate_name, experiment_type, fixed_read_count = item
+        file_format = file_format.upper()
+        items = [file_name, label, file_format, condition_name]
+        if replicate_name not in ['None', None, '']:
+            items.append(replicate_name)
+        if experiment_type not in ['None', None, '']:
+            items.append(experiment_type)
+        if fixed_read_count not in ['None', None, '']:
+            items.append(fixed_read_count)
+        design_file.write('%s\n' % '\t'.join(items))
+    design_file.close()
+
+
+def get_file_with_extension(dir, ext):
+    file_list = [f for f in os.listdir(dir) if f.endswith(ext)]
+    if len(file_list) == 1:
+        return file_list[0]
+    stop_err('Error running MultiGPS: output file with extension "%s" not generated.' % ext)
+
+
+def get_stderr_exception(tmp_err, tmp_stderr, tmp_out, tmp_stdout, include_stdout=False):
+    tmp_stderr.close()
+    # Get stderr, allowing for case where it's very large.
+    tmp_stderr = open(tmp_err, 'rb')
+    stderr_str = ''
+    buffsize = BUFF_SIZE
+    try:
+        while True:
+            stderr_str += tmp_stderr.read(buffsize)
+            if not stderr_str or len(stderr_str) % buffsize != 0:
+                break
+    except OverflowError:
+        pass
+    tmp_stderr.close()
+    if include_stdout:
+        tmp_stdout = open(tmp_out, 'rb')
+        stdout_str = ''
+        buffsize = BUFF_SIZE
+        try:
+            while True:
+                stdout_str += tmp_stdout.read(buffsize)
+                if not stdout_str or len(stdout_str) % buffsize != 0:
+                    break
+        except OverflowError:
+            pass
+    tmp_stdout.close()
+    if include_stdout:
+        return 'STDOUT\n%s\n\nSTDERR\n%s\n' % (stdout_str, stderr_str)
+    return stderr_str
+
+
+def stop_err(msg):
+    sys.stderr.write(msg)
+    sys.exit(1)
+
+
+# Preparation.
+tmp_dir = tempfile.mkdtemp(prefix="tmp-multigps-")
+os.makedirs(args.output_html_files_path)
+# Build the command line.
+cmd = 'multigps'
+# General options
+cmd += ' --threads %s' % args.threads
+if args.eventsaretxt is not None:
+    # Append .txt extensions to events hrefs
+    # in output dataset so files will render
+    # in the browser.
+    cmd += ' --eventsaretxt'
+if args.meme1proc is not None:
+    # Do not run the parallel version of meme.
+    cmd += ' --meme1proc'
+# Experiment.
+if args.input_items is not None:
+    generate_design_file(args.input_items)
+    cmd += ' --design %s' % DESIGN_FILE
+else:
+    if args.expt is not None:
+        cmd += ' --expt %s' % args.expt
+    if args.format is not None:
+        cmd += ' --format %s' % args.format
+    if args.control is not None:
+        cmd += ' --ctrl %s' % args.control
+cmd += ' --geninfo %s' % args.chrom_len_file
+# Advanced options.
+if args.seq is not None:
+    cmd += ' --seq %s' % args.seq
+# Limits on how many reads
+if args.fixedpb is not None:
+    cmd += ' --fixedpb %d' % args.fixedpb
+if args.poissongausspb is not None:
+    cmd += ' --poissongausspb %d' % args.poissongausspb
+if args.nonunique is not None:
+    cmd += ' --nonunique'
+if args.mappability is not None:
+    cmd += ' --mappability %4f' % args.mappability
+if args.nocache is not None:
+    cmd += ' --nocache'
+# Scaling data.'
+if args.noscaling is not None:
+    cmd += ' --noscaling %s' % args.noscaling
+if args.medianscale is not None:
+    cmd += ' --medianscale %s' % args.medianscale
+if args.regressionscale is not None:
+    cmd += ' --regressionscale %s' % args.regressionscale
+if args.sesscale is not None:
+    cmd += ' --sesscale %s' % args.sesscale
+if args.fixedscaling is not None:
+    cmd += ' --fixedscaling %4f' % args.fixedscaling
+if args.scalewin is not None:
+    cmd += ' --scalewin %d' % args.scalewin
+if args.plotscaling is not None:
+    cmd += ' --plotscaling %s' % args.plotscaling
+# Running MultiGPS.
+if args.readdistributionfile is not None:
+    cmd += ' --d %s' % args.readdistributionfile
+if args.maxtrainingrounds is not None:
+    cmd += ' --r %s' % args.maxtrainingrounds
+if args.nomodelupdate is not None:
+    cmd += ' --nomodelupdate'
+if args.minmodelupdateevents is not None:
+    cmd += ' --minmodelupdateevents %d' % args.minmodelupdateevents
+if args.nomodelsmoothing is not None:
+    cmd += ' --nomodelsmoothing'
+if args.splinesmoothparam is not None:
+    cmd += ' --splinesmoothparam %d' % args.splinesmoothparam
+if args.gaussmodelsmoothing is not None:
+    cmd += ' --gaussmodelsmoothing'
+if args.gausssmoothparam is not None:
+    cmd += ' --gausssmoothparam %s' % args.gausssmoothparam
+if args.jointinmodel is not None:
+    cmd += ' --jointinmodel'
+if args.fixedmodelrange is not None:
+    cmd += ' --fixedmodelrange'
+if args.prlogconf is not None:
+    cmd += ' --prlogconf %d' % args.prlogconf
+if args.fixedalpha is not None:
+    cmd += ' --fixedalpha %d' % args.fixedalpha
+if args.alphascale is not None:
+    cmd += ' --alphascale %4f' % args.alphascale
+if args.mlconfignotshared is not None:
+    cmd += ' --mlconfignotshared'
+if args.exclude not in [None, 'None']:
+    cmd += ' --exclude %s' % args.exclude_file
+# MultiGPS priors
+if args.noposprior is not None:
+    cmd += ' --noposprior'
+if args.probshared is not None:
+    cmd += ' --probshared %4f' % args.probshared
+if args.memenmotifs is not None:
+    cmd += ' --memenmotifs %d' % args.memenmotifs
+if args.mememinw is not None:
+    cmd += ' --mememinw %d' % args.mememinw
+if args.mememaxw is not None:
+    cmd += ' --mememaxw %d' % args.mememaxw
+if args.nomotifs is not None:
+    cmd += ' --nomotifs'
+if args.nomotifprior is not None:
+    cmd += ' --nomotifprior'
+# Reporting binding events
+if args.minqvalue is not None:
+    cmd += ' --q %4f' % args.minqvalue
+if args.minfold is not None:
+    cmd += ' --minfold %4f' % args.minfold
+if args.nodifftests is not None:
+    cmd += ' --nodifftests'
+if args.edgerod is not None:
+    cmd += ' --edgerod %4f' % args.edgerod
+if args.diffp is not None:
+    cmd += ' --diffp %4f' % args.diffp
+# Output directory.
+cmd += ' --out %s' % args.output_html_files_path
+# Define command response buffers.
+tmp_out = tempfile.NamedTemporaryFile(dir=tmp_dir).name
+tmp_stdout = open(tmp_out, 'wb')
+tmp_err = tempfile.NamedTemporaryFile(dir=tmp_dir).name
+tmp_stderr = open(tmp_err, 'wb')
+tmp_filename = tempfile.NamedTemporaryFile(dir=tmp_dir).name
+# Execute the command.
+proc = subprocess.Popen(args=cmd, stderr=tmp_stderr, stdout=tmp_stdout, shell=True)
+rc = proc.wait()
+if rc != 0:
+    error_message = get_stderr_exception(tmp_err, tmp_stderr, tmp_out, tmp_stdout)
+    stop_err(error_message)
+# Move each output file to the approapriate output dataset path.
+output_bed = get_file_with_extension(args.output_html_files_path, 'bed')
+shutil.move(os.path.join(args.output_html_files_path, output_bed), args.output_bed)
+output_html = get_file_with_extension(args.output_html_files_path, 'html')
+shutil.move(os.path.join(args.output_html_files_path, output_html), args.output_html)
+replicates_counts = get_file_with_extension(args.output_html_files_path, 'counts')
+shutil.move(os.path.join(args.output_html_files_path, replicates_counts), args.replicates_counts)
+all_events_table = get_file_with_extension(args.output_html_files_path, 'table.txt')
+shutil.move(os.path.join(args.output_html_files_path, all_events_table), args.all_events_table)
+# Clean up.
+if os.path.exists(tmp_dir):
+    shutil.rmtree(tmp_dir)
--- a/multigps.xml	Tue Mar 28 12:24:07 2017 -0400
+++ b/multigps.xml	Mon Apr 03 11:21:10 2017 -0400
@@ -1,31 +1,53 @@
-<tool id="multigps" name="MultiGPS" version="0.73.0">
+<tool id="multigps" name="MultiGPS" version="0.74.0">
     <description>analyzes collections of multi-condition ChIP-seq data</description>
     <macros>
         <import>macros.xml</import>
     </macros>
     <requirements>
-        <requirement type="package" version="0.73">multigps</requirement>
+        <requirement type="package" version="0.74">multigps</requirement>
     </requirements>
     <command detect_errors="aggressive">
         <![CDATA[
-            #set output_dir = $output_html.files_path
-            mkdir -p $output_dir &&
-            multigps
+            python $__tool_directory__/multigps.py
             ## General options
+            #set single_or_multi_expt = $single_or_multi_expt_cond.single_or_multi_expt
+            #if str($single_or_multi_expt) == 'multi':
+                #for $i in $single_or_multi_expt_cond['input_items']:
+                    #set file_name = $i['input']
+                    #set label_cond = $i['label_cond']
+                    #set label = $label_cond.label
+                    #set file_format = $i['input'].ext
+                    #set condition_name = $i['condition_name']
+                    #set replicate_name = 'None'
+                    #set experiment_type = $i['experiment_type']
+                    #set fixed_read_count = $i['fixedreadcount']
+                    #if str($label) == 'Signal':
+                        #set replicate_name = $label_cond['replicate_name']
+                    #else if str($label) == 'Control':
+                        #set rncond = $label_cond['replicate_name_cond']
+                        #if str($rncond['specify_replicate_name']) == 'yes':
+                            #set replicate_name = $rncond['replicate_name']
+                        #end if
+                    #end if
+                    --input_item '$file_name' '$label' '$file_format' '$condition_name' '$replicate_name' '$experiment_type' '$fixed_read_count'
+                #end for
+            #else:
+                #set expt = $single_or_multi_expt_cond.expt
+                #set control = $single_or_multi_expt_cond.control
+                --expt '$expt'
+                --format $expt.ext
+                #if str($control) != 'None':
+                    --control '$control'
+                #end if
+            #end if
             ## Append .txt extensions to events hrefs
             ## in output dataset so files will render
             ## in the browser.
-            --eventsaretxt
-            ## Do not run the parallel version of meme
-            ## since it is not yet available in conda.
-            --meme1proc
-            --expt '$expt'
-            --format $expt.ext
-            #if str($ctrl) != 'None':
-                --ctrl '$ctrl'
-            #end if
+            --eventsaretxt 'true'
+            ## Do not run the parallel version of meme.
+            --meme1proc 'true'
             --threads \${GALAXY_SLOTS:-4}
-            --geninfo '$chromInfo'
+            --chrom_len_file '$chromInfo'
             ## Advanced options
             #set aoc = $advanced_options_cond
             #if str($aoc.advanced_options) == 'display':
@@ -39,9 +61,9 @@
                     #set rgc = $umc.reference_genome_cond
                     --seq
                     #if str($rgc.reference_genome_source) == 'cached':
-		        '${rgc.reference_genome.fields.path}'
+                        '${rgc.reference_genome.fields.path}'
                     #else:
-		        '${rgc.reference_genome}'
+                        '${rgc.reference_genome}'
                     #end if
                 #end if
                 ## Limits on how many reads
@@ -49,11 +71,11 @@
                     --fixedpb $rloc.fixedpb
                     --poissongausspb $rloc.poissongausspb
                     #if str($rloc.nonunique) == 'yes':
-                        --nonunique
+                        --nonunique 'true'
                     #end if
                     --mappability $rloc.mappability
                     #if str($rloc.nocache) == 'yes':
-                        --nocache
+                        --nocache 'true'
                     #end if
                 #end if
                 ## Scaling data
@@ -80,27 +102,27 @@
                 #end if
                 ## Running MultiGPS
                 #if str($aoc.readdistributionfile) != 'None':
-                    --d '$aoc.readdistributionfile'
+                    --readdistributionfile '$aoc.readdistributionfile'
                 #end if
-                --r $aoc.maxtrainingrounds
+                --maxtrainingrounds $aoc.maxtrainingrounds
                 #if str($aoc.nomodelupdate) == 'no':
-                    --nomodelupdate
+                    --nomodelupdate 'true'
                 #end if
                 --minmodelupdateevents $aoc.minmodelupdateevents
                 #if str($bmsc.nomodelsmoothing) == 'no':
-                    --nomodelsmoothing
+                    --nomodelsmoothing 'true'
                 #else:
                     --splinesmoothparam $bmsc.splinesmoothparam
                 #end if
                 #if str($gmsc.gaussmodelsmoothing) == 'yes':
-                    --gaussmodelsmoothing
+                    --gaussmodelsmoothing 'true'
                     --gausssmoothparam $gmsc.gausssmoothparam
                 #end if
                 #if str($aoc.jointinmodel) == 'yes':
-                    --jointinmodel
+                    --jointinmodel 'true'
                 #end if
                 #if str($aoc.fixedmodelrange) == 'yes':
-                    --fixedmodelrange
+                    --fixedmodelrange 'true'
                 #end if
                 --prlogconf $aoc.prlogconf
                 #if $aoc.fixedalpha > 0:
@@ -108,7 +130,7 @@
                 #end if
                 --alphascale $aoc.alphascale
                 #if str($aoc.mlconfignotshared) == 'no':
-                    --mlconfignotshared
+                    --mlconfignotshared 'true'
                 #end if
                 #if str($aoc.exclude) != 'None':
                     --exclude '$aoc.exclude'
@@ -119,7 +141,7 @@
                     #if str($mpc.multigps_priors) == 'yes':
                         #set bmc = $mpc.both_motifs_cond
                         #if str($mpc.noposprior) == 'no':
-                            --noposprior
+                            --noposprior 'true'
                         #end if
                         --probshared $mpc.probshared
                         #if str($bmc.nomotifs) == 'yes':
@@ -127,41 +149,86 @@
                             --mememinw $bmc.mememinw
                             --mememaxw $bmc.mememaxw
                         #else:
-                            #set mfoc = $bmc.nomotifprior_cond
-                            --nomotifs
-                            --nomotifprior $mfoc.nomotifprior
-                            #if str($mfoc.nomotifprior) == 'yes':
-                                --memenmotifs $mfoc.memenmotifs
-                                --mememinw $mfoc.mememinw
-                                --mememaxw $mfoc.mememaxw
+                            #set nmpc = $bmc.nomotifprior_cond
+                            --nomotifs 'true'
+                            #if str($nmpc.nomotifprior) == 'yes':
+                                --nomotifprior 'true'
+                                --memenmotifs $nmpc.memenmotifs
+                                --mememinw $nmpc.mememinw
+                                --mememaxw $nmpc.mememaxw
                             #end if
                         #end if
                     #end if
                 #end if
                 ## Reporting binding events
                 #if str($rbec.report_binding_events) == 'yes':
-                    --q $rbec.minqvalue
+                    --minqvalue $rbec.minqvalue
                     --minfold $rbec.minfold
                     #if str($rbec.nodifftests) == 'no':
-                        --nodifftests
+                        --nodifftests 'true'
                     #end if
                     --edgerod $rbec.edgerod
                     --diffp $rbec.diffp
                 #end if
             #end if
-            2>&1
-            --out '$output_html.files_path'
-            && cp $output_dir/*.events.txt '$experiment_events'
-            && mv $output_dir/*.html '$output_html'
-            && mv $output_dir/*.table.txt '$all_events_table'
-            && mv $output_dir/*.counts '$replicates_counts'
+            --output_html_files_path '$output_html.files_path'
+            --replicates_counts '$replicates_counts'
+            --output_bed '$output_bed'
+            --output_html '$output_html'
+            --all_events_table '$all_events_table'
         ]]>
     </command>
     <inputs>
-        <param name="expt" type="data" format="bam,bed,scidx" label="Run MultiGPS on">
-            <validator type="unspecified_build" />
-        </param>
-        <param name="ctrl" type="data" format="bam,bed,scidx" optional="True" label="Optional file containing reads from a control experiment" help="Must be same forat as the input above" />
+        <conditional name="single_or_multi_expt_cond">
+            <param name="single_or_multi_expt" type="select" label="Run MultiGPS on single or multiple inputs?">
+                <option value="multi" selected="True">Multiple inputs</option>
+                <option value="single">Single input</option>
+            </param>
+            <when value="multi">
+                <repeat name="input_items" title="Input files, attributes and options" min="2">
+                    <param name="input" type="data" format="bam,bed,scidx" label="Run multigps on" help="Supported formats are bam, bed and scidx">
+                        <validator type="unspecified_build" />
+                    </param>
+                    <conditional name="label_cond">
+                        <param name="label" type="select" label="This experiment is">
+                            <option value="Signal" selected="True">Signal</option>
+                            <option value="Control">Control</option>
+                        </param>
+                        <when value="Signal">
+                            <param name="replicate_name" type="text" label="Replicate name" />
+                        </when>
+                        <when value="Control">
+                            <conditional name="replicate_name_cond">
+                                <param  name="specify_replicate_name" type="select" label="Specify replicate name?" help="Optional for control experiments.  If used, the control will only be used for the corresponding named signal replicate">
+                                    <option value="no" selected="True">No</option>
+                                    <option value="yes">Yes</option>
+                                </param>
+                                <when value="yes">
+                                    <param name="replicate_name" type="text" optional="True" label="Replicate name"/>
+                                </when>
+                                <when value="no" />
+                            </conditional>
+                        </when>
+                    </conditional>
+                    <param name="condition_name" type="text" label="Condition name" />
+                    <param name="experiment_type" type="select" label="Experiment type for this replicate">
+                        <option value="None" selected="True">Do not set</option>
+                        <option value="chipseq">ChIP-seq</option>
+                        <option value="chipexo">ChIP-exo</option>
+                    </param>
+                    <param  name="fixedreadcount" type="select" label="Use fixed per-base read count limit for this replicate?" help="Selecting No uses a global per-base limit that is estimated from a Poisson distribution.">
+                        <option value="None" selected="True">No</option>
+                        <option value="P">Yes</option>
+                    </param>
+                </repeat>
+            </when>
+            <when value="single">
+                <param name="expt" type="data" format="bam,bed,scidx" label="Run MultiGPS on">
+                    <validator type="unspecified_build" />
+                </param>
+                <param name="control" type="data" format="bam,bed,scidx" optional="True" label="Optional file containing reads from a control experiment" help="Must be same forat as the input above" />
+            </when>
+        </conditional>
         <!-- Advanced options -->
         <conditional name="advanced_options_cond">
             <param name="advanced_options" type="select" label="Advanced options">
@@ -282,7 +349,7 @@
                             <when value="cached">
                                 <param name="reference_genome" type="select" label="Using reference genome">
                                     <options from_data_table="all_fasta">
-                                        <filter type="data_meta" key="dbkey" ref="expt" column="1"/>
+                                        <!-- <filter type="data_meta" key="dbkey" ref="expt" column="1"/> does not yet work in a repeat...-->
                                     </options>
                                     <validator type="no_options" message="A built-in reference genome is not available for the build associated with the selected input file"/>
                                 </param>
@@ -290,7 +357,7 @@
                             <when value="history">
                                 <param name="reference_genome" type="data" format="fasta" label="Using reference genome">
                                     <options>
-                                        <filter type="data_meta" key="dbkey" ref="expt"/>
+                                        <!-- <filter type="data_meta" key="dbkey" ref="expt"/> does not yet work in a repeat...-->
                                     </options>
                                     <validator type="no_options" message="The current history does not include a fasta dataset with the build associated with the selected input file"/>
                                 </param>
@@ -358,26 +425,28 @@
         </conditional>
     </inputs>
     <outputs>
-        <data name="replicates_counts" format="tabular" label="${tool.name} replicates counts on ${on_string}"/>
-        <data name="all_events_table" format="tabular" label="${tool.name} all events table on ${on_string}"/>
-        <data name="experiment_events" format="tabular" label="${tool.name} experiment events on ${on_string}"/>
-        <data name="output_html" format="html" label="${tool.name} on ${on_string}"/>
+        <data name="output_bed" format="bed" label="${tool.name} (bed) on ${on_string}"/>
+        <data name="output_html" format="html" label="${tool.name} (html) on ${on_string}"/>
+        <data name="replicates_counts" format="tabular" label="${tool.name} (replicates counts) on ${on_string}"/>
+        <data name="all_events_table" format="tabular" label="${tool.name} (all events table) on ${on_string}"/>
     </outputs>
     <tests>
         <test>
+            <param name="single_or_multi_expt" value="single" />
             <param name="expt" value="expt_hg19.scidx" ftype="scidx" dbkey="hg19" />
-            <param name="advanced_options_cond" value="hide" />
+            <param name="advanced_options" value="hide" />
             <output name="output_html" file="hg19_output_html1.html" ftype="html" compare="contains"/>
-            <output name="experiment_events" file="hg19_experiment_events1.tabular" ftype="tabular"/>
+            <output name="output_bed" file="hg19_output_bed1.bed" ftype="bed"/>
             <output name="all_events_table" file="hg19_all_events_table1.tabular" ftype="tabular"/>
             <output name="replicates_counts" file="hg19_replicates_counts1.tabular" ftype="tabular"/>
         </test>
         <test>
+            <param name="single_or_multi_expt" value="single" />
             <param name="expt" value="expt_hg19.scidx" ftype="scidx" dbkey="hg19" />
-            <param name="ctrl" value="cntrl_hg19.scidx" ftype="scidx" dbkey="hg19" />
-            <param name="advanced_options_cond" value="display" />
+            <param name="control" value="cntrl_hg19.scidx" ftype="scidx" dbkey="hg19" />
+            <param name="advanced_options" value="display" />
             <output name="output_html" file="hg19_output_html2.html" ftype="html" compare="contains"/>
-            <output name="experiment_events" file="hg19_experiment_events2.tabular" ftype="tabular"/>
+            <output name="output_bed" file="hg19_output_bed2.bed" ftype="bed"/>
             <output name="all_events_table" file="hg19_all_events_table2.tabular" ftype="tabular"/>
             <output name="replicates_counts" file="hg19_replicates_counts2.tabular" ftype="tabular"/>
         </test>