diff microsatbed.xml @ 8:01c16e8fbc91 draft

planemo upload for repository https://github.com/fubar2/microsatbed commit 80a8c0db54b6e2cab9dfe7178b1e5b3b39592f2c-dirty
author fubar
date Tue, 13 Aug 2024 04:50:47 +0000
parents f27be15cc58d
children 57867d1931d6
line wrap: on
line diff
--- a/microsatbed.xml	Sun Jul 14 23:34:26 2024 +0000
+++ b/microsatbed.xml	Tue Aug 13 04:50:47 2024 +0000
@@ -1,186 +1,237 @@
-<tool name="STR to bed" id="microsatbed" version="1.3.0" profile="22.05">
-  <description>Short Tandem Repeats to bed features from fasta</description>
-  <requirements>
-    <requirement version="3.12.3" type="package">python</requirement>
-    <requirement version="2.1.0" type="package">pyfastx</requirement>
-    <requirement version="1.3.0" type="package">pytrf</requirement>
-  </requirements>
-   <required_files>
-      <include path="find_str.py"/>
-  </required_files>
-   <version_command><![CDATA[python -c "import pytrf; from importlib.metadata import version; print(version('pytrf'))"]]></version_command>
-  <command><![CDATA[
+
+<tool id="microsatbedfubar" name="STR to bed" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="22.05">
+    <description>Short Tandem Repeats to bed features from fasta</description>
+    <macros>
+        <token name="@TOOL_VERSION@">1.3.2</token>
+        <token name="@VERSION_SUFFIX@">0</token>
+        <token name="@PYTHON_VERSION@">3.12.3</token>
+        <macro name="subsetmacro">
+          <param name="subset" type="select" label="Select at least 1 specific motif length to report"
+              help="Bed features will be output for every motif of the selected length(s) with the minimum required repeats or more" multiple="true">
+              <option value="--di" selected="true">All dimers (AC,AG,AT,...)</option>
+              <option value="--tri">All trimers (ACG,..)</option>
+              <option value="--tetra">All tetramers (ACGT,..)</option>
+              <option value="--penta">All pentamers (ACGTC,..)</option>
+              <option value="--hexa">All hexamers (ACGTCG,..)</option>
+              <option value="--mono">All monomers (A,C...). Warning! Can produce overwhelming numbers of bed features</option>
+          </param>
+        </macro>
+    </macros>
+    <requirements>
+        <requirement version="@PYTHON_VERSION@" type="package">python</requirement>
+        <requirement version="2.1.0" type="package">pyfastx</requirement>
+        <requirement version="@TOOL_VERSION@" type="package">pytrf</requirement>
+        <requirement version="455" type="package">ucsc-bedgraphtobigwig</requirement>
+    </requirements>
+    <required_files>
+        <include path="find_str.py"/>
+    </required_files>
+    <version_command><![CDATA[python -c "import pytrf; from importlib.metadata import version; print(version('pytrf'))"]]></version_command>
+    <command><![CDATA[
   #if $mode_cond.mode == "NATIVE":
     #if $reference_genome.genome_type_select == "history":
-      pytrf findstr -f '$mode_cond.outformat' -o $bed -r $mode_cond.monomin $mode_cond.dimin $mode_cond.trimin $mode_cond.tetramin $mode_cond.pentamin $mode_cond.hexamin '${reference_genome.fasta}'
+      pytrf findstr -f '$mode_cond.outformat' -o '$bed' -r '$monomin' '$dimin' '$trimin' '$tetramin' '$pentamin' '$hexamin' '${reference_genome.fasta}'
     #else:
-      pytrf findstr -f '$mode_cond.outformat' -o $bed -r $mode_cond.monomin $mode_cond.dimin $mode_cond.trimin $mode_cond.tetramin $mode_cond.pentamin $mode_cond.hexamin '${reference_genome.fasta.fields.path}'
+      pytrf findstr -f '$mode_cond.outformat' -o '$bed' -r '$monomin' '$dimin' '$trimin' '$tetramin' '$pentamin' '$hexamin' '${reference_genome.fasta.fields.path}'
     #end if
   #else:
     python '${__tool_directory__}/find_str.py'
-    #if $reference_genome.genome_type_select == "history":
-      --fasta '${reference_genome.fasta}'
+    #if str($reference_genome.genome_type_select) == "history":
+        --fasta '${reference_genome.fasta}'
     #else:
-      --fasta '${reference_genome.fasta.fields.path}'
+        --fasta '${reference_genome.fasta.fields.path}'
     #end if
     --bed '$bed'
     #if $mode_cond.mode == "SPECIFIC":
-    --specific '$mode_cond.specific'
-    --minreps '$mode_cond.minreps'
+        --specific '$mode_cond.specific'
+    #elif $mode_cond.mode == "SPECIFICBW":
+        --bigwig
+        --winwidth '$mode_cond.winwidth'
+        --specific '$mode_cond.specific'
     #else:
-      #if "MONO" in $mode_cond.subset:
-      --mono
-      #end if
-      #if "DI" in $mode_cond.subset:
-      --di
-      #end if
-      #if "TRI" in $mode_cond.subset:
-      --tri
-      #end if
-      #if "TETRA" in $mode_cond.subset:
-      --tetra
-      #end if
-      #if "PENTA" in $mode_cond.subset:
-      --penta
-      #end if
-      #if "HEXA" in $mode_cond.subset:
-      --hexa
-      #end if
-      --monomin '$mode_cond.monomin'
-      --dimin '$mode_cond.dimin'
-      --trimin '$mode_cond.trimin'
-      --tetramin '$mode_cond.tetramin'
-      --pentamin '$mode_cond.pentamin'
-      --hexamin '$mode_cond.hexamin'
+      #for $flag in $mode_cond.subset:
+        $flag
+      #end for
+    #end if
+    --monomin '$monomin'
+    --dimin '$dimin'
+    --trimin '$trimin'
+    --tetramin '$tetramin'
+    --pentamin '$pentamin'
+    --hexamin '$hexamin'
+    #if $mode_cond.mode == "SPECIFICBW":
+        --bigwig
+        --winwidth '$mode_cond.winwidth'
     #end if
   #end if
 ]]></command>
-  <inputs>
-    <conditional name="reference_genome">
-        <param name="genome_type_select" type="select" label="Select a source for fasta sequences to be searched for STRs" help="Options are to choose a built-in genome, or choose any history fasta file">
-            <option value="indexed">Use a Galaxy server built-in reference genome fasta</option>
-            <option value="history" selected="True">Use any fasta file from the current history</option>
-        </param>
-        <when value="indexed">
-            <param name="fasta" type="select" multiple="false" label="Choose a built-in genome" 
-                help="If the genome you need is not on the list, upload it and select it as a current history fasta">
-                <options from_data_table="all_fasta"/>
+    <inputs>
+        <conditional name="reference_genome">
+            <param name="genome_type_select" type="select" label="Select a source for fasta sequences to be searched for STRs" help="Options are to choose a built-in genome, or choose any history fasta file">
+                <option value="indexed">Use a Galaxy server built-in reference genome fasta</option>
+                <option value="history" selected="True">Use any fasta file from the current history</option>
+            </param>
+            <when value="indexed">
+                <param name="fasta" type="select" label="Choose a built-in genome" help="If the genome you need is not on the list, upload it and select it as a current history fasta" >
+                    <options from_data_table="all_fasta"/>
+                </param>
+            </when>
+            <when value="history">
+                <param name="fasta" type="data" format="fasta,fasta.gz" label="Choose a fasta file from the current history" />
+            </when>
+        </conditional>
+        <conditional name="mode_cond">
+            <param name="mode" type="select" label="Select patterns by motif length; or provide a specific motif pattern to report?" help="Choose *By length:* or *By pattern:* to configure STR selection mode">
+                <option selected="True" value="ALL">By length: Report all motifs of one or more specified lengths (1-6nt) as bed features</option>
+                <option value="ALLBW">By length as windowed bigwig: Report all motifs of one or more specified lengths (1-6nt) as windowed density</option>
+                <option value="SPECIFIC">By motif: Report one or more specific motifs (such as TCA,GC) as bed features</option>
+                <option value="SPECIFICBW">By motif as windowed bigwig: Report one or more specific motifs (such as TCA,GC) as windowed density</option>
+                <option value="NATIVE">All exact STR: use the pytrf findstr native command to a create csv, tsv or gtf output</option>
             </param>
-        </when>
-        <when value="history">
-            <param name="fasta" type="data" format="fasta,fasta.gz" optional="false" multiple="false" label="Choose a fasta file from the current history"/>
-        </when>
-    </conditional>
-    <conditional name="mode_cond">
-    <param name="mode" type="select" label="Select patterns by motif length; or provide a specific motif pattern to report?" help="Choose *By length:* or *By pattern:* to configure STR selection mode">
-      <option selected="True" value="ALL">By length: Report all motifs of one or more specified lengths (1-6nt) as bed features</option>
-      <option value="SPECIFIC">By motif: Report one or more specific motifs (such as TCA,GC) as bed features</option>
-      <option value="NATIVE">All exact STR: use the pytrf findstr native command to a create csv, tsv or gtf output</option>
-    </param>
-    <when value="ALL">
-      <param name="subset" type="select" multiple="true" optional="false" label="Select at least 1 specific motif length to report" 
-        help="Bed features will be output for every motif of the selected length(s) with the minimum required repeats or more">
-        <option value="DI" selected="true">All dimers (AC,AG,AT,...)</option>
-        <option value="TRI">All trimers (ACG,..)</option>
-        <option value="TETRA">All tetramers (ACGT,..)</option>
-        <option value="PENTA">All pentamers (ACGTC,..)</option>
-        <option value="HEXA">All hexamers (ACGTCG,..)</option>
-        <option value="MONO">All monomers (A,C...). Warning! Can produce overwhelming numbers of bed features</option>
-      </param>
-      <param name="dimin" type="integer" value="2" min="1" label="Minimum number of repeats for dimers"/>
-      <param name="trimin" type="integer" value="2" min="2" label="Minimum number of repeats for trimers"/>
-      <param name="tetramin" type="integer" value="2" min="2" label="Minimum number of repeats for tetramers"/>
-      <param name="pentamin" type="integer" value="2" min="2" label="Minimum number of repeats for pentamers"/>
-      <param name="hexamin" type="integer" value="2" min="2" label="Minimum number of repeats for hexamers"/>
-      <param name="monomin" type="integer" value="2" min="2" label="Minimum number of repeats for monomers"/>
-    </when>
-    <when value="SPECIFIC">
-      <param name="specific" type="text" label="Supply a specific motif pattern. Separate multiple patterns with commas such as GA,GC" 
-         help="Make bed features only for the nominated specific motifs." optional="false"/>
-      <param name="minreps" type="integer" value="2" min="2" label="Minimum number of repeats of each of these motifs to report" 
-        help="Short tandem repeats require 2 or more consecutive motifs by definition. WARNING: If monomers are included, every single matching base will be reported as a STR if minimum repeats = 1!"
-        optional="false"/>
-    </when>
-    <when value="NATIVE">
-      <param name="outformat" type="select" optional="false" label="Select the required output format" 
-        help="Pytrf can create GFF, CSV or TSV output files. Documentation is linked in the help section below">
-        <option value="gff" >GFF</option>
-        <option value="csv">Comma separated values</option>
-        <option value="tsv" selected="true">Tab separated values</option>
-      </param>
-      <param name="monomin" type="integer" value="2" min="2" label="Minimum number of repeats for monomers"/>
-      <param name="dimin" type="integer" value="2" min="1" label="Minimum number of repeats for dimers"/>
-      <param name="trimin" type="integer" value="2" min="2" label="Minimum number of repeats for trimers"/>
-      <param name="tetramin" type="integer" value="2" min="2" label="Minimum number of repeats for tetramers"/>
-      <param name="pentamin" type="integer" value="2" min="2" label="Minimum number of repeats for pentamers"/>
-      <param name="hexamin" type="integer" value="2" min="2" label="Minimum number of repeats for hexamers"/>
-    </when>
-    </conditional>
-  </inputs>
-  <outputs>
-    <data name="bed" format="bed" label="STR from $fasta.element_identifier" hidden="false">
-      <change_format>
-            <when input="mode_cond.outformat" value="gff" format="gff" />
-            <when input="mode_cond.outformat" value="csv" format="csv" />
-            <when input="mode_cond.outformat" value="tsv" format="tabular" />
-      </change_format>
-    </data>
-  </outputs>
-  <tests>
-    <test expect_num_outputs="1">
-      <conditional name="reference_genome">
-          <param name="genome_type_select" value="history"/>
-          <param name="fasta" value="humsamp.fa"/>
-      </conditional>
-      <conditional name="mode_cond">
-          <param name="mode" value="ALL"/>
-          <param name="subset" value="DI,TRI,TETRA,PENTA,HEXA"/>
-          <param name="dimin" value="2"/>
-          <param name="trimin" value="2"/>
-          <param name="tetramin" value="2"/>
-          <param name="pentamin" value="2"/>
-          <param name="hexamin" value="2"/>
-      </conditional>
-      <output name="bed" value="bed_sample" compare="diff" lines_diff="0"/>
-    </test>    
-    <test expect_num_outputs="1">
-      <conditional name="reference_genome">
-          <param name="genome_type_select" value="history"/>
-          <param name="fasta" value="humsamp.fa"/>
-      </conditional>
-      <conditional name="mode_cond">
-          <param name="mode" value="SPECIFIC"/>
-          <param name="specific" value="GC"/>
-          <param name="minreps" value="2"/>
-      </conditional>
-      <output name="bed" value="dibed_sample" compare="diff" lines_diff="0"/>
-    </test>
-    <test expect_num_outputs="1">
-      <conditional name="reference_genome">
-          <param name="genome_type_select" value="history"/>
-          <param name="fasta" value="mouse.fa"/>
-      </conditional>
-      <conditional name="mode_cond">
-          <param name="mode" value="NATIVE"/>
-          <param name="outformat" value="gff"/>
-          <param name="monomin" value="20"/>
-          <param name="dimin" value="10"/>
-          <param name="trimin" value="5"/>
-          <param name="tetramin" value="4"/>
-          <param name="pentamin" value="4"/>
-          <param name="hexamin" value="2"/>
-      </conditional>
-      <output name="bed" value="nativegff_sample" compare="diff" lines_diff="0"/>
-    </test>
-  </tests>
-  <help><![CDATA[
+            <when value="ALL">
+              <expand macro="subsetmacro"/>
+            </when>
+            <when value="ALLBW">
+              <expand macro="subsetmacro"/>
+              <param name="winwidth" type="integer" min="5" value="128" label="Window with for estimating STR bigwig density"/>
+            </when>
+            <when value="SPECIFIC">
+              <param name="specific" type="text" label="Supply a specific motif pattern. Separate multiple patterns with commas such as GA,GC" help="Make bed features only for the nominated specific motifs."/>
+            </when>
+            <when value="SPECIFICBW">
+              <param name="specific" type="text" label="Supply a specific motif pattern. Separate multiple patterns with commas such as GA,GC" help="Make bed features only for the nominated specific motifs."/>
+              <param name="winwidth" type="integer" min="5" value="128" label="Window with for estimating STR bigwig density"/>
+            </when>
+            <when value="NATIVE">
+              <param name="outformat" type="select" label="Select the required output format" help="Pytrf can create GFF, CSV or TSV output files. Documentation is linked in the help section below">
+                <option value="gff">GFF</option>
+                <option value="csv">Comma separated values</option>
+                <option value="tsv" selected="true">Tab separated values</option>
+              </param>
+            </when>
+        </conditional>
+        <param name="monomin" type="integer" min="2" value="10" label="Minimum repeats required for monomers"/>
+        <param name="dimin" type="integer" min="1" value="3" label="Minimum repeats required for dimers"/>
+        <param name="trimin" type="integer" min="2" value="2" label="Minimum repeats required for trimers"/>
+        <param name="tetramin" type="integer" min="2" value="2" label="Minimum repeats required for tetramers"/>
+        <param name="pentamin" type="integer" min="2" value="2" label="Minimum repeats required for pentamers"/>
+        <param name="hexamin" type="integer" min="2" value="2" label="Minimum repeats required for hexamers"/>
+    </inputs>
+    <outputs>
+      <data name="bed" format="bed" label="STR from $fasta.element_identifier">
+        <change_format>
+            <when input="mode_cond.outformat" value="gff" format="gff"/>
+            <when input="mode_cond.outformat" value="csv" format="csv"/>
+            <when input="mode_cond.outformat" value="tsv" format="tabular"/>
+            <when input="mode_cond.mode" value="ALLBW" format="bigwig"/>
+            <when input="mode_cond.mode" value="SPECIFICBW" format="bigwig"/>
+        </change_format>
+      </data>
+    </outputs>
+    <tests>
+        <test expect_num_outputs="1">
+            <conditional name="reference_genome">
+                <param name="genome_type_select" value="history"/>
+                <param name="fasta" value="humsamp.fa"/>
+            </conditional>
+            <conditional name="mode_cond">
+                <param name="mode" value="ALL"/>
+                <param name="subset" value="--di,--tri,--tetra,--penta,--hexa"/>
+            </conditional>
+            <param name="monomin" value="20"/>
+            <param name="dimin" value="20"/>
+            <param name="trimin" value="5"/>
+            <param name="tetramin" value="5"/>
+            <param name="pentamin" value="3"/>
+            <param name="hexamin" value="2"/>
+            <output name="bed" value="bed_sample" compare="diff" lines_diff="0">
+              <assert_contents>
+                <has_n_columns n="5"/>
+                <has_text text="hpat1"/>
+                <has_text text="CCCCAC_2"/>
+                <has_text text="TTTTTT_2"/>
+              </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="reference_genome">
+                <param name="genome_type_select" value="history"/>
+                <param name="fasta" value="humsamp.fa"/>
+            </conditional>
+            <conditional name="mode_cond">
+                <param name="mode" value="SPECIFIC"/>
+                <param name="specific" value="GC"/>
+            </conditional>
+            <param name="monomin" value="20"/>
+            <param name="dimin" value="1"/>
+            <param name="trimin" value="20"/>
+            <param name="tetramin" value="20"/>
+            <param name="pentamin" value="20"/>
+            <param name="hexamin" value="20"/>
+            <output name="bed" value="dibed_sample" compare="diff" lines_diff="0">
+              <assert_contents>
+                <has_n_columns n="5"/>
+                <has_text text="hpat1"/>
+                <has_text text="GC_1"/>
+                <not_has_text text="TC_1"/>
+                <has_text text="209316"/>
+              </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="reference_genome">
+                <param name="genome_type_select" value="history"/>
+                <param name="fasta" value="mouse.fa"/>
+            </conditional>
+            <conditional name="mode_cond">
+                <param name="mode" value="NATIVE"/>
+                <param name="outformat" value="gff"/>
+            </conditional>
+            <param name="monomin" value="20"/>
+            <param name="dimin" value="10"/>
+            <param name="trimin" value="5"/>
+            <param name="tetramin" value="4"/>
+            <param name="pentamin" value="4"/>
+            <param name="hexamin" value="2"/>
+            <output name="bed" value="nativegff_sample" compare="diff" lines_diff="0">
+              <assert_contents>
+                <has_n_columns n="9"/>
+                <has_text text="Motif=CCGCCG;Type=6;Repeat=2;Length=12"/>
+                <has_text text="mm10_knownGene_uc008xda.1"/>
+                <has_text text="Motif=AGAGAG;Type=6;Repeat=2;Length=12"/>
+              </assert_contents>
+            </output>
+        </test>
+        <test expect_num_outputs="1">
+            <conditional name="reference_genome">
+                <param name="genome_type_select" value="history"/>
+                <param name="fasta" value="humsamp.fa"/>
+            </conditional>
+            <conditional name="mode_cond">
+                <param name="mode" value="SPECIFICBW"/>
+                <param name="specific" value="GC"/>
+            </conditional>
+            <param name="monomin" value="20"/>
+            <param name="dimin" value="1"/>
+            <param name="trimin" value="20"/>
+            <param name="tetramin" value="20"/>
+            <param name="pentamin" value="20"/>
+            <param name="hexamin" value="20"/>
+            <output name="bed" value="dibed_wig_sample" compare="sim_size" delta="10">
+              <assert_contents>
+                <has_size value="73544" delta="10" />
+              </assert_contents>
+            </output>
+        </test>
+    </tests>
+    <help><![CDATA[
 
- **Convert short repetitive sequences to bed features**
+ **Convert short repetitive sequences to bed features or windowed density bigwigs**
 
  Microsatellites are usually defined as repeated short DNA patterns in an unbroken sequence.
  A microsatellite pattern or *motif* can be any combination nucleotides, typically from 1 to 6nt in length.
  
- This tool allows microsatellite and related features to be selected from a fasta sequence input file, and output into a single bed track, suitable for viewing in a genome browser such as JBrowse2.
+ This tool allows microsatellite and related features to be selected from a fasta sequence input file, and output into a track, suitable for viewing in a genome browser such as JBrowse2.
 
  All motifs of selected lengths can be reported as individual features in the output bed file, or specific motifs can be provided and all 
  others will be ignored. In all cases, a minimum required number of repeats can be specified. For example, requiring 2 or more repeats of the trimer *ACG* will report 
@@ -193,17 +244,22 @@
  A fasta file must be supplied for processing. A built in genome can be selected, or a fasta file of any kind can be selected from the current history. Note that all 
  symbols are treated as valid nucleotides by pytrf, so extraneous characters such as *-* or *N* in the input fasta may appear as unexpected bed features. Lower case fasta symbols will be converted
  to uppercase, to prevent them being reported as distinct motifs.
-
+ 
+ Output can be bed format, or for two kinds of operation, a bigwig track showing bases covered by selected features over a configurable window size with a default of 128nt.
 
- **Select motifs by length**
+ **Select motifs by length - for bed or windowed density bigwig**
  
  The default tool form setting is to select all dimer motif patterns. 
  
- Additional motif lengths from 1 to 6nt can be selected in the multiple-select drop-down list. All features will be returned in a single bed file. For each selected motif length, 
- the minimum number of repeats required for reporting can be adjusted. **Tandem repeats** are defined as at least 2 of any pattern. This tool allows singleton motifs to be reported,
+ Any combination of motif lengths from 1 to 6nt can be selected in the multiple-select drop-down list. All features will be returned in a single bed file. For each selected motif length, 
+ the minimum number of repeats required for reporting can be adjusted. **Tandem repeats** are defined as at least 2 of any pattern. This tool allows singleton dimer motifs to be reported,
  so is not restricted to short tandem repeats (STR)
 
- **Select motifs by pattern**
+ This mode of operation can produce a bed file with every STR as a separate feature.
+ These can be very large and a bigwig containing the sum of STR bases over a selectable window size (default 128) may be more 
+ useful and much faster to load. 
+
+ **Select motifs by pattern - for bed or windowed density bigwig**
 
  This option allows a motif pattern to be specified as a text string such as *CG* or *ATC*. Multiple motifs can be specified as a comma separated string such as *CG,ATC*.
  All features will be returned as a single bed file.
@@ -212,7 +268,11 @@
 
  For example, technical sequencing read bias may be influenced by the density of specific dimers, whether they are repeated or not
  such as in https://github.com/arangrhie/T2T-Polish/tree/master/pattern
- 
+
+ This mode of operation can produce a bed file with every STR as a separate feature.
+ These can be very large and a bigwig containing the sum of STR bases over a selectable window size (default 128) may be more 
+ useful and much faster to load. 
+
  **Select all perfect STR using pytrf findstr in csv, tsv or gff output format**
 
 This selection runs the pytrf *findstr* option to create gff/csv/tsv outputs as described at the end of https://pytrf.readthedocs.io/en/latest/. 
@@ -226,12 +286,11 @@
    It also can find generic tandem repeats with any size of motif, such as with maximum motif length of 100 bp. Additionally, it has capability of finding approximate or imperfect tandem repeats*
  
   ]]></help>
-  <citations>
-    <citation type="bibtex">@misc{pytrf,
+    <citations>
+        <citation type="bibtex">@misc{pytrf,
   title = {{pytrf} Short tandem repeat finder, Accessed on July 10 2024},
   howpublished = {\url{https://github.com/lmdu/pytrf}},
   note = {Accessed on July 10 2024}
 }</citation>
-  </citations>
+    </citations>
 </tool>
-