changeset 1:c05f607d116c draft default tip

Replace simplejson with json. Add option to call broad peaks.
author stemcellcommons
date Tue, 20 May 2014 12:10:38 -0400
parents 642c0da30ca6
children
files macs2_wrapper.py macs2_wrapper.xml
diffstat 2 files changed, 180 insertions(+), 166 deletions(-) [+]
line wrap: on
line diff
--- a/macs2_wrapper.py	Thu Oct 17 12:47:49 2013 -0400
+++ b/macs2_wrapper.py	Tue May 20 12:10:38 2014 -0400
@@ -1,12 +1,9 @@
-#purpose: macs2 python wrapper
-#author: Ziru Zhou
-#date: November, 2012
+# macs2 python wrapper
+# based on http://toolshed.g2.bx.psu.edu/view/modencode-dcc/macs2
 
 import sys, subprocess, tempfile, shutil, glob, os, os.path, gzip
 from galaxy import eggs
-import pkg_resources
-pkg_resources.require( "simplejson" )
-import simplejson
+import json
 
 CHUNK_SIZE = 1024
 
@@ -38,12 +35,12 @@
         #keep all existing comment lines
         if line.startswith( '#' ):
             out.write( line )
-	#added for macs2 since there is an extra newline 
+    #added for macs2 since there is an extra newline 
         elif line.startswith( '\n' ):
             out.write( line )
         elif not wrote_header:
             out.write( '#%s' % line )
-	    print line
+            print line
             wrote_header = True
         else:
             fields = line.split( '\t' )
@@ -57,8 +54,8 @@
 #==========================================================================================
 def main():
     #take in options file and output file names
-    options = simplejson.load( open( sys.argv[1] ) )
-    outputs = simplejson.load( open( sys.argv[2] ) )
+    options = json.load( open( sys.argv[1] ) )
+    outputs = json.load( open( sys.argv[2] ) )
 
     #=================================================================================
     #parse options and execute macs2
@@ -71,26 +68,29 @@
 
     #=================================================================================
     if (options['command'] == "callpeak"):
-    	output_bed = outputs['output_bed_file']
-    	output_extra_html = outputs['output_extra_file']
-    	output_extra_path = outputs['output_extra_file_path']
-    	output_peaks =  outputs['output_peaks_file']
-   	output_narrowpeaks = outputs['output_narrowpeaks_file']    
-	output_xls_to_interval_peaks_file = outputs['output_xls_to_interval_peaks_file']
-	output_xls_to_interval_negative_peaks_file = outputs['output_xls_to_interval_negative_peaks_file']
+        output_bed = outputs['output_bed_file']
+        output_extra_html = outputs['output_extra_file']
+        output_extra_path = outputs['output_extra_file_path']
+        output_peaks =  outputs['output_peaks_file']
+    output_narrowpeaks = outputs['output_narrowpeaks_file']
+    output_xls_to_interval_peaks_file = outputs['output_xls_to_interval_peaks_file']
+    output_xls_to_interval_negative_peaks_file = outputs['output_xls_to_interval_negative_peaks_file']
 
-	if 'pvalue' in options:
-    		cmdline = "%s --format='%s' --name='%s' --gsize='%s' --bw='%s' --pvalue='%s' --mfold %s %s %s %s" % ( cmdline, options['format'], experiment_name, options['gsize'], options['bw'], options['pvalue'], options['mfoldlo'], options['mfoldhi'], options['nolambda'], options['bdg'] )
-	elif 'qvalue' in options:
-    		cmdline = "%s --format='%s' --name='%s' --gsize='%s' --bw='%s' --qvalue='%s' --mfold %s %s %s %s" % ( cmdline, options['format'], experiment_name, options['gsize'], options['bw'], options['qvalue'], options['mfoldlo'], options['mfoldhi'], options['nolambda'], options['bdg'] )
-		
-	if 'nomodel' in options:
-        	cmdline = "%s --nomodel --shiftsize='%s'" % ( cmdline, options['nomodel'] )
+    if 'pvalue' in options:
+        cmdline = "%s --format='%s' --name='%s' --gsize='%s' --bw='%s' --pvalue='%s' --mfold %s %s %s %s" % ( cmdline, options['format'], experiment_name, options['gsize'], options['bw'], options['pvalue'], options['mfoldlo'], options['mfoldhi'], options['nolambda'], options['bdg'] )
+    elif 'qvalue' in options:
+        cmdline = "%s --format='%s' --name='%s' --gsize='%s' --bw='%s' --qvalue='%s' --mfold %s %s %s %s" % ( cmdline, options['format'], experiment_name, options['gsize'], options['bw'], options['qvalue'], options['mfoldlo'], options['mfoldhi'], options['nolambda'], options['bdg'] )
+
+    if 'broad_cutoff' in options:
+        cmdline += " --broad --broad-cutoff=%s" % (options['broad_cutoff'])
+
+    if 'nomodel' in options:
+        cmdline = "%s --nomodel --shiftsize='%s'" % ( cmdline, options['nomodel'] )
     #=================================================================================
     if (options['command'] == "bdgcmp"):
-	output_bdgcmp = outputs['output_bdgcmp_file']
+        output_bdgcmp = outputs['output_bdgcmp_file']
 
-	cmdline = "%s -m %s -p %s -o bdgcmp_out.bdg" % ( cmdline, options['m'], options['pseudocount'] )
+        cmdline = "%s -m %s -p %s -o bdgcmp_out.bdg" % ( cmdline, options['m'], options['pseudocount'] )
     #=================================================================================
 
     tmp_dir = tempfile.mkdtemp() #macs makes very messy output, need to contain it into a temp dir, then provide to user
@@ -115,59 +115,59 @@
     #=================================================================================
     #move files generated by callpeak command 
     if (options['command'] == "callpeak"):
-    	#run R to create pdf from model script
-    	if os.path.exists( os.path.join( tmp_dir, "%s_model.r" % experiment_name ) ):
-     	   	cmdline = 'R --vanilla --slave < "%s_model.r" > "%s_model.r.log"' % ( experiment_name, experiment_name )
-     	   	proc = subprocess.Popen( args=cmdline, shell=True, cwd=tmp_dir )
-		proc.wait()
+        #run R to create pdf from model script
+        if os.path.exists( os.path.join( tmp_dir, "%s_model.r" % experiment_name ) ):
+            cmdline = 'R --vanilla --slave < "%s_model.r" > "%s_model.r.log"' % ( experiment_name, experiment_name )
+            proc = subprocess.Popen( args=cmdline, shell=True, cwd=tmp_dir )
+            proc.wait()
         
-    	#move bed out to proper output file
-    	created_bed_name =  os.path.join( tmp_dir, "%s_peaks.bed" % experiment_name )
-    	if os.path.exists( created_bed_name ):
-        	shutil.move( created_bed_name, output_bed )
+        #move bed out to proper output file
+        created_bed_name =  os.path.join( tmp_dir, "%s_peaks.bed" % experiment_name )
+        if os.path.exists( created_bed_name ):
+            shutil.move( created_bed_name, output_bed )
 
-    	#OICR peak_xls file
-    	created_peak_xls_file =  os.path.join( tmp_dir, "%s_peaks.xls" % experiment_name )
-    	if os.path.exists( created_peak_xls_file ):
-        	# shutil.copy( created_peak_xls_file, os.path.join ( "/mnt/galaxyData/tmp/", "%s_peaks.xls" % ( os.path.basename(output_extra_path) )))
-		shutil.copyfile( created_peak_xls_file, output_peaks )   
+        #OICR peak_xls file
+        created_peak_xls_file =  os.path.join( tmp_dir, "%s_peaks.xls" % experiment_name )
+        if os.path.exists( created_peak_xls_file ):
+            # shutil.copy( created_peak_xls_file, os.path.join ( "/mnt/galaxyData/tmp/", "%s_peaks.xls" % ( os.path.basename(output_extra_path) )))
+            shutil.copyfile( created_peak_xls_file, output_peaks )   
 
-    	#peaks.encodepeaks (narrowpeaks) file
-    	created_narrowpeak_file = os.path.join (tmp_dir, "%s_peaks.encodePeak" % experiment_name )
-    	if os.path.exists( created_narrowpeak_file ):
-		shutil.move (created_narrowpeak_file, output_narrowpeaks )
+        #peaks.encodepeaks (narrowpeaks) file
+        created_narrowpeak_file = os.path.join (tmp_dir, "%s_peaks.encodePeak" % experiment_name )
+        if os.path.exists( created_narrowpeak_file ):
+            shutil.move (created_narrowpeak_file, output_narrowpeaks )
 
- 	#parse xls files to interval files as needed
-   	#if 'xls_to_interval' in options:
-    	if (options['xls_to_interval'] == "True"):
-        	create_peak_xls_file = os.path.join( tmp_dir, '%s_peaks.xls' % experiment_name )
-        	if os.path.exists( create_peak_xls_file ):
-            		xls_to_interval( create_peak_xls_file, output_xls_to_interval_peaks_file, header = 'peaks file' )
-        	create_peak_xls_file = os.path.join( tmp_dir, '%s_negative_peaks.xls' % experiment_name )
-        	if os.path.exists( create_peak_xls_file ):
-			print "negative file exists"
-            		xls_to_interval( create_peak_xls_file, output_xls_to_interval_negative_peaks_file, header = 'negative peaks file' )
+    #parse xls files to interval files as needed
+    #if 'xls_to_interval' in options:
+        if (options['xls_to_interval'] == "True"):
+            create_peak_xls_file = os.path.join( tmp_dir, '%s_peaks.xls' % experiment_name )
+            if os.path.exists( create_peak_xls_file ):
+                xls_to_interval( create_peak_xls_file, output_xls_to_interval_peaks_file, header = 'peaks file' )
+            create_peak_xls_file = os.path.join( tmp_dir, '%s_negative_peaks.xls' % experiment_name )
+            if os.path.exists( create_peak_xls_file ):
+                print "negative file exists"
+                xls_to_interval( create_peak_xls_file, output_xls_to_interval_negative_peaks_file, header = 'negative peaks file' )
 
-    	#move all remaining files to extra files path of html file output to allow user download
-    	out_html = open( output_extra_html, 'wb' )
-    	out_html.write( '<html><head><title>Additional output created by MACS (%s)</title></head><body><h3>Additional Files:</h3><p><ul>\n' % experiment_name )
-    	os.mkdir( output_extra_path )
-    	for filename in sorted( os.listdir( tmp_dir ) ):
-    		shutil.move( os.path.join( tmp_dir, filename ), os.path.join( output_extra_path, filename ) )
-        	out_html.write( '<li><a href="%s">%s</a></li>\n' % ( filename, filename ) )
-		#out_html.write( '<li><a href="%s">%s</a>peakxls %s SomethingDifferent tmp_dir %s path %s exp_name %s</li>\n' % ( created_peak_xls_file, filename, filename, tmp_dir, output_extra_path, experiment_name ) )
-    	out_html.write( '</ul></p>\n' )
-    	out_html.write( '<h3>Messages from MACS:</h3>\n<p><pre>%s</pre></p>\n' % open( stderr_name, 'rb' ).read() )
-    	out_html.write( '</body></html>\n' )
-    	out_html.close()
+        #move all remaining files to extra files path of html file output to allow user download
+        out_html = open( output_extra_html, 'wb' )
+        out_html.write( '<html><head><title>Additional output created by MACS (%s)</title></head><body><h3>Additional Files:</h3><p><ul>\n' % experiment_name )
+        os.mkdir( output_extra_path )
+        for filename in sorted( os.listdir( tmp_dir ) ):
+            shutil.move( os.path.join( tmp_dir, filename ), os.path.join( output_extra_path, filename ) )
+            out_html.write( '<li><a href="%s">%s</a></li>\n' % ( filename, filename ) )
+            #out_html.write( '<li><a href="%s">%s</a>peakxls %s SomethingDifferent tmp_dir %s path %s exp_name %s</li>\n' % ( created_peak_xls_file, filename, filename, tmp_dir, output_extra_path, experiment_name ) )
+        out_html.write( '</ul></p>\n' )
+        out_html.write( '<h3>Messages from MACS:</h3>\n<p><pre>%s</pre></p>\n' % open( stderr_name, 'rb' ).read() )
+        out_html.write( '</body></html>\n' )
+        out_html.close()
 
     #=================================================================================
     #move files generated by bdgcmp command
     if (options['command'] == "bdgcmp"):
-    	created_bdgcmp_file = os.path.join (tmp_dir, "bdgcmp_out.bdg" )
-    	if os.path.exists( created_bdgcmp_file ):
-		shutil.move (created_bdgcmp_file, output_bdgcmp )
-     
+        created_bdgcmp_file = os.path.join (tmp_dir, "bdgcmp_out.bdg" )
+        if os.path.exists( created_bdgcmp_file ):
+            shutil.move (created_bdgcmp_file, output_bdgcmp )
+
     #=================================================================================    
     #cleanup
     #=================================================================================    
--- a/macs2_wrapper.xml	Thu Oct 17 12:47:49 2013 -0400
+++ b/macs2_wrapper.xml	Tue May 20 12:10:38 2014 -0400
@@ -1,6 +1,7 @@
 <tool id="macs2_peakcalling" name="MACS2" version="2.0.10">
   <description>Model-based Analysis of ChIP-Seq</description>
   <command interpreter="python">macs2_wrapper.py $options_file $outputs_file</command>
+  <version_command>macs2 --version</version_command>
   <inputs>
     <!--experiment name and option of selecting paired or single end will always be present-->
     <param name="experiment_name" type="text" value="MACS2 in Galaxy" size="50" label="Experiment Name"/>
@@ -8,53 +9,63 @@
     <!--select one of the 7 major commands offered by macs2-->
     <conditional name="major_command">
       <param name="major_command_selector" type="select" label="Select action to be performed">
-	<option value="callpeak">Peak Calling</option>
-	<!--<option value="filterdup">filterdup</option>
-	<option value="randsample">randsample</option>-->
-	<option value="bdgcmp">Compare .bdg Files</option>
-	<!--<option value="bdgdiff">bdgdiff</option>
-	<option value="bdgpeakcall">bdgpeakcall</option>
-	<option value="bdgbroadcall">bdgbroadcall</option>-->
+        <option value="callpeak">Peak Calling</option>
+        <!--<option value="filterdup">filterdup</option>
+        <option value="randsample">randsample</option>-->
+        <option value="bdgcmp">Compare .bdg Files</option>
+        <!--<option value="bdgdiff">bdgdiff</option>
+        <option value="bdgpeakcall">bdgpeakcall</option>
+        <option value="bdgbroadcall">bdgbroadcall</option>-->
       </param>
       <!--callpeak option of macs2-->
       <when value="callpeak">
-	<!--may need to add a few more formats at later time-->
+        <!--may need to add a few more formats at later time-->
         <param name="input_chipseq_file1" type="data" format="bam" label="ChIP-Seq Tag File" />
         <param name="input_control_file1" type="data" format="bam" optional="True" label="ChIP-Seq Control File" />
-	<param name="gsize" type="float" label="Effective genome size" value="2.7e+9" help="Human: 3.3e+9, Mouse: 3.0e+9, Fly: 1.9e+8, Worm: 1.3e+8 (--gsize)"/>
-	<param name="bw" type="integer" label="Band width" value="300" help="(--bw)"/>
-	<param name="xls_to_interval" label="Parse xls files into into distinct interval files" type="boolean" truevalue="True" falsevalue="False" checked="False"/>
-	<param name="bdg" label="Save fragment pileup, control lambda, -log10pvalue/qvalue in bedGraph" type="boolean" truevalue="-B" falsevalue="" checked="False" help="files located in html report"/>
+        <param name="gsize" type="float" label="Effective genome size" value="2.7e+9" help="Human: 3.3e+9, Mouse: 3.0e+9, Fly: 1.9e+8, Worm: 1.3e+8 (--gsize)"/>
+        <param name="bw" type="integer" label="Band width" value="300" help="(--bw)"/>
+        <param name="xls_to_interval" label="Parse xls files into into distinct interval files" type="boolean" truevalue="True" falsevalue="False" checked="False"/>
+        <param name="bdg" label="Save fragment pileup, control lambda, -log10pvalue/qvalue in bedGraph" type="boolean" truevalue="-B" falsevalue="" checked="False" help="files located in html report"/>
 
-	<conditional name="pq_options">
-	  <param name="pq_options_selector" type="select" label="Select p-value or q-value" help="default uses q-value">
-	    <option value="qvalue">q-value</option>
-	    <option value="pvalue">p-value</option>
-	  </param>
-	  <when value="pvalue">
-	    <param name="pvalue" type="float" label="p-value cutoff for peak detection" value="1e-2" help="default: 1e-2 (--pvalue)"/>
-	  </when>
-	  <when value="qvalue">
-	    <param name="qvalue" type="float" label="q-value cutoff for peak detection" value="5e-2" help="default: 5e-2 (--qvalue)"/>
-	  </when> 
-	</conditional>
-	<conditional name="advanced_options">
-	  <param name="advanced_options_selector" type="select" label="Display advanced options">
-	    <option value="off">Hide</option>
-	    <option value="on">Display</option>
-	  </param>
-	  <when value="on">
+        <conditional name="pq_options">
+          <param name="pq_options_selector" type="select" label="Select p-value or q-value" help="default uses q-value">
+            <option value="qvalue">q-value</option>
+            <option value="pvalue">p-value</option>
+          </param>
+          <when value="pvalue">
+            <param name="pvalue" type="float" label="p-value cutoff for peak detection" value="1e-2" help="default: 1e-2 (--pvalue)"/>
+          </when>
+          <when value="qvalue">
+            <param name="qvalue" type="float" label="q-value cutoff for peak detection" value="5e-2" help="default: 5e-2 (--qvalue)"/>
+          </when> 
+        </conditional>
+        <conditional name="advanced_options">
+          <param name="advanced_options_selector" type="select" label="Display advanced options">
+            <option value="off">Hide</option>
+            <option value="on">Display</option>
+          </param>
+          <when value="on">
             <param name="mfoldlo" type="integer" label="Select the regions with MFOLD high-confidence enrichment ratio against background to build model (lower-limit)" value="10" help="(--mfold)"/>
-	    <param name="mfoldhi" type="integer" label="Select the regions with MFOLD high-confidence enrichment ratio against background to build model (upper-limit)" value="30" help="(--mfold)"/>
-	    <param name="nolambda" label="Use fixed background lambda as local lambda for every peak region" type="boolean" truevalue="--nolambda" falsevalue="" checked="False" help="up to 9X more time consuming (--nolambda)"/>
-	  </when>
-	  <when value="off">
-	    <!--display nothing-->
-	  </when>
-	</conditional>
-    	<conditional name="nomodel_type">
+            <param name="mfoldhi" type="integer" label="Select the regions with MFOLD high-confidence enrichment ratio against background to build model (upper-limit)" value="30" help="(--mfold)"/>
+            <param name="nolambda" label="Use fixed background lambda as local lambda for every peak region" type="boolean" truevalue="--nolambda" falsevalue="" checked="False" help="up to 9X more time consuming (--nolambda)"/>
+            <conditional name="broad_options">
+              <param name="broad_options_selector" type="select" label="Composite broad regions" help="put nearby highly enriched regions into a broad region with loose cutoff (--broad)">
+                <option value="nobroad" selected="true">No broad regions</option>
+                <option value="broad">Broad regions</option>
+              </param>
+              <when value="broad">
+                <param name="broad_cutoff" type="float" label="Cutoff for broad region" value="0.1" help="value is either p-value or q-value as specified above (--broad-cutoff)"/>
+              </when>
+              <when value="nobroad"/>
+            </conditional>
+          </when>
+          <when value="off">
+            <!--display nothing-->
+          </when>
+        </conditional>
+        <conditional name="nomodel_type">
           <param name="nomodel_type_selector" type="select" label="Build Model">
-	   <option value="nomodel">Do not build the shifting model (--nomodel enabled)</option>
+           <option value="nomodel">Do not build the shifting model (--nomodel enabled)</option>
            <option value="create_model" selected="true">Build the shifting model (--nomodel disabled)</option>
           </param>
           <when value="nomodel">
@@ -67,18 +78,18 @@
       <when value="bdgcmp">
         <param name="input_chipseq_file1" type="data" format="bam" label="ChIP-Seq Tag File" />
         <param name="input_control_file1" type="data" format="bam" optional="True" label="ChIP-Seq Control File" />
-	<param name="pseudocount" type="float" label="Set pseudocount" value="0.00001" help="default: 0.00001 (-p)"/>
+        <param name="pseudocount" type="float" label="Set pseudocount" value="0.00001" help="default: 0.00001 (-p)"/>
 
         <conditional name="bdgcmp_options">
           <param name="bdgcmp_options_selector" type="select" label="Select action to be performed">
-	    <option value="ppois">ppois</option>
-	    <option value="qpois">qpois</option>
-	    <option value="subtract">subtract</option>
-	    <option value="logFE">logFE</option>
-	    <option value="FE">FE</option>
-	    <option value="logLR">logLR</option>
+            <option value="ppois">ppois</option>
+            <option value="qpois">qpois</option>
+            <option value="subtract">subtract</option>
+            <option value="logFE">logFE</option>
+            <option value="FE">FE</option>
+            <option value="logLR">logLR</option>
           </param>
-	</conditional>
+        </conditional>
       </when>
     </conditional>
   </inputs>
@@ -114,28 +125,28 @@
   <configfiles>
 
     <configfile name="outputs_file">&lt;%
-import simplejson
+import json
 %&gt;
 ##=======================================================================================
 #set $__outputs = { 'command':str( $major_command.major_command_selector ) }
 #if str( $major_command.major_command_selector ) == 'callpeak':
-	#set $__outputs['output_bed_file'] = str( $output_bed_file )
-	#set $__outputs['output_extra_file'] = str( $output_extra_files )
-	#set $__outputs['output_extra_file_path'] = str( $output_extra_files.files_path )
-	#set $__outputs['output_peaks_file'] = str( $output_peaks_file )
-	#set $__outputs['output_narrowpeaks_file'] = str( $output_narrowpeaks_file )
-	#set $__outputs['output_xls_to_interval_peaks_file'] = str( $output_xls_to_interval_peaks_file )
-	#set $__outputs['output_xls_to_interval_negative_peaks_file'] = str( $output_xls_to_interval_negative_peaks_file )
+    #set $__outputs['output_bed_file'] = str( $output_bed_file )
+    #set $__outputs['output_extra_file'] = str( $output_extra_files )
+    #set $__outputs['output_extra_file_path'] = str( $output_extra_files.files_path )
+    #set $__outputs['output_peaks_file'] = str( $output_peaks_file )
+    #set $__outputs['output_narrowpeaks_file'] = str( $output_narrowpeaks_file )
+    #set $__outputs['output_xls_to_interval_peaks_file'] = str( $output_xls_to_interval_peaks_file )
+    #set $__outputs['output_xls_to_interval_negative_peaks_file'] = str( $output_xls_to_interval_negative_peaks_file )
 #end if
 ##=======================================================================================
 #if str( $major_command.major_command_selector ) == 'bdgcmp':
-	#set $__outputs['output_bdgcmp_file'] = str( $output_bdgcmp_file )
+    #set $__outputs['output_bdgcmp_file'] = str( $output_bdgcmp_file )
 #end if
 
-${ simplejson.dumps( __outputs ) }
+${ json.dumps( __outputs ) }
     </configfile>
     <configfile name="options_file">&lt;%
-import simplejson
+import json
 %&gt;
 ##=======================================================================================
 #set $__options = { 'experiment_name':str( $experiment_name ) }
@@ -146,57 +157,60 @@
 ##control/input files
 #set $__options['input_control'] = []
 #if str( $major_command.input_control_file1 ) != 'None':
-	#set $_hole = __options['input_control'].append( str( $major_command.input_control_file1 ) )
+    #set $_hole = __options['input_control'].append( str( $major_command.input_control_file1 ) )
 #end if
 
 #if str( $major_command.major_command_selector ) == 'callpeak':
-	#set $__options['command'] = str( "callpeak" )
-	#set $__options['gsize'] = int( $major_command.gsize )
-	#set $__options['bw'] = str( $major_command.bw )
-	#set $__options['bdg'] = str( $major_command.bdg )
-	#set $__options['xls_to_interval'] = str( $major_command.xls_to_interval )
-
-	##advanced options
-	#if str( $major_command.advanced_options.advanced_options_selector ) == 'on':
-		#set $__options['mfoldlo'] = int( $major_command.advanced_options.mfoldlo )
-		#set $__options['mfoldhi'] = int( $major_command.advanced_options.mfoldhi )
-		#set $__options['nolambda'] = str( $major_command.advanced_options.nolambda )
-	#else:
-		#set $__options['mfoldlo'] = int( "10" )
-		#set $__options['mfoldhi'] = int( "30" )
-		#set $__options['nolambda'] = str( "" )		
-	#end if
+    #set $__options['command'] = str( "callpeak" )
+    #set $__options['gsize'] = int( $major_command.gsize )
+    #set $__options['bw'] = str( $major_command.bw )
+    #set $__options['bdg'] = str( $major_command.bdg )
+    #set $__options['xls_to_interval'] = str( $major_command.xls_to_interval )
 
-	##enable xls file options
-	##if str( $major_command.xls_to_interval ) == 'create':
-		##set $__options['xls_to_interval'] = { 'peaks_file': str( $output_xls_to_interval_peaks_file ), 'negative_peaks_file': str( $output_xls_to_interval_negative_peaks_file ) }
-	##end if
-	
-	##pq value select options
-	#if str( $major_command.pq_options.pq_options_selector ) == 'qvalue':
-		#set $__options['qvalue'] = str( $major_command.pq_options.qvalue )
-	#else:
-		#set $__options['pvalue'] = str( $major_command.pq_options.pvalue )
-	#end if
-	
-	##model options
-	#if str( $major_command.nomodel_type.nomodel_type_selector ) == 'nomodel':
-		#set $__options['nomodel'] = str( $major_command.nomodel_type.shiftsize )
-	#end if
+    ##advanced options
+    #if str( $major_command.advanced_options.advanced_options_selector ) == 'on':
+        #set $__options['mfoldlo'] = int( $major_command.advanced_options.mfoldlo )
+        #set $__options['mfoldhi'] = int( $major_command.advanced_options.mfoldhi )
+        #set $__options['nolambda'] = str( $major_command.advanced_options.nolambda )
+        #if str($major_command.advanced_options.broad_options.broad_options_selector) == 'broad'
+            #set $__options['broad_cutoff'] = str($major_command.advanced_options.broad_options.broad_cutoff)
+        #end if
+    #else:
+        #set $__options['mfoldlo'] = int( "10" )
+        #set $__options['mfoldhi'] = int( "30" )
+        #set $__options['nolambda'] = str( "" )
+    #end if
+
+    ##enable xls file options
+    ##if str( $major_command.xls_to_interval ) == 'create':
+        ##set $__options['xls_to_interval'] = { 'peaks_file': str( $output_xls_to_interval_peaks_file ), 'negative_peaks_file': str( $output_xls_to_interval_negative_peaks_file ) }
+    ##end if
+    
+    ##pq value select options
+    #if str( $major_command.pq_options.pq_options_selector ) == 'qvalue':
+        #set $__options['qvalue'] = str( $major_command.pq_options.qvalue )
+    #else:
+        #set $__options['pvalue'] = str( $major_command.pq_options.pvalue )
+    #end if
+    
+    ##model options
+    #if str( $major_command.nomodel_type.nomodel_type_selector ) == 'nomodel':
+        #set $__options['nomodel'] = str( $major_command.nomodel_type.shiftsize )
+    #end if
 #end if
 ##=======================================================================================
 #if str( $major_command.major_command_selector ) == 'bdgcmp':
-	#set $__options['command'] = str( "bdgcmp" )
-	#set $__options['pseudocount'] = float( str( $major_command.pseudocount ) )
-	#set $__options['m'] = str( $major_command.bdgcmp_options.bdgcmp_options_selector )
+    #set $__options['command'] = str( "bdgcmp" )
+    #set $__options['pseudocount'] = float( str( $major_command.pseudocount ) )
+    #set $__options['m'] = str( $major_command.bdgcmp_options.bdgcmp_options_selector )
 #end if
 ##=======================================================================================
 
-${ simplejson.dumps( __options ) }
+${ json.dumps( __options ) }
     </configfile>
   </configfiles>
   <tests>
-	<!--none yet for macs2-->
+        <!--none yet for macs2-->
   </tests>
   <help>
 **What it does**