Repository 'sicer'
hg clone https://toolshed.g2.bx.psu.edu/repos/devteam/sicer

Changeset 3:5c2cc3b58c7d (2020-10-28)
Previous changeset 2:74c9214cc8e6 (2018-10-24)
Commit message:
"planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/sicer commit 0cbb1b33c232da498a31902aa5afcdc97971a74b"
modified:
sicer_wrapper.py
sicer_wrapper.xml
b
diff -r 74c9214cc8e6 -r 5c2cc3b58c7d sicer_wrapper.py
--- a/sicer_wrapper.py Wed Oct 24 11:31:03 2018 -0400
+++ b/sicer_wrapper.py Wed Oct 28 23:36:25 2020 +0000
[
b'@@ -1,157 +1,158 @@\n #!/usr/bin/env python\n-#Dan Blankenberg\n+# Dan Blankenberg\n \n """\n A wrapper script for running SICER (spatial clustering approach for the identification of ChIP-enriched regions) region caller.\n """\n \n-import sys, optparse, os, tempfile, subprocess, shutil\n-\n-CHUNK_SIZE = 2**20 #1mb\n+import optparse\n+import os\n+import shutil\n+import subprocess\n+import sys\n+import tempfile\n \n-#HACK! FIXME: allow using all specified builds, would currently require hacking SICER\'s "GenomeData.py" on the fly.\n-VALID_BUILDS = [ \'mm8\', \'mm9\', \'hg18\', \'hg19\', \'dm2\', \'dm3\', \'sacCer1\', \'pombe\', \'rn4\', \'tair8\' ] \n+CHUNK_SIZE = 2**20  # 1mb\n \n-def cleanup_before_exit( tmp_dir ):\n-    if tmp_dir and os.path.exists( tmp_dir ):\n-        shutil.rmtree( tmp_dir )\n+# HACK! FIXME: allow using all specified builds, would currently require hacking SICER\'s "GenomeData.py" on the fly.\n+VALID_BUILDS = [\'mm8\', \'mm9\', \'hg18\', \'hg19\', \'dm2\', \'dm3\', \'sacCer1\', \'pombe\', \'rn4\', \'tair8\']\n \n \n-def open_file_from_option( filename, mode = \'rb\' ):\n+def cleanup_before_exit(tmp_dir):\n+    if tmp_dir and os.path.exists(tmp_dir):\n+        shutil.rmtree(tmp_dir)\n+\n+\n+def open_file_from_option(filename, mode=\'rb\'):\n     if filename:\n-        return open( filename, mode = mode )\n+        return open(filename, mode=mode)\n     return None\n \n-def add_one_to_file_column( filename, column, split_char = "\\t", startswith_skip = None ):\n-    tmp_out = tempfile.TemporaryFile( mode=\'w+b\' )\n-    tmp_in = open( filename )\n-    for line in tmp_in:\n-        if startswith_skip and line.startswith( startswith_skip ):\n-            tmp_out.write( line )\n-        else:\n-            fields = line.rstrip( \'\\n\\r\' ).split( split_char )\n-            if len( fields ) <= column:\n-                tmp_out.write( line )\n-            else:\n-                fields[ column ] = str( int( fields[ column ] ) + 1 )\n-                tmp_out.write( "%s\\n" % ( split_char.join( fields )  ) )\n-    tmp_in.close()\n-    tmp_out.seek( 0 )\n-    tmp_in = open( filename, \'wb\' )\n-    while True:\n-        chunk = tmp_out.read( CHUNK_SIZE )\n-        if chunk:\n-            tmp_in.write( chunk )\n-        else:\n-            break\n-    tmp_in.close()\n-    tmp_out.close()\n+\n+def add_one_to_file_column(filename, column, split_char="\\t", startswith_skip=None):\n+    with tempfile.NamedTemporaryFile(mode=\'w+b\', delete=False) as tmp_out:\n+        with open(filename) as fh:\n+            tmp_path = tmp_out.name\n+            for line in fh:\n+                if startswith_skip and line.startswith(startswith_skip):\n+                    tmp_out.write(line)\n+                else:\n+                    fields = line.rstrip(\'\\n\\r\').split(split_char)\n+                    if len(fields) <= column:\n+                        tmp_out.write(line)\n+                    else:\n+                        fields[column] = str(int(fields[column]) + 1)\n+                        tmp_out.write("%s\\n" % (split_char.join(fields)))\n+    shutil.move(tmp_path, filename)\n+\n \n def __main__():\n-    #Parse Command Line\n     parser = optparse.OptionParser()\n-    #stdout/err\n-    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.\' )\n-    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.\' )\n-    parser.add_option( \'\', \'--fix_off_by_one_errors\', dest=\'fix_off_by_one_errors\', action=\'store_true\', default=False, help=\'If specified, fix off-by-one errors in output files\' )\n-    #inputs\n-    parser.add_option( \'-b\', \'--bed_file\', dest=\'bed_file\', action=\'store\', type="string", default=None, help=\'Input ChIP BED file.\' )\n-    parser.add_option( \'-c\', \'--control_file\', dest=\'control_file\', action=\'store\', type="string", default=None, help=\'Input control BED file.\' )\n-    parser.add_option( \'-d\', \'--dbkey\', dest=\'dbkey\', action=\'store\', type="'..b'ns.window_size, options.gap_size, options.error_cut_off ) ), options.island_filtered_output_file )\n-            shutil.move(  os.path.join( tmp_dir,\'%s-W%i-G%i-FDR%s-islandfiltered-normalized.wig\' % ( bed_base_filename, options.window_size, options.gap_size, options.error_cut_off ) ), options.island_filtered_normalized_wig_output_file )\n+            shutil.move(os.path.join(tmp_dir, \'%s-%i-removed.bed\' % (control_base_filename, options.redundancy_threshold)), options.redundancy_removed_control_bed_output_file)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i.scoreisland\' % (bed_base_filename, options.window_size, options.gap_size)), options.score_island_output_file)\n+            if options.fix_off_by_one_errors:\n+                add_one_to_file_column(options.score_island_output_file, 2)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-islands-summary\' % (bed_base_filename, options.window_size, options.gap_size)), options.islands_summary_output_file)\n+            if options.fix_off_by_one_errors:\n+                add_one_to_file_column(options.islands_summary_output_file, 2)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-islands-summary-FDR%s\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.significant_islands_summary_output_file)\n+            if options.fix_off_by_one_errors:\n+                add_one_to_file_column(options.significant_islands_summary_output_file, 2)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-FDR%s-island.bed\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.significant_islands_output_file)\n+            if options.fix_off_by_one_errors:\n+                add_one_to_file_column(options.significant_islands_output_file, 2)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-FDR%s-islandfiltered.bed\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.island_filtered_output_file)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-FDR%s-islandfiltered-normalized.wig\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.island_filtered_normalized_wig_output_file)\n         else:\n-            shutil.move(  os.path.join( tmp_dir,\'%s-W%i-G%i-E%s.scoreisland\' % ( bed_base_filename, options.window_size, options.gap_size, options.error_cut_off ) ), options.score_island_output_file )\n-            if options.fix_off_by_one_errors: add_one_to_file_column( options.score_island_output_file, 2 )\n-            shutil.move(  os.path.join( tmp_dir,\'%s-W%i-G%i-E%s-islandfiltered.bed\' % ( bed_base_filename, options.window_size, options.gap_size, options.error_cut_off ) ), options.island_filtered_output_file )\n-            shutil.move(  os.path.join( tmp_dir,\'%s-W%i-G%i-E%s-islandfiltered-normalized.wig\' % ( bed_base_filename, options.window_size, options.gap_size, options.error_cut_off ) ), options.island_filtered_normalized_wig_output_file )\n-    except Exception, e:\n-        raise e\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-E%s.scoreisland\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.score_island_output_file)\n+            if options.fix_off_by_one_errors:\n+                add_one_to_file_column(options.score_island_output_file, 2)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-E%s-islandfiltered.bed\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.island_filtered_output_file)\n+            shutil.move(os.path.join(tmp_dir, \'%s-W%i-G%i-E%s-islandfiltered-normalized.wig\' % (bed_base_filename, options.window_size, options.gap_size, options.error_cut_off)), options.island_filtered_normalized_wig_output_file)\n     finally:\n-        cleanup_before_exit( tmp_dir )\n+        cleanup_before_exit(tmp_dir)\n+\n \n-if __name__=="__main__": __main__()\n+if __name__ == "__main__":\n+    __main__()\n'
b
diff -r 74c9214cc8e6 -r 5c2cc3b58c7d sicer_wrapper.xml
--- a/sicer_wrapper.xml Wed Oct 24 11:31:03 2018 -0400
+++ b/sicer_wrapper.xml Wed Oct 28 23:36:25 2020 +0000
[
b'@@ -1,155 +1,159 @@\n-<tool id="peakcalling_sicer" name="SICER" version="0.0.2">\n-  <description>Statistical approach for the Identification of ChIP-Enriched Regions</description>\n-  <command interpreter="python">sicer_wrapper.py \n-  --bed_file \'${input_bed_file}\' \n-  #if str( $input_control_file ) != \'None\':\n-      --control_file \'${input_control_file}\'\n-      --significant_islands_output_file "${significant_islands_output_file}"\n-      --islands_summary_output_file "${islands_summary_output_file}"\n-      --significant_islands_summary_output_file "${significant_islands_summary_output_file}"\n-  #end if\n-  ${fix_off_by_one_errors}\n-  --dbkey \'${input_bed_file.dbkey}\'\n-  --redundancy_threshold \'${redundancy_threshold}\'\n-  --window_size \'${window_size}\'\n-  --fragment_size \'${fragment_size}\'\n-  --effective_genome_fraction \'${effective_genome_fraction}\'\n-  --gap_size \'${gap_size}\'\n-  --error_cut_off \'${error_cut_off}\'\n-  ##output files\n-  --stdout "${output_log_file}"\n-  --redundancy_removed_test_bed_output_file "${redundancy_removed_test_bed_output_file}"\n-  --redundancy_removed_control_bed_output_file "${redundancy_removed_control_bed_output_file}"\n-  --score_island_output_file "${score_island_output_file}"\n-  --summary_graph_output_file "${summary_graph_output_file}"\n-  --test_normalized_wig_output_file "${test_normalized_wig_output_file}"\n-  --island_filtered_output_file "${island_filtered_output_file}"\n-  --island_filtered_normalized_wig_output_file "${island_filtered_normalized_wig_output_file}"\n-  </command>\n-  <requirements>\n-    <requirement type="package" version="1.1">SICER</requirement>\n-  </requirements>\n-  <inputs>\n-    <param name="input_bed_file" type="data" format="bed" label="ChIP-Seq Tag File" >\n-      <validator type="expression" message="SICER is not available for the genome.">value is not None and value.dbkey in [ \'mm8\', \'mm9\', \'hg18\', \'hg19\', \'dm2\', \'dm3\', \'sacCer1\', \'pombe\', \'rn4\', \'tair8\' ]</validator>\n-    </param>\n-    <param name="input_control_file" type="data" format="bed" label="ChIP-Seq Control File" optional="True"> <!-- fix me, add filter to match dbkeys -->\n-      <options>\n-        <filter type="data_meta" ref="input_bed_file" key="dbkey" />\n-      </options>\n-    </param>\n-    <param name="fix_off_by_one_errors" type="boolean" truevalue="--fix_off_by_one_errors" falsevalue="" checked="True" label="Fix off-by-one errors in output files" help="SICER creates non-standard output files, this option will fix these coordinates"/> \n-    <param name="redundancy_threshold" type="integer" label="Redundancy Threshold" value="1" help="The number of copies of identical reads allowed in a library" />\n-    <param name="window_size" type="integer" label="Window size" value="200" help="Resolution of SICER algorithm. For histone modifications, one can use 200 bp" />\n-    <param name="fragment_size" type="integer" label="Fragment size" value="150" help="for determination of the amount of shift from the beginning of a read to the center of the DNA fragment represented by the read. FRAGMENT_SIZE=150 means the shift is 75." />\n-    <param name="effective_genome_fraction" type="float" label="Effective genome fraction" value="0.74" help="Effective Genome as fraction of the genome size. It depends on read length." />\n-    <param name="gap_size" type="integer" label="Gap size" value="600" help="Needs to be multiples of window size. Namely if the window size is 200, the gap size should be 0, 200, 400, 600, ..." />\n-    <param name="error_cut_off" type="float" label="Statistic threshold value" value="0.01" help="FDR (with control) or E-value (without control)" />\n-  </inputs>\n-  <outputs>\n-    <data name="redundancy_removed_test_bed_output_file" format="bed" label="${tool.name} on ${on_string} (test-${redundancy_threshold}-removed.bed)"/>\n-    <data name="redundancy_removed_control_bed_output_file" format="bed" label="${tool.name} on ${on_string} (control-${redundancy_threshold}-removed.bed)">\n-      <filter>input_control_f'..b'-W200-G600.scoreisland" />\n+            <output name="islands_summary_output_file" file="test_2_test-W200-G600-islands-summary" />\n+            <output name="significant_islands_summary_output_file" file="test_2_test-W200-G600-islands-summary-FDR0.01" />\n+            <output name="output_log_file" file="test_2_output_log_file.contains" compare="contains"/>\n+        </test>\n+        <test>\n+            <param name="input_bed_file" value="chipseq_enriched.bed.gz" ftype="bed" dbkey="mm8" />\n+            <param name="input_control_file" value="chipseq_input.bed.gz" ftype="bed" dbkey="mm8" />\n+            <param name="fix_off_by_one_errors" value="True" />\n+            <param name="redundancy_threshold" value="1" />\n+            <param name="window_size" value="200" />\n+            <param name="fragment_size" value="150" />\n+            <param name="effective_genome_fraction" value="0.74" />\n+            <param name="gap_size" value="600" />\n+            <param name="error_cut_off" value="0.01" />\n+            <output name="redundancy_removed_test_bed_output_file" file="test-1-removed.bed" />\n+            <output name="redundancy_removed_control_bed_output_file" file="control-1-removed.bed" />\n+            <output name="summary_graph_output_file" file="test_3_test-W200.graph" />\n+            <output name="test_normalized_wig_output_file" file="test-W200-normalized.wig" />\n+            <output name="significant_islands_output_file" file="test_3_test-W200-G600-FDR0.01-island.bed" />\n+            <output name="island_filtered_output_file" file="test-W200-G600-FDR0.01-islandfiltered.bed" />\n+            <output name="island_filtered_normalized_wig_output_file" file="test-W200-G600-FDR0.01-islandfiltered-normalized.wig" />\n+            <output name="score_island_output_file" file="test_3_test-W200-G600.scoreisland" />\n+            <output name="islands_summary_output_file" file="test_3_test-W200-G600-islands-summary" />\n+            <output name="significant_islands_summary_output_file" file="test_3_test-W200-G600-islands-summary-FDR0.01" />\n+            <output name="output_log_file" file="test_2_output_log_file.contains" compare="contains"/>\n+        </test>\n+        <test>\n+            <param name="input_bed_file" value="chipseq_enriched.bed.gz" ftype="bed" dbkey="mm8" />\n+            <param name="input_control_file" />\n+            <param name="fix_off_by_one_errors" value="True" />\n+            <param name="redundancy_threshold" value="1" />\n+            <param name="window_size" value="200" />\n+            <param name="fragment_size" value="150" />\n+            <param name="effective_genome_fraction" value="0.74" />\n+            <param name="gap_size" value="600" />\n+            <param name="error_cut_off" value="0.01" />\n+            <output name="redundancy_removed_test_bed_output_file" file="test-1-removed.bed" />\n+            <output name="summary_graph_output_file" file="test_3_test-W200.graph" />\n+            <output name="test_normalized_wig_output_file" file="test-W200-normalized.wig" />\n+            <output name="island_filtered_output_file" file="test-W200-G600-E0.01-islandfiltered.bed" />\n+            <output name="island_filtered_normalized_wig_output_file" file="test-W200-G600-E0.01-islandfiltered-normalized.wig" />\n+            <output name="score_island_output_file" file="test_4_test-W200-G600-E0.01.scoreisland" />\n+            <output name="output_log_file" file="test_1_output_log_file.contains" compare="contains"/>\n+        </test>\n+    </tests>\n+    <help><![CDATA[\n **What it does**\n \n SICER first and foremost is a filtering tool. Its main functions are::\n@@ -170,9 +174,8 @@\n \n **Citation**\n If you use this tool in Galaxy, please cite Blankenberg D, et al. *In preparation.*\n-\n-  </help>\n-  <citations>\n-    <citation type="doi">10.1093/bioinformatics/btp340</citation>\n-  </citations>\n+    ]]></help>\n+    <citations>\n+        <citation type="doi">10.1093/bioinformatics/btp340</citation>\n+    </citations>\n </tool>\n'