# HG changeset patch # User mvdbeek # Date 1454509234 18000 # Node ID ebfc73c72652b662953fffac8314d58c0686a55c # Parent e4874d1ae69dffb884e1359c68d1929361d9e3f3 planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/master/tools/msp_sr_readmap_and_size_histograms commit c9ca5272028c778ad137601e75ddbea3459d9a05-dirty 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)) 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 @@ - + from sRbowtie aligment bowtie @@ -78,6 +78,7 @@ + @@ -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), diff -r e4874d1ae69d -r ebfc73c72652 smRtools.pyc Binary file smRtools.pyc has changed 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 @@ -7,7 +7,7 @@ - +