]> git.donarmstrong.com Git - biopieces.git/commitdiff
added nucleotide plot to QA_454_report
authormartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 30 Aug 2012 12:09:53 +0000 (12:09 +0000)
committermartinahansen <martinahansen@74ccb610-7750-0410-82ae-013aeee3265d>
Thu, 30 Aug 2012 12:09:53 +0000 (12:09 +0000)
git-svn-id: http://biopieces.googlecode.com/svn/trunk@1905 74ccb610-7750-0410-82ae-013aeee3265d

bp_scripts/QA_454_report.rb

index 37da5beb30a81655b4f3bf1a6275ccfc70b874cf..362c728289c406fea726167ee470a25578ec7650 100755 (executable)
@@ -31,7 +31,6 @@ class Report
     @seq_analysis   = SeqAnalyze.new(@sff_file, tmpdir)
     @plots          = PlotData.new(@sff_file, tmpdir)
     @table_mid_join = MidTable.new(@sff_file, tmpdir)
-    @table_freq     = FreqTable.new(@sff_file, tmpdir)
   end
 
   # Support templating of member data.
@@ -108,7 +107,7 @@ class Report
   end
 
   class PlotData
-    attr_reader :lendist_unclipped, :lendist_clipped, :scores_unclipped, :scores_clipped, :mean_scores
+    attr_reader :lendist_unclipped, :lendist_clipped, :scores_unclipped, :scores_clipped, :mean_scores, :nucleotide_dist
 
     def initialize(sff_file, tmpdir)
       @sff_file = sff_file
@@ -117,6 +116,7 @@ class Report
       @plot3    = File.join(tmpdir, "plot3.png")
       @plot4    = File.join(tmpdir, "plot4.png")
       @plot5    = File.join(tmpdir, "plot5.png")
+      @plot6    = File.join(tmpdir, "plot6.png")
 
       bp_plot
 
@@ -125,6 +125,7 @@ class Report
       @scores_unclipped  = png2base64(@plot2)
       @scores_clipped    = png2base64(@plot4)
       @mean_scores       = png2base64(@plot5)
+      @nucleotide_dist   = png2base64(@plot6)
     end
 
     def bp_plot
@@ -139,7 +140,9 @@ class Report
          plot_scores -c -T 'Mean Quality Scores - clipped' -t png -o #{@plot4} |
          mean_scores |
          bin_vals -k SCORES_MEAN -b 5 |
-         plot_histogram -s num -k SCORES_MEAN_BIN -T 'Mean score bins' -X 'Bins (size 5)' -Y 'Count' -t png -o #{@plot5} -x"
+         plot_histogram -s num -k SCORES_MEAN_BIN -T 'Mean score bins' -X 'Bins (size 5)' -Y 'Count' -t png -o #{@plot5} |
+         extract_seq -l 50 |
+         plot_nucleotide_distribution -t png -o #{@plot6} -x"
       )
       STDERR.puts "done.\n"
     end
@@ -247,52 +250,6 @@ class Report
       end
     end
   end
-
-  class FreqTable
-    def initialize(sff_file, tmpdir)
-      @sff_file = sff_file
-      @tab_file = File.join(tmpdir, "freq.tab")
-
-      bp_frequency_table
-    end
-
-    def each
-      File.open(@tab_file, "r") do |ios|
-        while not ios.eof? do
-          fields = ios.readline.chomp.split("\t")
-          yield FreqRow.new(fields[0], fields[1], fields[2], fields[3], fields[4])
-        end
-      end
-    end
-
-    private
-
-    def bp_frequency_table
-      STDERR.puts "Creating residue frequency table ... "
-      system(
-        "read_sff -i #{@sff_file} |
-         progress_meter |
-         extract_seq -l 50 |
-         uppercase_seq |
-         create_weight_matrix -p |
-         flip_tab |
-         write_tab -o #{@tab_file} -x"
-      )
-      STDERR.puts "done.\n"
-    end
-
-    class FreqRow
-      attr_reader :res_A, :res_C, :res_G, :res_N, :res_T
-
-      def initialize(res_A, res_C, res_G, res_N, res_T)
-        @res_A = res_A
-        @res_C = res_C
-        @res_G = res_G
-        @res_N = res_N
-        @res_T = res_T
-      end
-    end
-  end
 end
 
 template = %{
@@ -348,18 +305,8 @@ template = %{
       <% end %>
       </table>
       <h2>Residue frequency analysis</h2>
-      <p>The below table contains the residue frequency (in percent) of the first 50 bases:</p>
-      <table>
-      <% @table_freq.each do |row| %>
-        <tr>
-        <td><%= row.res_A %></td>
-        <td><%= row.res_T %></td>
-        <td><%= row.res_C %></td>
-        <td><%= row.res_G %></td>
-        <td><%= row.res_N %></td>
-        </tr>
-      <% end %>
-      </table>
+      <p>Plot of nucleotide distribution in percent of the first 50 bases:</p>
+      <p><img alt="plot_nucleotide_distribution" src="<%= @plots.nucleotide_dist %>" width="600" /></p>
     </body>
   </html>
 }.gsub(/^\s+/, '')