semin-egor 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +49 -0
- data/Manifest.txt +37 -0
- data/PostInstall.txt +5 -0
- data/Rakefile +32 -0
- data/bin/egor +10 -0
- data/config/website.yml +2 -0
- data/config/website.yml.sample +2 -0
- data/egor.gemspec +51 -0
- data/lib/egor/cli.rb +1738 -0
- data/lib/egor/environment.rb +34 -0
- data/lib/egor/environment_class_hash.rb +20 -0
- data/lib/egor/environment_feature.rb +16 -0
- data/lib/egor/environment_feature_array.rb +12 -0
- data/lib/egor/heatmap_array.rb +111 -0
- data/lib/egor.rb +6 -0
- data/lib/math_extensions.rb +7 -0
- data/lib/narray_extensions.rb +22 -0
- data/lib/nmatrix_extensions.rb +245 -0
- data/lib/string_extensions.rb +17 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +71 -0
- data/test/test_egor.rb +11 -0
- data/test/test_egor_cli.rb +9 -0
- data/test/test_egor_environment_class_hash.rb +25 -0
- data/test/test_egor_environment_feature.rb +29 -0
- data/test/test_helper.rb +2 -0
- data/test/test_math_extensions.rb +11 -0
- data/test/test_narray_extensions.rb +14 -0
- data/test/test_nmatrix_extensions.rb +16 -0
- data/test/test_string_extensions.rb +11 -0
- data/website/index.html +16 -0
- data/website/index.txt +217 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +158 -0
- data/website/template.html.erb +57 -0
- metadata +155 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
module Egor
|
2
|
+
class Environment
|
3
|
+
|
4
|
+
attr_accessor :amino_acids,
|
5
|
+
:number,
|
6
|
+
:label,
|
7
|
+
:freq_array,
|
8
|
+
:prob_array,
|
9
|
+
:logo_array,
|
10
|
+
:smooth_prob_array
|
11
|
+
|
12
|
+
def initialize(number, label, amino_acids = "ACDEFGHIKLMNPQRSTVWYJ".split(''))
|
13
|
+
@amino_acids = amino_acids
|
14
|
+
@number = number
|
15
|
+
@label = label
|
16
|
+
@freq_array = $noweight ? NArray.int(@amino_acids.size) : NArray.float(@amino_acids.size)
|
17
|
+
@prob_array = NArray.float(@amino_acids.size)
|
18
|
+
@logo_array = NArray.float(@amino_acids.size)
|
19
|
+
@smooth_prob_array = NArray.float(@amino_acids.size)
|
20
|
+
end
|
21
|
+
|
22
|
+
def increase_residue_count(a, inc = 1.0)
|
23
|
+
@freq_array[@amino_acids.index(a.upcase)] += inc
|
24
|
+
end
|
25
|
+
|
26
|
+
def label_set
|
27
|
+
label.split("").map_with_index { |l, i| "#{i}#{l}" }.to_set
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_s
|
31
|
+
"#{number}-#{label}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Egor
|
2
|
+
class EnvironmentClassHash < Hash
|
3
|
+
|
4
|
+
def group_by_non_residue_labels
|
5
|
+
self.values.group_by { |env| env.label[1..-1] }
|
6
|
+
end
|
7
|
+
|
8
|
+
def groups_sorted_by_residue_labels
|
9
|
+
group_by_non_residue_labels.to_a.sort_by { |env_group|
|
10
|
+
env_group[0].split('').map_with_index { |l, i|
|
11
|
+
$env_features[i + 1].labels.index(l)
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def group_size
|
17
|
+
group_by_non_residue_labels.size
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Egor
|
2
|
+
class EnvironmentFeature < Struct.new(:name, :symbols, :labels, :constrained, :silent)
|
3
|
+
|
4
|
+
def to_s
|
5
|
+
[name, symbols.join, labels.join, constrained, silent].join(";")
|
6
|
+
end
|
7
|
+
|
8
|
+
def constrained?
|
9
|
+
constrained == "T"
|
10
|
+
end
|
11
|
+
|
12
|
+
def silent?
|
13
|
+
silent == "T"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'facets'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'RMagick'
|
6
|
+
include Magick
|
7
|
+
rescue
|
8
|
+
$logger.warn "A RubyGems package, 'rmagick' is not found, so heat maps cannot be generated."
|
9
|
+
$no_rmagick = true
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
module Egor
|
15
|
+
class HeatmapArray < Array
|
16
|
+
|
17
|
+
def heatmap(options = {})
|
18
|
+
if $no_rmagick
|
19
|
+
return nil
|
20
|
+
end
|
21
|
+
|
22
|
+
opts = {:columns => 4,
|
23
|
+
:rvg_width => nil,
|
24
|
+
:dpi => 100,
|
25
|
+
:title => '',
|
26
|
+
:max_val => nil,
|
27
|
+
:mid_val => nil,
|
28
|
+
:min_val => nil,
|
29
|
+
:print_gradient => true,
|
30
|
+
:gradient_beg_color => '#FFFFFF',
|
31
|
+
:gradient_mid_color => nil,
|
32
|
+
:gradient_end_color => '#FF0000',
|
33
|
+
:gradient_border_width => 1,
|
34
|
+
:gradient_border_color => '#000000'}.merge(options)
|
35
|
+
|
36
|
+
row_images = ImageList.new
|
37
|
+
|
38
|
+
self.each_by(opts[:columns]) { |maps|
|
39
|
+
images = ImageList.new
|
40
|
+
maps.each { |m| images << m }
|
41
|
+
row_images << images.append(false)
|
42
|
+
}
|
43
|
+
|
44
|
+
tbl_img = row_images.append(true)
|
45
|
+
|
46
|
+
unless opts[:print_gradient]
|
47
|
+
return tbl_img
|
48
|
+
else
|
49
|
+
RVG::dpi = opts[:dpi]
|
50
|
+
rvg_width = opts[:rvg_width] * opts[:columns]
|
51
|
+
rvg_height = rvg_width / 10.0
|
52
|
+
|
53
|
+
rvg = RVG.new(rvg_width, rvg_height) do |canvas|
|
54
|
+
canvas.viewbox(0, 0, rvg_width, rvg_height)
|
55
|
+
canvas.background_fill = 'white'
|
56
|
+
canvas.desc = 'gradient key'
|
57
|
+
|
58
|
+
gradient_width = rvg_width / 2.0
|
59
|
+
gradient_height = gradient_width / 15.0
|
60
|
+
|
61
|
+
if opts[:gradient_mid_color]
|
62
|
+
img1 = Image.new(gradient_width / 2,
|
63
|
+
gradient_height,
|
64
|
+
GradientFill.new(0, 0, 0, gradient_width / 2,
|
65
|
+
opts[:gradient_beg_color], opts[:gradient_mid_color]))
|
66
|
+
|
67
|
+
img2 = Image.new(gradient_width / 2,
|
68
|
+
gradient_height,
|
69
|
+
GradientFill.new(0, 0, 0, gradient_width / 2,
|
70
|
+
opts[:gradient_mid_color], opts[:gradient_end_color]))
|
71
|
+
|
72
|
+
img3 = ImageList.new
|
73
|
+
img3 << img1 << img2
|
74
|
+
img = img3.append(false)
|
75
|
+
else
|
76
|
+
img = Image.new(gradient_width,
|
77
|
+
gradient_height,
|
78
|
+
GradientFill.new(0, 0, 0, gradient_width,
|
79
|
+
opts[:gradient_beg_color], opts[:gradient_end_color]))
|
80
|
+
end
|
81
|
+
|
82
|
+
img.border!(opts[:gradient_border_width],
|
83
|
+
opts[:gradient_border_width],
|
84
|
+
opts[:gradient_border_color])
|
85
|
+
|
86
|
+
gradient_x = (rvg_width - gradient_width) / 2.0
|
87
|
+
gradient_y = (rvg_height - gradient_height) / 2.0
|
88
|
+
gradient_font_size = rvg_width / 45.0
|
89
|
+
|
90
|
+
canvas.image(img,
|
91
|
+
gradient_width,
|
92
|
+
gradient_height,
|
93
|
+
gradient_x,
|
94
|
+
gradient_y)
|
95
|
+
|
96
|
+
canvas.text(gradient_x,
|
97
|
+
gradient_y + gradient_height + gradient_font_size * 1.1,
|
98
|
+
"#{'%.1f' % opts[:min_val]}").styles(:font_size => gradient_font_size)
|
99
|
+
|
100
|
+
canvas.text(gradient_x + gradient_width,
|
101
|
+
gradient_y + gradient_height + gradient_font_size * 1.1,
|
102
|
+
"#{'%.1f' % opts[:max_val]}").styles(:font_size => gradient_font_size)
|
103
|
+
end
|
104
|
+
|
105
|
+
fin_img = ImageList.new
|
106
|
+
fin_img << tbl_img << rvg.draw
|
107
|
+
fin_img.append(true)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/lib/egor.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#require 'rubygems'
|
2
|
+
require 'narray'
|
3
|
+
require 'facets'
|
4
|
+
|
5
|
+
module NArrayExtensions
|
6
|
+
|
7
|
+
def pretty_string(opts={})
|
8
|
+
{ :col_header => nil,
|
9
|
+
:row_header => nil }.merge!(opts)
|
10
|
+
|
11
|
+
("%-3s" % "#") + opts[:col_header].inject("") { |s, a| s + ("%7s" % a) } + "\n" +
|
12
|
+
self.to_a.inject("%-3s" % opts[:row_header]) { |s, v|
|
13
|
+
if v.is_a? Float
|
14
|
+
s + ("%7.2f" % v)
|
15
|
+
else
|
16
|
+
s + ("%7d" % v)
|
17
|
+
end
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
NArray.send(:include, NArrayExtensions)
|
@@ -0,0 +1,245 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'narray'
|
3
|
+
require 'facets'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'rvg/rvg'
|
7
|
+
include Magick
|
8
|
+
rescue
|
9
|
+
$logger.warn "A RubyGems package, 'rmagick' is not found, so heat maps cannot be generated."
|
10
|
+
$no_rmagick = true
|
11
|
+
end
|
12
|
+
|
13
|
+
module NMatrixExtensions
|
14
|
+
|
15
|
+
def pretty_string(options={})
|
16
|
+
opts = {:col_header => nil,
|
17
|
+
:row_header => nil }.merge(options)
|
18
|
+
|
19
|
+
("%-3s" % "#") + opts[:col_header].inject("") { |s, a|
|
20
|
+
s + ("%7s" % a)
|
21
|
+
} + "\n" + self.to_a.map_with_index { |a, i|
|
22
|
+
("%-3s" % opts[:row_header][i]) + a.inject("") { |s, v|
|
23
|
+
if v.is_a? Float
|
24
|
+
s + ("%7.2f" % v)
|
25
|
+
else
|
26
|
+
s + ("%7d" % v)
|
27
|
+
end
|
28
|
+
}
|
29
|
+
}.join("\n")
|
30
|
+
end
|
31
|
+
|
32
|
+
def heatmap(options={})
|
33
|
+
if $no_rmagick
|
34
|
+
return nil
|
35
|
+
end
|
36
|
+
|
37
|
+
opts = {:col_header => 'ACDEFGHIKLMNPQRSTVWYJ'.split(''),
|
38
|
+
:row_header => 'ACDEFGHIKLMNPQRSTVWYJ'.split(''),
|
39
|
+
:max_val => self.max,
|
40
|
+
:mid_val => (self.max - self.min) / 2.0,
|
41
|
+
:min_val => self.min,
|
42
|
+
:dpi => 100,
|
43
|
+
:margin_width => 30,
|
44
|
+
:rvg_width => nil,
|
45
|
+
:rvg_height => nil,
|
46
|
+
:canvas_width => nil,
|
47
|
+
:canvas_height => nil,
|
48
|
+
:cell_width => 20,
|
49
|
+
:cell_height => 20,
|
50
|
+
:cell_border_color => '#888888',
|
51
|
+
:cell_border_width => 1,
|
52
|
+
:table_border_color => '#000000',
|
53
|
+
:table_border_width => 2,
|
54
|
+
:header_height => 100,
|
55
|
+
:footer_height => 50,
|
56
|
+
:print_gradient => true,
|
57
|
+
:gradient_width => 300,
|
58
|
+
:gradient_height => 30,
|
59
|
+
:gradient_beg_color => '#FFFFFF',
|
60
|
+
:gradient_mid_color => nil,
|
61
|
+
:gradient_end_color => '#FF0000',
|
62
|
+
:gradient_border_width => 1,
|
63
|
+
:gradient_border_color => '#000000',
|
64
|
+
:font_scale => 0.9,
|
65
|
+
:font_family => 'san serif',
|
66
|
+
:small_gap_width => 2,
|
67
|
+
:title? => true,
|
68
|
+
:title => '',
|
69
|
+
:title_font_size => 35,
|
70
|
+
:print_value => false,
|
71
|
+
:key_font_size => 15,
|
72
|
+
:value_font_size => 8,
|
73
|
+
:background => '#FFFFFF'}.merge(options)
|
74
|
+
|
75
|
+
RVG::dpi = opts[:dpi]
|
76
|
+
|
77
|
+
rvg = RVG.new(opts[:rvg_width], opts[:rvg_height]) do |canvas|
|
78
|
+
title_x = (opts[:canvas_width] - opts[:title].length * opts[:title_font_size] * 0.6) / 2.0
|
79
|
+
title_y = opts[:header_height] - opts[:title_font_size]
|
80
|
+
|
81
|
+
canvas.viewbox(0, 0, opts[:canvas_width], opts[:canvas_height])
|
82
|
+
canvas.background_fill = opts[:background]
|
83
|
+
canvas.desc = opts[:title]
|
84
|
+
|
85
|
+
if opts[:title?]
|
86
|
+
canvas.text(title_x, title_y, opts[:title]).styles(:font_size => opts[:title_font_size])
|
87
|
+
end
|
88
|
+
|
89
|
+
# border for whole matrix
|
90
|
+
table_x = (opts[:canvas_width] - opts[:cell_width] * self.shape[0]) / 2.0
|
91
|
+
table_y = opts[:header_height] + opts[:cell_height]
|
92
|
+
|
93
|
+
canvas.rect(self.shape[0] * opts[:cell_width],
|
94
|
+
self.shape[1] * opts[:cell_height],
|
95
|
+
table_x,
|
96
|
+
table_y).styles(:stroke => opts[:table_border_color],
|
97
|
+
:stroke_width => opts[:table_border_width])
|
98
|
+
|
99
|
+
# drawing column and row labels
|
100
|
+
0.upto(self.shape[0] - 1) do |col|
|
101
|
+
canvas.text(table_x + col * opts[:cell_width] + opts[:small_gap_width],
|
102
|
+
opts[:cell_height] + opts[:header_height] - opts[:small_gap_width],
|
103
|
+
opts[:col_header][col]).styles( :font_family => opts[:font_family],
|
104
|
+
:font_size => opts[:cell_width] * opts[:font_scale])
|
105
|
+
end
|
106
|
+
|
107
|
+
0.upto(self.shape[1] - 1) do |row|
|
108
|
+
canvas.text(table_x - opts[:cell_width],
|
109
|
+
table_y + (row + 1) * opts[:cell_height],
|
110
|
+
opts[:row_header][row]).styles( :font_family => opts[:font_family],
|
111
|
+
:font_size => opts[:cell_height] * opts[:font_scale])
|
112
|
+
end
|
113
|
+
|
114
|
+
# drawing cells
|
115
|
+
|
116
|
+
# calculating a unit of RGB color in a decimal number
|
117
|
+
r_beg = (opts[:gradient_beg_color].rgb_to_integer & 0xFF0000) >> 16
|
118
|
+
g_beg = (opts[:gradient_beg_color].rgb_to_integer & 0x00FF00) >> 8
|
119
|
+
b_beg = (opts[:gradient_beg_color].rgb_to_integer & 0x0000FF) >> 0
|
120
|
+
r_end = (opts[:gradient_end_color].rgb_to_integer & 0xFF0000) >> 16
|
121
|
+
g_end = (opts[:gradient_end_color].rgb_to_integer & 0x00FF00) >> 8
|
122
|
+
b_end = (opts[:gradient_end_color].rgb_to_integer & 0x0000FF) >> 0
|
123
|
+
gap = opts[:max_val] - opts[:min_val]
|
124
|
+
|
125
|
+
if opts[:gradient_mid_color]
|
126
|
+
r_mid = (opts[:gradient_mid_color].rgb_to_integer & 0xFF0000) >> 16
|
127
|
+
g_mid = (opts[:gradient_mid_color].rgb_to_integer & 0x00FF00) >> 8
|
128
|
+
b_mid = (opts[:gradient_mid_color].rgb_to_integer & 0x0000FF) >> 0
|
129
|
+
gap1 = opts[:mid_val] - opts[:min_val]
|
130
|
+
gap2 = opts[:max_val] - opts[:mid_val]
|
131
|
+
end
|
132
|
+
|
133
|
+
0.upto(self.shape[0] - 1) do |col|
|
134
|
+
0.upto(self.shape[1] - 1) do |row|
|
135
|
+
if opts[:gradient_mid_color]
|
136
|
+
if self[col, row] <= opts[:mid_val]
|
137
|
+
r = interpolate(r_beg, r_mid, self[col, row] - opts[:min_val], gap1)
|
138
|
+
g = interpolate(g_beg, g_mid, self[col, row] - opts[:min_val], gap1)
|
139
|
+
b = interpolate(b_beg, b_mid, self[col, row] - opts[:min_val], gap1)
|
140
|
+
else
|
141
|
+
r = interpolate(r_mid, r_end, self[col, row] - opts[:mid_val], gap2)
|
142
|
+
g = interpolate(g_mid, g_end, self[col, row] - opts[:mid_val], gap2)
|
143
|
+
b = interpolate(b_mid, b_end, self[col, row] - opts[:mid_val], gap2)
|
144
|
+
end
|
145
|
+
else
|
146
|
+
r = interpolate(r_beg, r_end, self[col, row] - opts[:min_val], gap)
|
147
|
+
g = interpolate(g_beg, g_end, self[col, row] - opts[:min_val], gap)
|
148
|
+
b = interpolate(b_beg, b_end, self[col, row] - opts[:min_val], gap)
|
149
|
+
end
|
150
|
+
|
151
|
+
color = ("#%6X" % ((((r << 8) | g) << 8) | b)).gsub(" ", "0")
|
152
|
+
|
153
|
+
canvas.rect(opts[:cell_width],
|
154
|
+
opts[:cell_height],
|
155
|
+
table_x + col * opts[:cell_width],
|
156
|
+
table_y + row * opts[:cell_height]).styles( :fill => color,
|
157
|
+
:stroke => opts[:cell_border_color],
|
158
|
+
:stroke_width => opts[:cell_border_width])
|
159
|
+
|
160
|
+
if opts[:print_value]
|
161
|
+
canvas.text(table_x + col * opts[:cell_width] + opts[:cell_border_width],
|
162
|
+
table_y + (row + 1) * opts[:cell_height],
|
163
|
+
"#{'%.1f' % self[col, row]}").styles(:font_size => opts[:value_font_size])
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# gradient key
|
169
|
+
if opts[:print_gradient]
|
170
|
+
if opts[:gradient_mid_color]
|
171
|
+
img1 = Image.new(opts[:gradient_height],
|
172
|
+
opts[:gradient_width] / 2,
|
173
|
+
GradientFill.new(0,
|
174
|
+
opts[:gradient_width] / 2,
|
175
|
+
opts[:gradient_height],
|
176
|
+
opts[:gradient_width] / 2,
|
177
|
+
opts[:gradient_beg_color],
|
178
|
+
opts[:gradient_mid_color])).rotate(90)
|
179
|
+
|
180
|
+
img2 = Image.new(opts[:gradient_height],
|
181
|
+
opts[:gradient_width] / 2,
|
182
|
+
GradientFill.new(0,
|
183
|
+
opts[:gradient_width] / 2,
|
184
|
+
opts[:gradient_height],
|
185
|
+
opts[:gradient_width] / 2,
|
186
|
+
opts[:gradient_mid_color],
|
187
|
+
opts[:gradient_end_color])).rotate(90)
|
188
|
+
img3 = ImageList.new
|
189
|
+
img3 << img1 << img2
|
190
|
+
img = img3.append(false)
|
191
|
+
else
|
192
|
+
img = Image.new(opts[:gradient_height],
|
193
|
+
opts[:gradient_width],
|
194
|
+
GradientFill.new(0,
|
195
|
+
opts[:gradient_width],
|
196
|
+
opts[:gradient_height],
|
197
|
+
opts[:gradient_width],
|
198
|
+
opts[:gradient_beg_color],
|
199
|
+
opts[:gradient_end_color])).rotate(90)
|
200
|
+
end
|
201
|
+
|
202
|
+
img.border!(opts[:gradient_border_width],
|
203
|
+
opts[:gradient_border_width],
|
204
|
+
opts[:gradient_border_color])
|
205
|
+
|
206
|
+
gradient_x = (opts[:canvas_width] - opts[:gradient_width]) / 2
|
207
|
+
gradient_y = opts[:header_height] + opts[:cell_height] * opts[:row_header].count + opts[:margin_width]
|
208
|
+
|
209
|
+
canvas.image(img,
|
210
|
+
opts[:gradient_width],
|
211
|
+
opts[:gradient_height] + opts[:margin_width],
|
212
|
+
gradient_x,
|
213
|
+
gradient_y)
|
214
|
+
|
215
|
+
canvas.text(gradient_x,
|
216
|
+
gradient_y + opts[:gradient_height] + opts[:key_font_size] * 2,
|
217
|
+
"#{'%.1f' % opts[:min_val]}").styles(:font_size => opts[:key_font_size])
|
218
|
+
|
219
|
+
canvas.text(gradient_x + opts[:gradient_width],
|
220
|
+
gradient_y + opts[:gradient_height] + opts[:key_font_size] * 2,
|
221
|
+
"#{'%.1f' % opts[:max_val]}").styles(:font_size => opts[:key_font_size])
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
rvg.draw
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
private
|
230
|
+
|
231
|
+
def interpolate(start_val, end_val, step, no_steps)
|
232
|
+
begin
|
233
|
+
if (start_val < end_val)
|
234
|
+
((end_val - start_val) / no_steps.to_f) * step + start_val
|
235
|
+
else
|
236
|
+
start_val - ((start_val - end_val) / no_steps.to_f) * step
|
237
|
+
end.round
|
238
|
+
rescue FloatDomainError
|
239
|
+
start_val
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
NMatrix.send(:include, NMatrixExtensions)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module StringExtensions
|
2
|
+
|
3
|
+
def remove_internal_spaces
|
4
|
+
gsub(/[\n|\r|\s]+/, '')
|
5
|
+
end
|
6
|
+
|
7
|
+
def rgb_to_integer
|
8
|
+
if self.length == 7 # '#FF00FF'
|
9
|
+
Integer(self.gsub('#', '0x'))
|
10
|
+
else
|
11
|
+
raise "#{self} doesn't seem to be a proper RGB code."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
String.send :include, StringExtensions
|
17
|
+
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/egor.rb'}"
|
9
|
+
puts "Loading egor gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/script/txt2html
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
load File.dirname(__FILE__) + "/../Rakefile"
|
4
|
+
require 'rubyforge'
|
5
|
+
require 'redcloth'
|
6
|
+
require 'syntax/convertors/html'
|
7
|
+
require 'erb'
|
8
|
+
|
9
|
+
download = "http://rubyforge.org/projects/#{$hoe.rubyforge_name}"
|
10
|
+
version = $hoe.version
|
11
|
+
|
12
|
+
def rubyforge_project_id
|
13
|
+
RubyForge.new.configure.autoconfig["group_ids"][$hoe.rubyforge_name]
|
14
|
+
end
|
15
|
+
|
16
|
+
class Fixnum
|
17
|
+
def ordinal
|
18
|
+
# teens
|
19
|
+
return 'th' if (10..19).include?(self % 100)
|
20
|
+
# others
|
21
|
+
case self % 10
|
22
|
+
when 1: return 'st'
|
23
|
+
when 2: return 'nd'
|
24
|
+
when 3: return 'rd'
|
25
|
+
else return 'th'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Time
|
31
|
+
def pretty
|
32
|
+
return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def convert_syntax(syntax, source)
|
37
|
+
return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
|
38
|
+
end
|
39
|
+
|
40
|
+
if ARGV.length >= 1
|
41
|
+
src, template = ARGV
|
42
|
+
template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
|
43
|
+
else
|
44
|
+
puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
|
45
|
+
exit!
|
46
|
+
end
|
47
|
+
|
48
|
+
template = ERB.new(File.open(template).read)
|
49
|
+
|
50
|
+
title = nil
|
51
|
+
body = nil
|
52
|
+
File.open(src) do |fsrc|
|
53
|
+
title_text = fsrc.readline
|
54
|
+
body_text_template = fsrc.read
|
55
|
+
body_text = ERB.new(body_text_template).result(binding)
|
56
|
+
syntax_items = []
|
57
|
+
body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
|
58
|
+
ident = syntax_items.length
|
59
|
+
element, syntax, source = $1, $2, $3
|
60
|
+
syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
|
61
|
+
"syntax-temp-#{ident}"
|
62
|
+
}
|
63
|
+
title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
|
64
|
+
body = RedCloth.new(body_text).to_html
|
65
|
+
body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
|
66
|
+
end
|
67
|
+
stat = File.stat(src)
|
68
|
+
created = stat.ctime
|
69
|
+
modified = stat.mtime
|
70
|
+
|
71
|
+
$stdout << template.result(binding)
|
data/test/test_egor.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib', 'egor')
|
2
|
+
|
3
|
+
require 'test/unit'
|
4
|
+
require 'environment_class_hash'
|
5
|
+
|
6
|
+
class TestEgorEnvironmentClassHash < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include Egor
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@env_cls = EnvironmentClassHash.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_group_by_non_residue_labels
|
15
|
+
assert(true)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_groups_sorted_by_residue_labels
|
19
|
+
assert(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
def group_size
|
23
|
+
assert(true)
|
24
|
+
end
|
25
|
+
end
|