determinations_comparison 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- determinations_comparison (1.0.1)
4
+ determinations_comparison (2.0.0)
5
5
  htmlentities
6
6
  uuidtools
7
7
 
@@ -7,6 +7,7 @@ require 'uuidtools'
7
7
  require 'htmlentities/encoder'
8
8
  require 'html_table_of_property_differences'
9
9
  require 'html_table_of_peak_picking_log'
10
+ require 'jquery_tabs'
10
11
  require 'exe_comparedeterminations'
11
12
 
12
13
  LIB_FOLDER = File.dirname(__FILE__)
@@ -51,76 +52,99 @@ module DeterminationsComparison
51
52
  baseline_filepath = File.join folderpath_output, "#{@uuid}_baseline.json"
52
53
  undertest_filepath = File.join folderpath_output, "#{@uuid}_undertest.json"
53
54
 
54
- @plotter = Exe_CompareDeterminations.new @filepath_baseline_origin, @filepath_undertest_origin, @filepath_comparedeterminations
55
-
56
55
  # these are necessary for cpplogreader
57
56
  @sample_index = hashCompoundBaseLine['Sample_Index']
58
57
  @analyte_name = hashCompoundBaseLine['Analyte']
59
58
 
60
-
61
- str = ""
62
- arr = Array.new
63
-
64
59
  begin
65
- coder = HTMLEntities.new
66
- retcodePNG,rundetailsPNG = @plotter.generate_png png_filepath
60
+
61
+ #coder = HTMLEntities.new
67
62
 
68
63
  FileUtils.copy_file @filepath_baseline_origin, baseline_filepath
69
64
  FileUtils.copy_file @filepath_undertest_origin, undertest_filepath
70
65
 
71
- str += "<p>baseline file: <a href=#{File.basename(baseline_filepath)}>#{File.basename(@filepath_baseline_origin)}</a></p>"
72
- str += "<p>undertest file: <a href=#{File.basename(undertest_filepath)}>#{File.basename(@filepath_undertest_origin)}</a></p>"
66
+ # html for file links
67
+ strFiles = "<p>baseline file: <a href=#{File.basename(baseline_filepath)}>#{File.basename(@filepath_baseline_origin)}</a></p>"
68
+ strFiles += "<p>undertest file: <a href=#{File.basename(undertest_filepath)}>#{File.basename(@filepath_undertest_origin)}</a></p>"
73
69
 
74
- if retcodePNG
75
- str += "<p><p><p><img src='#{File.basename(png_filepath)}' alt='chromatogram' height='500' width='800' align='top'></p>"
76
- end
70
+ # html for plot
71
+ strPlot = nil
72
+ @plotter = Exe_CompareDeterminations.new @filepath_baseline_origin, @filepath_undertest_origin, @filepath_comparedeterminations
73
+ retcodePNG,rundetailsPNG = @plotter.generate_png png_filepath
74
+ if retcodePNG
75
+ strPlot = "<img src='#{File.basename(png_filepath)}' alt='chromatogram' height='500' width='800' align='top'>"
76
+ end
77
77
 
78
- @hashDiffs.each_pair do |k,v|
78
+ # html for peak picking logs
79
+ hashChromHTML = Hash.new
79
80
 
80
- chrom_type = k
81
+ @hashDiffs.each_pair do |k,v|
81
82
 
82
- v.each_pair do |k,v|
83
- if k == 'peak'
84
- v.each_pair do |k,v|
85
- arr << property_diff_to_hash(chrom_type,k,v)
86
- end
87
- else
88
- unless k == 'peak_picked'
89
- arr << property_diff_to_hash(chrom_type,k,v)
83
+ chrom_type = k
84
+
85
+ ht = HTML_Table_of_Peak_Picking_Log.new(@folderpath_with_log,@sample_index,@analyte_name,k)
86
+ str_pp = ht.render
87
+ unless str_pp.nil?
88
+
89
+ peak_picked = "unknown"
90
+ arrPP = v.select { |h| h['peak_picked'] }
91
+ unless arrPP.empty?
92
+ peak_picked = "#{arrPP.first[0]} #{arrPP.first[1]}"
90
93
  end
94
+
95
+ strChrom = "<p><b>#{chrom_type}</b> - #{peak_picked}</p>"
96
+ strChrom += str_pp
91
97
  end
92
98
 
93
- end
99
+ hashChromHTML[k] = strChrom
94
100
 
95
- peak_picked = "unknown"
96
- arrPP = v.select { |h| h['peak_picked'] }
97
- unless arrPP.empty?
98
- peak_picked = "#{arrPP.first[0]} #{arrPP.first[1]}"
99
101
  end
100
102
 
101
- str += "<p><p>"
102
- str += "<p><b>#{k}</b> - #{peak_picked}</p>"
103
+ # html for property differences
104
+ arr = Array.new
105
+
106
+ @hashDiffs.each_pair do |k,v|
107
+
108
+ chrom_type = k
109
+
110
+ v.each_pair do |k,v|
111
+ if k == 'peak'
112
+ v.each_pair do |k,v|
113
+ arr << property_diff_to_hash(chrom_type,k,v)
114
+ end
115
+ else
116
+ unless k == 'peak_picked'
117
+ arr << property_diff_to_hash(chrom_type,k,v)
118
+ end
119
+ end
120
+
121
+ end
103
122
 
104
- ht = HTML_Table_of_Peak_Picking_Log.new(@folderpath_with_log,@sample_index,@analyte_name,k)
105
- str_pp = ht.render
106
- unless str_pp.nil?
107
- str += "<p><p>"
108
- str += str_pp
109
- str += "</p>"
110
123
  end
111
124
 
112
- end
125
+ strProps = nil
113
126
 
114
127
  ht = HTML_Table_of_Property_Differences.new(arr)
115
128
  str_p = ht.render
116
129
  unless str_p.nil?
117
- str += "<p><p>"
118
- str += str_p
119
- str += "</p>"
130
+ strProps = str_p
120
131
  end
121
132
 
133
+ strFull = strFiles
134
+ strFull += strPlot unless strPlot.nil?
135
+
136
+ hashGroups = Hash.new
137
+ hashGroups['Properties'] = strProps
138
+ hashChromHTML.each_pair do |k,v|
139
+ hashGroups["Pick Log - #{k.to_s}"] = v
140
+ end
141
+
142
+ jt = Jquery_Tabs.new hashGroups
143
+ strFull += jt.render
144
+
145
+
122
146
  File.open(html_filepath, "w") do |f|
123
- f.write(str)
147
+ f.write(strFull)
124
148
  end
125
149
 
126
150
  retcode = true
@@ -146,6 +170,7 @@ module DeterminationsComparison
146
170
 
147
171
  private
148
172
 
173
+
149
174
  def categorize(hashPropertyThresholds)
150
175
 
151
176
  hashCategory = Hash.new
@@ -1,3 +1,3 @@
1
1
  module DeterminationsComparison
2
- VERSION = "1.0.2"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,60 @@
1
+ require 'erb'
2
+ require 'uuidtools'
3
+ require 'string'
4
+
5
+ class Jquery_Accordian
6
+ include ERB::Util
7
+
8
+ def initialize(hashGroups)
9
+ @hashGroups = hashGroups
10
+ @template = get_template
11
+ @div = UUIDTools::UUID.random_create
12
+
13
+ end
14
+
15
+ def render
16
+ unless @template.nil?
17
+ ERB.new(@template).result(binding)
18
+ end
19
+ end
20
+
21
+ def save(file)
22
+ File.open(file, "w+") do |f|
23
+ f.write(render)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def get_template()
30
+ %{
31
+ <html lang='en'>
32
+ <head>
33
+ <meta charset='utf-8'>
34
+ <link rel='stylesheet' href='http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css'>
35
+ <script src='http://code.jquery.com/jquery-1.9.1.js'></script>
36
+ <script src='http://code.jquery.com/ui/1.10.3/jquery-ui.js'></script>
37
+ </head>
38
+ <body>
39
+
40
+ <div id='accordion'>
41
+ <% @hashGroups.each do |k,v| %>
42
+ <h3> <%= k.to_s %> </h3>
43
+ <div>
44
+ <p> <%= v %> </p>
45
+ </div>
46
+ <% end %>
47
+ </div>
48
+
49
+ <script>
50
+ $( '#accordion' ).accordion();
51
+ </script>
52
+
53
+ </body>
54
+ </html>
55
+ }
56
+
57
+ end
58
+
59
+ end
60
+
@@ -0,0 +1,65 @@
1
+ require 'erb'
2
+ require 'uuidtools'
3
+ require 'string'
4
+
5
+ class Jquery_Tabs
6
+ include ERB::Util
7
+
8
+ def initialize(hashGroups)
9
+ @hashGroups = hashGroups
10
+ @template = get_template
11
+ @div = UUIDTools::UUID.random_create
12
+
13
+ end
14
+
15
+ def render
16
+ unless @template.nil?
17
+ ERB.new(@template).result(binding)
18
+ end
19
+ end
20
+
21
+ def save(file)
22
+ File.open(file, "w+") do |f|
23
+ f.write(render)
24
+ end
25
+ end
26
+
27
+ private
28
+
29
+ def get_template()
30
+ %{
31
+ <html lang='en'>
32
+ <head>
33
+ <meta charset="utf-8">
34
+ <title>compute test results</title>
35
+ <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
36
+ <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
37
+ <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
38
+ </head>
39
+ <body>
40
+
41
+ <div id="tabs">
42
+ <ul>
43
+ <% @hashGroups.each do |k,v| %>
44
+ <li><a href="#<%= k.gsub(' ','') %>"><span> <%= k %> </span></a></li>
45
+ <% end %>
46
+ </ul>
47
+ <% @hashGroups.each do |k,v| %>
48
+ <div id="<%= k.gsub(' ','') %>">
49
+ <%= v %>
50
+ </div>
51
+ <% end %>
52
+ </div>
53
+
54
+ <script>
55
+ $( "#tabs" ).tabs();
56
+ </script>
57
+
58
+ </body>
59
+ </html>
60
+ }
61
+
62
+ end
63
+
64
+ end
65
+
@@ -21,6 +21,10 @@ describe 'determinations_comparison' do
21
21
  File.join('spec','support','data','test_batch_for_cpplogreader')
22
22
  end
23
23
 
24
+ before :each do
25
+ FileUtils.rm(Dir.glob('bin/*'))
26
+ FileUtils.rm(Dir.glob('bin2/*'))
27
+ end
24
28
 
25
29
  it 'should show differences as hash' do
26
30
  comparison = DeterminationsComparison::Comparison.new( baseline_file, undertest_file, {:folderpath_output=>folderpath_output})
@@ -66,10 +70,4 @@ describe 'determinations_comparison' do
66
70
  expect(Dir.glob('bin2/*').size).to_not eq(0)
67
71
  end
68
72
 
69
- after :each do
70
- FileUtils.rm(Dir.glob('bin/*'))
71
- FileUtils.rm(Dir.glob('bin2/*'))
72
- end
73
-
74
-
75
73
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: determinations_comparison
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-07 00:00:00.000000000 Z
12
+ date: 2013-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -129,6 +129,8 @@ files:
129
129
  - lib/html_table.rb
130
130
  - lib/html_table_of_peak_picking_log.rb
131
131
  - lib/html_table_of_property_differences.rb
132
+ - lib/jquery_accordian.rb
133
+ - lib/jquery_tabs.rb
132
134
  - lib/string.rb
133
135
  - lib/utilities.rb
134
136
  - spec/determinations_comparison_spec.rb