Repository 'msp_sr_readmap_and_size_histograms'
hg clone https://toolshed.g2.bx.psu.edu/repos/drosofff/msp_sr_readmap_and_size_histograms

Changeset 2:ebfc73c72652 (2016-02-03)
Previous changeset 1:e4874d1ae69d (2015-11-26) Next changeset 3:9b62e6b0d219 (2016-02-03)
Commit message:
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit c9ca5272028c778ad137601e75ddbea3459d9a05-dirty
modified:
readmap.py
readmap.xml
smRtools.pyc
tool_dependencies.xml
b
diff -r e4874d1ae69d -r ebfc73c72652 readmap.py
--- a/readmap.py Thu Nov 26 11:56:07 2015 -0500
+++ b/readmap.py Wed Feb 03 09:20:34 2016 -0500
[
@@ -66,6 +66,35 @@
       filtered_list.append(line) 
   return filtered_list
 
+
+def listify_plottable_item(item):
+  """
+  plottable is a list of strings:
+  'FBti0020401\t78\t-1.0\tR'
+  split on tab and return gene, coordinate, count and orientation
+  """
+  gene, coordinate, count, orientation = item.split("\t")
+  return gene, coordinate, count, orientation
+
+def lookup_gene_length(gene, readDict):
+  return readDict[readDict.keys()[0]].instanceDict["size"]
+
+def handle_start_stop_coordinates(plottable, readDict):
+  """
+  To ensure that the plot area always includes the correct start and end coordinates,
+  we add an entry at start [coordinate 0] and end [last coordinate] of count 0, if these do not exist.
+  """
+  first_line = plottable[0]
+  last_line = plottable[-1]
+  gene, coordinate, count, orientation = listify_plottable_item(first_line)
+  if not coordinate == "0":
+    new_line = "\t".join([gene, "0", "0", "F"])
+    plottable = new_line + plottable
+  gene_length = str(lookup_gene_length(gene, readDict))
+  if not coordinate == gene_length:
+    last_line = "\t".join([gene, gene_length, "0", "F"])
+    plottable = plottable + last_line
+
 def write_readplot_dataframe(readDict, readmap_file):
   listoflines = []
   with open(readmap_file, 'w') as readmap:
@@ -77,6 +106,7 @@
         dict=readDict[sample].instanceDict
       for gene in dict.keys():
         plottable = dict[gene].readplot()
+        handle_start_stop_coordinates(plottable, readDict)
         for line in plottable:
           #print >>readmap, "%s\t%s" % (line, sample)
           listoflines.append ("%s\t%s" % (line, sample))
b
diff -r e4874d1ae69d -r ebfc73c72652 readmap.xml
--- a/readmap.xml Thu Nov 26 11:56:07 2015 -0500
+++ b/readmap.xml Wed Feb 03 09:20:34 2016 -0500
[
@@ -1,4 +1,4 @@
-<tool id="Readmap" name="Generate readmap and histograms from alignment files" version="1.0.5">
+<tool id="Readmap" name="Generate readmap and histograms from alignment files" version="1.1.2">
   <description>from sRbowtie aligment</description>
   <requirements>
         <requirement type="package" version="0.12.7">bowtie</requirement>
@@ -78,6 +78,7 @@
                 <param name="title" type="text" size="15" value= "Readmaps and size distributions" label="Main Titles"/>
                 <param name="xlabel" type="text" size="15" value="Coordinates/read size" label="x axis label"/>
                 <param name="ylabel" type="text" size="15" value="Number of reads" label="y axis label"/>
+                <param name="yrange" type="integer" size="3" value="0" label="y axis range for readmaps. 0 means auto-scaling."/>
                 <param name="rows_per_page" type="text" size="9" value="8" label="How many items to display per page?">
    <validator type="in_range" min="6" max="20" message="Select between 6 and 20 rows, as the readability will suffer otherwise."/>
                 </param>
@@ -167,7 +168,8 @@
         start=i
         end=i+rows_per_page-1
         if (end>n_genes) {end=n_genes}
-        readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap))
+        if (${yrange} == 0) { readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) } else {
+        readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, ylim=c(-${yrange}, ${yrange}) , par.settings=par.settings.readmap)) }
         args.list=c(readmap_plot.list, list(nrow=rows_per_page, ncol=1,
                                             main=textGrob("Read Maps (nucleotide coordinates)", gp=gpar(cex=1), just="top"),
                                             left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90)
@@ -200,9 +202,10 @@
         start=i
         end=i+rows_per_page/2-1
         if (end>n_genes) {end=n_genes}
- read_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.combination.readmap))
+        if (${yrange} == 0) {readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, par.settings=par.settings.readmap)) } else {
+        readmap_plot.list=lapply(per_gene_readmap[start:end], function(x) plot_readmap(x, ylim=c(-${yrange}, ${yrange}), par.settings=par.settings.readmap)) }
         size_plot.list=lapply(per_gene_size[start:end], function(x) plot_size_distribution(x, strip=FALSE, par.settings=par.settings.combination.size))
- plot.list=rbind(read_plot.list, size_plot.list )
+ plot.list=rbind(readmap_plot.list, size_plot.list )
         args.list=c(plot.list, list(nrow=rows_per_page + extrarow, ncol=1,
                                     main=textGrob("${title}", gp=gpar(cex=1), just="top"),
                                     left=textGrob("${ylabel}", gp=gpar(cex=1), vjust=1, rot=90),
b
diff -r e4874d1ae69d -r ebfc73c72652 smRtools.pyc
b
Binary file smRtools.pyc has changed
b
diff -r e4874d1ae69d -r ebfc73c72652 tool_dependencies.xml
--- a/tool_dependencies.xml Thu Nov 26 11:56:07 2015 -0500
+++ b/tool_dependencies.xml Wed Feb 03 09:20:34 2016 -0500
b
@@ -7,7 +7,7 @@
       <repository changeset_revision="0a5141bdf9d0" name="package_pysam_0_7_7" owner="iuc" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
     <package name="numpy" version="1.9">
-        <repository changeset_revision="9cc1138e5e3e" name="package_numpy_1_9" owner="iuc" prior_installation_required="True" toolshed="https://toolshed.g2.bx.psu.edu" />
+        <repository changeset_revision="c8f7a7d73466" name="package_numpy_1_9" owner="iuc" prior_installation_required="True" toolshed="https://toolshed.g2.bx.psu.edu" />
     </package>
     <package name="R" version="3.1.2">
         <repository changeset_revision="c987143177d4" name="package_r_3_1_2" owner="iuc" prior_installation_required="True" toolshed="https://toolshed.g2.bx.psu.edu" />