iroki 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e95553e4a9cc4572479c11aa9f5701e897e7fbd9
4
- data.tar.gz: ff5b30ae95cdfb53e2c443877100f55cf3846e67
3
+ metadata.gz: 7a089968db7de186aa8276b1964e496b65fbac4a
4
+ data.tar.gz: 1d1d3db465f5741256f6937a8884f0d4e95a6b56
5
5
  SHA512:
6
- metadata.gz: 538e1db4cdb5201363922f342f0a9ee9fd5100bfd59e0ff2d1e480034ac6591bd2355548b569b5011dbdeb3c34a589f3a811569f3bc65312b8bb6774bb45704f
7
- data.tar.gz: 363ef46a8ff54ab9858c46d0f6cfdc04f270cb03933ed2378af3a818a9ba3d6ec70a2f1b4d050ebd1da4076f2862eb8a56e2e7e55773bdbccfe1809063c48beb
6
+ metadata.gz: 7294d161e7988f562bdb17ab32d343763df1af2fa3431cf64ea22d6300849bbb6af083872bab5288cde5e9d7eedf67d90a26283d40d971c879911bd96c3a28b5
7
+ data.tar.gz: 560fbd14e2da7cf0ac33f282f44511d934bb893beb349a068c31c0b8fee0ede5041906b2a4019d7d7d559fcea844991221009daf20c991c5decc3fce719df6fb
data/lib/iroki.rb CHANGED
@@ -31,12 +31,12 @@ require "iroki/main/main"
31
31
  include Iroki::Const
32
32
  include Iroki::Color
33
33
  include Iroki::CoreExt::Hash
34
- include Iroki::CoreExt::String
34
+ String.include Iroki::CoreExt::String
35
35
  include Iroki::CoreExt::File
36
36
  include Iroki::Utils
37
37
 
38
38
  include AbortIf
39
-
39
+ include AbortIf::Assert
40
40
 
41
41
  module Iroki
42
42
  end
@@ -18,41 +18,761 @@
18
18
 
19
19
  module Iroki
20
20
  module Color
21
- BASIC =
22
- { "1" => "#FF3814", # red
23
- "2" => "#712BFF", # blue
24
- "3" => "#FFDF14", # yellow
25
- "4" => "#14FF63", } # green
26
-
27
- BASIC_LIGHT =
28
- { "1" => "#FF8872",
29
- "2" => "#A97FFE",
30
- "3" => "#FFEC72",
31
- "4" => "#71FEA1", }
32
-
33
- BASIC_DARK =
34
- { "1" => "#FF2800",
35
- "2" => "#4901DD",
36
- "3" => "#FFDD00",
37
- "4" => "#00E24D", }
38
-
39
- FUNKY =
40
- { "1" => "#FF7314",
41
- "2" => "#9F23FF",
42
- "3" => "#FFF814",
43
- "4" => "#14FFD8", }
44
-
45
- FUNKY_LIGHT =
46
- { "1" => "#FFAB72",
47
- "2" => "#C57AFE",
48
- "3" => "#FFFB72",
49
- "4" => "#71FEE6", }
50
-
51
- FUNKY_DARK =
52
- { "1" => "#FF6700",
53
- "2" => "#7C01DC",
54
- "3" => "#FFF700",
55
- "4" => "#00D7B3", }
21
+ module Palette
22
+ # BASIC =
23
+ # { "1" => "#FF3814", # red
24
+ # "2" => "#712BFF", # blue
25
+ # "3" => "#FFDF14", # yellow
26
+ # "4" => "#14FF63", } # green
27
+
28
+ # BASIC_LIGHT =
29
+ # { "1" => "#FF8872",
30
+ # "2" => "#A97FFE",
31
+ # "3" => "#FFEC72",
32
+ # "4" => "#71FEA1", }
33
+
34
+ # BASIC_DARK =
35
+ # { "1" => "#FF2800",
36
+ # "2" => "#4901DD",
37
+ # "3" => "#FFDD00",
38
+ # "4" => "#00E24D", }
39
+
40
+ # FUNKY =
41
+ # { "1" => "#FF7314",
42
+ # "2" => "#9F23FF",
43
+ # "3" => "#FFF814",
44
+ # "4" => "#14FFD8", }
45
+
46
+ # FUNKY_LIGHT =
47
+ # { "1" => "#FFAB72",
48
+ # "2" => "#C57AFE",
49
+ # "3" => "#FFFB72",
50
+ # "4" => "#71FEE6", }
51
+
52
+ # FUNKY_DARK =
53
+ # { "1" => "#FF6700",
54
+ # "2" => "#7C01DC",
55
+ # "3" => "#FFF700",
56
+ # "4" => "#00D7B3", }
57
+
58
+ KELLY = {
59
+ "1" => { name: "purple", hex: "#875692" },
60
+ "2" => { name: "orange", hex: "#F38400" },
61
+ "3" => { name: "light_blue", hex: "#A1CAF1" },
62
+ "4" => { name: "red", hex: "#BE0032" },
63
+ "5" => { name: "buff", hex: "#C2B280" },
64
+ "6" => { name: "grey", hex: "#848482" },
65
+ "7" => { name: "green", hex: "#008856" },
66
+ "8" => { name: "purplish_pink", hex: "#E68FAC" },
67
+ "9" => { name: "blue", hex: "#0067A5" },
68
+ "10" => { name: "yellowish_pink", hex: "#F99379" },
69
+ "11" => { name: "violet", hex: "#604E97" },
70
+ "12" => { name: "orange_yellow", hex: "#F6A600" },
71
+ "13" => { name: "purplish_red", hex: "#B3446C" },
72
+ "14" => { name: "reddish_brown", hex: "#882D17" },
73
+ "15" => { name: "yellow_green", hex: "#8DB600" },
74
+ "16" => { name: "yellowish_brown", hex: "#654522" },
75
+ "17" => { name: "reddish_orange", hex: "#E25822" },
76
+ "18" => { name: "olive_green", hex: "#2B3D26" },
77
+ "19" => { name: "yellow", hex: "#F3C300" },
78
+ }
79
+ end
80
+
81
+ def self.get_tag str, palette=nil
82
+ if str.hex?
83
+ self.tag_from_hex str
84
+ else
85
+ self.tag_from_color str, palette
86
+ end
87
+ end
88
+
89
+ def self.tag_from_hex hex
90
+ assert hex.hex?, "'#{hex}' was not a valid hex code"
91
+
92
+ %Q{[&!color="#{hex}"]}
93
+ end
94
+
95
+ def self.tag_from_color color, palette=nil
96
+ col = color.downcase.strip
97
+
98
+ if palette
99
+ hash =
100
+ Hash[palette.keys.zip palette.map(&:last).map{|h| h[:hex]}]
101
+ colors = COLORS.merge hash
102
+ else
103
+ colors = COLORS
104
+ end
105
+
106
+ if colors.has_key? col
107
+ hex = colors[col]
108
+ else
109
+ # if passed color other than one defined, return black
110
+ hex = colors["black"]
111
+ end
112
+
113
+ %Q{[&!color="#{hex}"]}
114
+ end
115
+
116
+ COLORS = {
117
+ "white" => "#FFFFFF",
118
+ "aliceblue" => "#F0F8FF",
119
+ "antiquewhite" => "#FAEBD7",
120
+ "antiquewhite1" => "#FFEFDB",
121
+ "antiquewhite2" => "#EEDFCC",
122
+ "antiquewhite3" => "#CDC0B0",
123
+ "antiquewhite4" => "#8B8378",
124
+ "aquamarine" => "#7FFFD4",
125
+ "aquamarine1" => "#7FFFD4",
126
+ "aquamarine2" => "#76EEC6",
127
+ "aquamarine3" => "#66CDAA",
128
+ "aquamarine4" => "#458B74",
129
+ "azure" => "#F0FFFF",
130
+ "azure1" => "#F0FFFF",
131
+ "azure2" => "#E0EEEE",
132
+ "azure3" => "#C1CDCD",
133
+ "azure4" => "#838B8B",
134
+ "beige" => "#F5F5DC",
135
+ "bisque" => "#FFE4C4",
136
+ "bisque1" => "#FFE4C4",
137
+ "bisque2" => "#EED5B7",
138
+ "bisque3" => "#CDB79E",
139
+ "bisque4" => "#8B7D6B",
140
+ "black" => "#000000",
141
+ "blanchedalmond" => "#FFEBCD",
142
+ "blue" => "#0000FF",
143
+ "blue1" => "#0000FF",
144
+ "blue2" => "#0000EE",
145
+ "blue3" => "#0000CD",
146
+ "blue4" => "#00008B",
147
+ "blueviolet" => "#8A2BE2",
148
+ "brown" => "#A52A2A",
149
+ "brown1" => "#FF4040",
150
+ "brown2" => "#EE3B3B",
151
+ "brown3" => "#CD3333",
152
+ "brown4" => "#8B2323",
153
+ "burlywood" => "#DEB887",
154
+ "burlywood1" => "#FFD39B",
155
+ "burlywood2" => "#EEC591",
156
+ "burlywood3" => "#CDAA7D",
157
+ "burlywood4" => "#8B7355",
158
+ "cadetblue" => "#5F9EA0",
159
+ "cadetblue1" => "#98F5FF",
160
+ "cadetblue2" => "#8EE5EE",
161
+ "cadetblue3" => "#7AC5CD",
162
+ "cadetblue4" => "#53868B",
163
+ "chartreuse" => "#7FFF00",
164
+ "chartreuse1" => "#7FFF00",
165
+ "chartreuse2" => "#76EE00",
166
+ "chartreuse3" => "#66CD00",
167
+ "chartreuse4" => "#458B00",
168
+ "chocolate" => "#D2691E",
169
+ "chocolate1" => "#FF7F24",
170
+ "chocolate2" => "#EE7621",
171
+ "chocolate3" => "#CD661D",
172
+ "chocolate4" => "#8B4513",
173
+ "coral" => "#FF7F50",
174
+ "coral1" => "#FF7256",
175
+ "coral2" => "#EE6A50",
176
+ "coral3" => "#CD5B45",
177
+ "coral4" => "#8B3E2F",
178
+ "cornflowerblue" => "#6495ED",
179
+ "cornsilk" => "#FFF8DC",
180
+ "cornsilk1" => "#FFF8DC",
181
+ "cornsilk2" => "#EEE8CD",
182
+ "cornsilk3" => "#CDC8B1",
183
+ "cornsilk4" => "#8B8878",
184
+ "cyan" => "#00FFFF",
185
+ "cyan1" => "#00FFFF",
186
+ "cyan2" => "#00EEEE",
187
+ "cyan3" => "#00CDCD",
188
+ "cyan4" => "#008B8B",
189
+ "darkblue" => "#00008B",
190
+ "darkcyan" => "#008B8B",
191
+ "darkgoldenrod" => "#B8860B",
192
+ "darkgoldenrod1" => "#FFB90F",
193
+ "darkgoldenrod2" => "#EEAD0E",
194
+ "darkgoldenrod3" => "#CD950C",
195
+ "darkgoldenrod4" => "#8B6508",
196
+ "darkgray" => "#A9A9A9",
197
+ "darkgreen" => "#006400",
198
+ "darkgrey" => "#A9A9A9",
199
+ "darkkhaki" => "#BDB76B",
200
+ "darkmagenta" => "#8B008B",
201
+ "darkolivegreen" => "#556B2F",
202
+ "darkolivegreen1" => "#CAFF70",
203
+ "darkolivegreen2" => "#BCEE68",
204
+ "darkolivegreen3" => "#A2CD5A",
205
+ "darkolivegreen4" => "#6E8B3D",
206
+ "darkorange" => "#FF8C00",
207
+ "darkorange1" => "#FF7F00",
208
+ "darkorange2" => "#EE7600",
209
+ "darkorange3" => "#CD6600",
210
+ "darkorange4" => "#8B4500",
211
+ "darkorchid" => "#9932CC",
212
+ "darkorchid1" => "#BF3EFF",
213
+ "darkorchid2" => "#B23AEE",
214
+ "darkorchid3" => "#9A32CD",
215
+ "darkorchid4" => "#68228B",
216
+ "darkred" => "#8B0000",
217
+ "darksalmon" => "#E9967A",
218
+ "darkseagreen" => "#8FBC8F",
219
+ "darkseagreen1" => "#C1FFC1",
220
+ "darkseagreen2" => "#B4EEB4",
221
+ "darkseagreen3" => "#9BCD9B",
222
+ "darkseagreen4" => "#698B69",
223
+ "darkslateblue" => "#483D8B",
224
+ "darkslategray" => "#2F4F4F",
225
+ "darkslategray1" => "#97FFFF",
226
+ "darkslategray2" => "#8DEEEE",
227
+ "darkslategray3" => "#79CDCD",
228
+ "darkslategray4" => "#528B8B",
229
+ "darkslategrey" => "#2F4F4F",
230
+ "darkturquoise" => "#00CED1",
231
+ "darkviolet" => "#9400D3",
232
+ "deeppink" => "#FF1493",
233
+ "deeppink1" => "#FF1493",
234
+ "deeppink2" => "#EE1289",
235
+ "deeppink3" => "#CD1076",
236
+ "deeppink4" => "#8B0A50",
237
+ "deepskyblue" => "#00BFFF",
238
+ "deepskyblue1" => "#00BFFF",
239
+ "deepskyblue2" => "#00B2EE",
240
+ "deepskyblue3" => "#009ACD",
241
+ "deepskyblue4" => "#00688B",
242
+ "dimgray" => "#696969",
243
+ "dimgrey" => "#696969",
244
+ "dodgerblue" => "#1E90FF",
245
+ "dodgerblue1" => "#1E90FF",
246
+ "dodgerblue2" => "#1C86EE",
247
+ "dodgerblue3" => "#1874CD",
248
+ "dodgerblue4" => "#104E8B",
249
+ "firebrick" => "#B22222",
250
+ "firebrick1" => "#FF3030",
251
+ "firebrick2" => "#EE2C2C",
252
+ "firebrick3" => "#CD2626",
253
+ "firebrick4" => "#8B1A1A",
254
+ "floralwhite" => "#FFFAF0",
255
+ "forestgreen" => "#228B22",
256
+ "gainsboro" => "#DCDCDC",
257
+ "ghostwhite" => "#F8F8FF",
258
+ "gold" => "#FFD700",
259
+ "gold1" => "#FFD700",
260
+ "gold2" => "#EEC900",
261
+ "gold3" => "#CDAD00",
262
+ "gold4" => "#8B7500",
263
+ "goldenrod" => "#DAA520",
264
+ "goldenrod1" => "#FFC125",
265
+ "goldenrod2" => "#EEB422",
266
+ "goldenrod3" => "#CD9B1D",
267
+ "goldenrod4" => "#8B6914",
268
+ "gray" => "#BEBEBE",
269
+ "gray0" => "#000000",
270
+ "gray1" => "#030303",
271
+ "gray2" => "#050505",
272
+ "gray3" => "#080808",
273
+ "gray4" => "#0A0A0A",
274
+ "gray5" => "#0D0D0D",
275
+ "gray6" => "#0F0F0F",
276
+ "gray7" => "#121212",
277
+ "gray8" => "#141414",
278
+ "gray9" => "#171717",
279
+ "gray10" => "#1A1A1A",
280
+ "gray11" => "#1C1C1C",
281
+ "gray12" => "#1F1F1F",
282
+ "gray13" => "#212121",
283
+ "gray14" => "#242424",
284
+ "gray15" => "#262626",
285
+ "gray16" => "#292929",
286
+ "gray17" => "#2B2B2B",
287
+ "gray18" => "#2E2E2E",
288
+ "gray19" => "#303030",
289
+ "gray20" => "#333333",
290
+ "gray21" => "#363636",
291
+ "gray22" => "#383838",
292
+ "gray23" => "#3B3B3B",
293
+ "gray24" => "#3D3D3D",
294
+ "gray25" => "#404040",
295
+ "gray26" => "#424242",
296
+ "gray27" => "#454545",
297
+ "gray28" => "#474747",
298
+ "gray29" => "#4A4A4A",
299
+ "gray30" => "#4D4D4D",
300
+ "gray31" => "#4F4F4F",
301
+ "gray32" => "#525252",
302
+ "gray33" => "#545454",
303
+ "gray34" => "#575757",
304
+ "gray35" => "#595959",
305
+ "gray36" => "#5C5C5C",
306
+ "gray37" => "#5E5E5E",
307
+ "gray38" => "#616161",
308
+ "gray39" => "#636363",
309
+ "gray40" => "#666666",
310
+ "gray41" => "#696969",
311
+ "gray42" => "#6B6B6B",
312
+ "gray43" => "#6E6E6E",
313
+ "gray44" => "#707070",
314
+ "gray45" => "#737373",
315
+ "gray46" => "#757575",
316
+ "gray47" => "#787878",
317
+ "gray48" => "#7A7A7A",
318
+ "gray49" => "#7D7D7D",
319
+ "gray50" => "#7F7F7F",
320
+ "gray51" => "#828282",
321
+ "gray52" => "#858585",
322
+ "gray53" => "#878787",
323
+ "gray54" => "#8A8A8A",
324
+ "gray55" => "#8C8C8C",
325
+ "gray56" => "#8F8F8F",
326
+ "gray57" => "#919191",
327
+ "gray58" => "#949494",
328
+ "gray59" => "#969696",
329
+ "gray60" => "#999999",
330
+ "gray61" => "#9C9C9C",
331
+ "gray62" => "#9E9E9E",
332
+ "gray63" => "#A1A1A1",
333
+ "gray64" => "#A3A3A3",
334
+ "gray65" => "#A6A6A6",
335
+ "gray66" => "#A8A8A8",
336
+ "gray67" => "#ABABAB",
337
+ "gray68" => "#ADADAD",
338
+ "gray69" => "#B0B0B0",
339
+ "gray70" => "#B3B3B3",
340
+ "gray71" => "#B5B5B5",
341
+ "gray72" => "#B8B8B8",
342
+ "gray73" => "#BABABA",
343
+ "gray74" => "#BDBDBD",
344
+ "gray75" => "#BFBFBF",
345
+ "gray76" => "#C2C2C2",
346
+ "gray77" => "#C4C4C4",
347
+ "gray78" => "#C7C7C7",
348
+ "gray79" => "#C9C9C9",
349
+ "gray80" => "#CCCCCC",
350
+ "gray81" => "#CFCFCF",
351
+ "gray82" => "#D1D1D1",
352
+ "gray83" => "#D4D4D4",
353
+ "gray84" => "#D6D6D6",
354
+ "gray85" => "#D9D9D9",
355
+ "gray86" => "#DBDBDB",
356
+ "gray87" => "#DEDEDE",
357
+ "gray88" => "#E0E0E0",
358
+ "gray89" => "#E3E3E3",
359
+ "gray90" => "#E5E5E5",
360
+ "gray91" => "#E8E8E8",
361
+ "gray92" => "#EBEBEB",
362
+ "gray93" => "#EDEDED",
363
+ "gray94" => "#F0F0F0",
364
+ "gray95" => "#F2F2F2",
365
+ "gray96" => "#F5F5F5",
366
+ "gray97" => "#F7F7F7",
367
+ "gray98" => "#FAFAFA",
368
+ "gray99" => "#FCFCFC",
369
+ "gray100" => "#FFFFFF",
370
+ "green" => "#00FF00",
371
+ "green1" => "#00FF00",
372
+ "green2" => "#00EE00",
373
+ "green3" => "#00CD00",
374
+ "green4" => "#008B00",
375
+ "greenyellow" => "#ADFF2F",
376
+ "grey" => "#BEBEBE",
377
+ "grey0" => "#000000",
378
+ "grey1" => "#030303",
379
+ "grey2" => "#050505",
380
+ "grey3" => "#080808",
381
+ "grey4" => "#0A0A0A",
382
+ "grey5" => "#0D0D0D",
383
+ "grey6" => "#0F0F0F",
384
+ "grey7" => "#121212",
385
+ "grey8" => "#141414",
386
+ "grey9" => "#171717",
387
+ "grey10" => "#1A1A1A",
388
+ "grey11" => "#1C1C1C",
389
+ "grey12" => "#1F1F1F",
390
+ "grey13" => "#212121",
391
+ "grey14" => "#242424",
392
+ "grey15" => "#262626",
393
+ "grey16" => "#292929",
394
+ "grey17" => "#2B2B2B",
395
+ "grey18" => "#2E2E2E",
396
+ "grey19" => "#303030",
397
+ "grey20" => "#333333",
398
+ "grey21" => "#363636",
399
+ "grey22" => "#383838",
400
+ "grey23" => "#3B3B3B",
401
+ "grey24" => "#3D3D3D",
402
+ "grey25" => "#404040",
403
+ "grey26" => "#424242",
404
+ "grey27" => "#454545",
405
+ "grey28" => "#474747",
406
+ "grey29" => "#4A4A4A",
407
+ "grey30" => "#4D4D4D",
408
+ "grey31" => "#4F4F4F",
409
+ "grey32" => "#525252",
410
+ "grey33" => "#545454",
411
+ "grey34" => "#575757",
412
+ "grey35" => "#595959",
413
+ "grey36" => "#5C5C5C",
414
+ "grey37" => "#5E5E5E",
415
+ "grey38" => "#616161",
416
+ "grey39" => "#636363",
417
+ "grey40" => "#666666",
418
+ "grey41" => "#696969",
419
+ "grey42" => "#6B6B6B",
420
+ "grey43" => "#6E6E6E",
421
+ "grey44" => "#707070",
422
+ "grey45" => "#737373",
423
+ "grey46" => "#757575",
424
+ "grey47" => "#787878",
425
+ "grey48" => "#7A7A7A",
426
+ "grey49" => "#7D7D7D",
427
+ "grey50" => "#7F7F7F",
428
+ "grey51" => "#828282",
429
+ "grey52" => "#858585",
430
+ "grey53" => "#878787",
431
+ "grey54" => "#8A8A8A",
432
+ "grey55" => "#8C8C8C",
433
+ "grey56" => "#8F8F8F",
434
+ "grey57" => "#919191",
435
+ "grey58" => "#949494",
436
+ "grey59" => "#969696",
437
+ "grey60" => "#999999",
438
+ "grey61" => "#9C9C9C",
439
+ "grey62" => "#9E9E9E",
440
+ "grey63" => "#A1A1A1",
441
+ "grey64" => "#A3A3A3",
442
+ "grey65" => "#A6A6A6",
443
+ "grey66" => "#A8A8A8",
444
+ "grey67" => "#ABABAB",
445
+ "grey68" => "#ADADAD",
446
+ "grey69" => "#B0B0B0",
447
+ "grey70" => "#B3B3B3",
448
+ "grey71" => "#B5B5B5",
449
+ "grey72" => "#B8B8B8",
450
+ "grey73" => "#BABABA",
451
+ "grey74" => "#BDBDBD",
452
+ "grey75" => "#BFBFBF",
453
+ "grey76" => "#C2C2C2",
454
+ "grey77" => "#C4C4C4",
455
+ "grey78" => "#C7C7C7",
456
+ "grey79" => "#C9C9C9",
457
+ "grey80" => "#CCCCCC",
458
+ "grey81" => "#CFCFCF",
459
+ "grey82" => "#D1D1D1",
460
+ "grey83" => "#D4D4D4",
461
+ "grey84" => "#D6D6D6",
462
+ "grey85" => "#D9D9D9",
463
+ "grey86" => "#DBDBDB",
464
+ "grey87" => "#DEDEDE",
465
+ "grey88" => "#E0E0E0",
466
+ "grey89" => "#E3E3E3",
467
+ "grey90" => "#E5E5E5",
468
+ "grey91" => "#E8E8E8",
469
+ "grey92" => "#EBEBEB",
470
+ "grey93" => "#EDEDED",
471
+ "grey94" => "#F0F0F0",
472
+ "grey95" => "#F2F2F2",
473
+ "grey96" => "#F5F5F5",
474
+ "grey97" => "#F7F7F7",
475
+ "grey98" => "#FAFAFA",
476
+ "grey99" => "#FCFCFC",
477
+ "grey100" => "#FFFFFF",
478
+ "honeydew" => "#F0FFF0",
479
+ "honeydew1" => "#F0FFF0",
480
+ "honeydew2" => "#E0EEE0",
481
+ "honeydew3" => "#C1CDC1",
482
+ "honeydew4" => "#838B83",
483
+ "hotpink" => "#FF69B4",
484
+ "hotpink1" => "#FF6EB4",
485
+ "hotpink2" => "#EE6AA7",
486
+ "hotpink3" => "#CD6090",
487
+ "hotpink4" => "#8B3A62",
488
+ "indianred" => "#CD5C5C",
489
+ "indianred1" => "#FF6A6A",
490
+ "indianred2" => "#EE6363",
491
+ "indianred3" => "#CD5555",
492
+ "indianred4" => "#8B3A3A",
493
+ "ivory" => "#FFFFF0",
494
+ "ivory1" => "#FFFFF0",
495
+ "ivory2" => "#EEEEE0",
496
+ "ivory3" => "#CDCDC1",
497
+ "ivory4" => "#8B8B83",
498
+ "khaki" => "#F0E68C",
499
+ "khaki1" => "#FFF68F",
500
+ "khaki2" => "#EEE685",
501
+ "khaki3" => "#CDC673",
502
+ "khaki4" => "#8B864E",
503
+ "lavender" => "#E6E6FA",
504
+ "lavenderblush" => "#FFF0F5",
505
+ "lavenderblush1" => "#FFF0F5",
506
+ "lavenderblush2" => "#EEE0E5",
507
+ "lavenderblush3" => "#CDC1C5",
508
+ "lavenderblush4" => "#8B8386",
509
+ "lawngreen" => "#7CFC00",
510
+ "lemonchiffon" => "#FFFACD",
511
+ "lemonchiffon1" => "#FFFACD",
512
+ "lemonchiffon2" => "#EEE9BF",
513
+ "lemonchiffon3" => "#CDC9A5",
514
+ "lemonchiffon4" => "#8B8970",
515
+ "lightblue" => "#ADD8E6",
516
+ "lightblue1" => "#BFEFFF",
517
+ "lightblue2" => "#B2DFEE",
518
+ "lightblue3" => "#9AC0CD",
519
+ "lightblue4" => "#68838B",
520
+ "lightcoral" => "#F08080",
521
+ "lightcyan" => "#E0FFFF",
522
+ "lightcyan1" => "#E0FFFF",
523
+ "lightcyan2" => "#D1EEEE",
524
+ "lightcyan3" => "#B4CDCD",
525
+ "lightcyan4" => "#7A8B8B",
526
+ "lightgoldenrod" => "#EEDD82",
527
+ "lightgoldenrod1" => "#FFEC8B",
528
+ "lightgoldenrod2" => "#EEDC82",
529
+ "lightgoldenrod3" => "#CDBE70",
530
+ "lightgoldenrod4" => "#8B814C",
531
+ "lightgoldenrodyellow" => "#FAFAD2",
532
+ "lightgray" => "#D3D3D3",
533
+ "lightgreen" => "#90EE90",
534
+ "lightgrey" => "#D3D3D3",
535
+ "lightpink" => "#FFB6C1",
536
+ "lightpink1" => "#FFAEB9",
537
+ "lightpink2" => "#EEA2AD",
538
+ "lightpink3" => "#CD8C95",
539
+ "lightpink4" => "#8B5F65",
540
+ "lightsalmon" => "#FFA07A",
541
+ "lightsalmon1" => "#FFA07A",
542
+ "lightsalmon2" => "#EE9572",
543
+ "lightsalmon3" => "#CD8162",
544
+ "lightsalmon4" => "#8B5742",
545
+ "lightseagreen" => "#20B2AA",
546
+ "lightskyblue" => "#87CEFA",
547
+ "lightskyblue1" => "#B0E2FF",
548
+ "lightskyblue2" => "#A4D3EE",
549
+ "lightskyblue3" => "#8DB6CD",
550
+ "lightskyblue4" => "#607B8B",
551
+ "lightslateblue" => "#8470FF",
552
+ "lightslategray" => "#778899",
553
+ "lightslategrey" => "#778899",
554
+ "lightsteelblue" => "#B0C4DE",
555
+ "lightsteelblue1" => "#CAE1FF",
556
+ "lightsteelblue2" => "#BCD2EE",
557
+ "lightsteelblue3" => "#A2B5CD",
558
+ "lightsteelblue4" => "#6E7B8B",
559
+ "lightyellow" => "#FFFFE0",
560
+ "lightyellow1" => "#FFFFE0",
561
+ "lightyellow2" => "#EEEED1",
562
+ "lightyellow3" => "#CDCDB4",
563
+ "lightyellow4" => "#8B8B7A",
564
+ "limegreen" => "#32CD32",
565
+ "linen" => "#FAF0E6",
566
+ "magenta" => "#FF00FF",
567
+ "magenta1" => "#FF00FF",
568
+ "magenta2" => "#EE00EE",
569
+ "magenta3" => "#CD00CD",
570
+ "magenta4" => "#8B008B",
571
+ "maroon" => "#B03060",
572
+ "maroon1" => "#FF34B3",
573
+ "maroon2" => "#EE30A7",
574
+ "maroon3" => "#CD2990",
575
+ "maroon4" => "#8B1C62",
576
+ "mediumaquamarine" => "#66CDAA",
577
+ "mediumblue" => "#0000CD",
578
+ "mediumorchid" => "#BA55D3",
579
+ "mediumorchid1" => "#E066FF",
580
+ "mediumorchid2" => "#D15FEE",
581
+ "mediumorchid3" => "#B452CD",
582
+ "mediumorchid4" => "#7A378B",
583
+ "mediumpurple" => "#9370DB",
584
+ "mediumpurple1" => "#AB82FF",
585
+ "mediumpurple2" => "#9F79EE",
586
+ "mediumpurple3" => "#8968CD",
587
+ "mediumpurple4" => "#5D478B",
588
+ "mediumseagreen" => "#3CB371",
589
+ "mediumslateblue" => "#7B68EE",
590
+ "mediumspringgreen" => "#00FA9A",
591
+ "mediumturquoise" => "#48D1CC",
592
+ "mediumvioletred" => "#C71585",
593
+ "midnightblue" => "#191970",
594
+ "mintcream" => "#F5FFFA",
595
+ "mistyrose" => "#FFE4E1",
596
+ "mistyrose1" => "#FFE4E1",
597
+ "mistyrose2" => "#EED5D2",
598
+ "mistyrose3" => "#CDB7B5",
599
+ "mistyrose4" => "#8B7D7B",
600
+ "moccasin" => "#FFE4B5",
601
+ "navajowhite" => "#FFDEAD",
602
+ "navajowhite1" => "#FFDEAD",
603
+ "navajowhite2" => "#EECFA1",
604
+ "navajowhite3" => "#CDB38B",
605
+ "navajowhite4" => "#8B795E",
606
+ "navy" => "#000080",
607
+ "navyblue" => "#000080",
608
+ "oldlace" => "#FDF5E6",
609
+ "olivedrab" => "#6B8E23",
610
+ "olivedrab1" => "#C0FF3E",
611
+ "olivedrab2" => "#B3EE3A",
612
+ "olivedrab3" => "#9ACD32",
613
+ "olivedrab4" => "#698B22",
614
+ "orange" => "#FFA500",
615
+ "orange1" => "#FFA500",
616
+ "orange2" => "#EE9A00",
617
+ "orange3" => "#CD8500",
618
+ "orange4" => "#8B5A00",
619
+ "orangered" => "#FF4500",
620
+ "orangered1" => "#FF4500",
621
+ "orangered2" => "#EE4000",
622
+ "orangered3" => "#CD3700",
623
+ "orangered4" => "#8B2500",
624
+ "orchid" => "#DA70D6",
625
+ "orchid1" => "#FF83FA",
626
+ "orchid2" => "#EE7AE9",
627
+ "orchid3" => "#CD69C9",
628
+ "orchid4" => "#8B4789",
629
+ "palegoldenrod" => "#EEE8AA",
630
+ "palegreen" => "#98FB98",
631
+ "palegreen1" => "#9AFF9A",
632
+ "palegreen2" => "#90EE90",
633
+ "palegreen3" => "#7CCD7C",
634
+ "palegreen4" => "#548B54",
635
+ "paleturquoise" => "#AFEEEE",
636
+ "paleturquoise1" => "#BBFFFF",
637
+ "paleturquoise2" => "#AEEEEE",
638
+ "paleturquoise3" => "#96CDCD",
639
+ "paleturquoise4" => "#668B8B",
640
+ "palevioletred" => "#DB7093",
641
+ "palevioletred1" => "#FF82AB",
642
+ "palevioletred2" => "#EE799F",
643
+ "palevioletred3" => "#CD6889",
644
+ "palevioletred4" => "#8B475D",
645
+ "papayawhip" => "#FFEFD5",
646
+ "peachpuff" => "#FFDAB9",
647
+ "peachpuff1" => "#FFDAB9",
648
+ "peachpuff2" => "#EECBAD",
649
+ "peachpuff3" => "#CDAF95",
650
+ "peachpuff4" => "#8B7765",
651
+ "peru" => "#CD853F",
652
+ "pink" => "#FFC0CB",
653
+ "pink1" => "#FFB5C5",
654
+ "pink2" => "#EEA9B8",
655
+ "pink3" => "#CD919E",
656
+ "pink4" => "#8B636C",
657
+ "plum" => "#DDA0DD",
658
+ "plum1" => "#FFBBFF",
659
+ "plum2" => "#EEAEEE",
660
+ "plum3" => "#CD96CD",
661
+ "plum4" => "#8B668B",
662
+ "powderblue" => "#B0E0E6",
663
+ "purple" => "#A020F0",
664
+ "purple1" => "#9B30FF",
665
+ "purple2" => "#912CEE",
666
+ "purple3" => "#7D26CD",
667
+ "purple4" => "#551A8B",
668
+ "red" => "#FF0000",
669
+ "red1" => "#FF0000",
670
+ "red2" => "#EE0000",
671
+ "red3" => "#CD0000",
672
+ "red4" => "#8B0000",
673
+ "rosybrown" => "#BC8F8F",
674
+ "rosybrown1" => "#FFC1C1",
675
+ "rosybrown2" => "#EEB4B4",
676
+ "rosybrown3" => "#CD9B9B",
677
+ "rosybrown4" => "#8B6969",
678
+ "royalblue" => "#4169E1",
679
+ "royalblue1" => "#4876FF",
680
+ "royalblue2" => "#436EEE",
681
+ "royalblue3" => "#3A5FCD",
682
+ "royalblue4" => "#27408B",
683
+ "saddlebrown" => "#8B4513",
684
+ "salmon" => "#FA8072",
685
+ "salmon1" => "#FF8C69",
686
+ "salmon2" => "#EE8262",
687
+ "salmon3" => "#CD7054",
688
+ "salmon4" => "#8B4C39",
689
+ "sandybrown" => "#F4A460",
690
+ "seagreen" => "#2E8B57",
691
+ "seagreen1" => "#54FF9F",
692
+ "seagreen2" => "#4EEE94",
693
+ "seagreen3" => "#43CD80",
694
+ "seagreen4" => "#2E8B57",
695
+ "seashell" => "#FFF5EE",
696
+ "seashell1" => "#FFF5EE",
697
+ "seashell2" => "#EEE5DE",
698
+ "seashell3" => "#CDC5BF",
699
+ "seashell4" => "#8B8682",
700
+ "sienna" => "#A0522D",
701
+ "sienna1" => "#FF8247",
702
+ "sienna2" => "#EE7942",
703
+ "sienna3" => "#CD6839",
704
+ "sienna4" => "#8B4726",
705
+ "skyblue" => "#87CEEB",
706
+ "skyblue1" => "#87CEFF",
707
+ "skyblue2" => "#7EC0EE",
708
+ "skyblue3" => "#6CA6CD",
709
+ "skyblue4" => "#4A708B",
710
+ "slateblue" => "#6A5ACD",
711
+ "slateblue1" => "#836FFF",
712
+ "slateblue2" => "#7A67EE",
713
+ "slateblue3" => "#6959CD",
714
+ "slateblue4" => "#473C8B",
715
+ "slategray" => "#708090",
716
+ "slategray1" => "#C6E2FF",
717
+ "slategray2" => "#B9D3EE",
718
+ "slategray3" => "#9FB6CD",
719
+ "slategray4" => "#6C7B8B",
720
+ "slategrey" => "#708090",
721
+ "snow" => "#FFFAFA",
722
+ "snow1" => "#FFFAFA",
723
+ "snow2" => "#EEE9E9",
724
+ "snow3" => "#CDC9C9",
725
+ "snow4" => "#8B8989",
726
+ "springgreen" => "#00FF7F",
727
+ "springgreen1" => "#00FF7F",
728
+ "springgreen2" => "#00EE76",
729
+ "springgreen3" => "#00CD66",
730
+ "springgreen4" => "#008B45",
731
+ "steelblue" => "#4682B4",
732
+ "steelblue1" => "#63B8FF",
733
+ "steelblue2" => "#5CACEE",
734
+ "steelblue3" => "#4F94CD",
735
+ "steelblue4" => "#36648B",
736
+ "tan" => "#D2B48C",
737
+ "tan1" => "#FFA54F",
738
+ "tan2" => "#EE9A49",
739
+ "tan3" => "#CD853F",
740
+ "tan4" => "#8B5A2B",
741
+ "thistle" => "#D8BFD8",
742
+ "thistle1" => "#FFE1FF",
743
+ "thistle2" => "#EED2EE",
744
+ "thistle3" => "#CDB5CD",
745
+ "thistle4" => "#8B7B8B",
746
+ "tomato" => "#FF6347",
747
+ "tomato1" => "#FF6347",
748
+ "tomato2" => "#EE5C42",
749
+ "tomato3" => "#CD4F39",
750
+ "tomato4" => "#8B3626",
751
+ "turquoise" => "#40E0D0",
752
+ "turquoise1" => "#00F5FF",
753
+ "turquoise2" => "#00E5EE",
754
+ "turquoise3" => "#00C5CD",
755
+ "turquoise4" => "#00868B",
756
+ "violet" => "#EE82EE",
757
+ "violetred" => "#D02090",
758
+ "violetred1" => "#FF3E96",
759
+ "violetred2" => "#EE3A8C",
760
+ "violetred3" => "#CD3278",
761
+ "violetred4" => "#8B2252",
762
+ "wheat" => "#F5DEB3",
763
+ "wheat1" => "#FFE7BA",
764
+ "wheat2" => "#EED8AE",
765
+ "wheat3" => "#CDBA96",
766
+ "wheat4" => "#8B7E66",
767
+ "whitesmoke" => "#F5F5F5",
768
+ "yellow" => "#FFFF00",
769
+ "yellow1" => "#FFFF00",
770
+ "yellow2" => "#EEEE00",
771
+ "yellow3" => "#CDCD00",
772
+ "yellow4" => "#8B8B00",
773
+ "yellowgreen" => "#9ACD32",
774
+ }
775
+
56
776
 
57
777
  end
58
778
  end
@@ -16,6 +16,22 @@
16
16
  # You should have received a copy of the GNU General Public License
17
17
  # along with Iroki. If not, see <http://www.gnu.org/licenses/>.
18
18
 
19
+ def color_given? str
20
+ str && !str.empty?
21
+ end
22
+
23
+ def has_label_tag? str
24
+ m = str.match(/\Alabel:(\p{Alnum}+)\Z/i)
25
+
26
+ m[1] if m
27
+ end
28
+
29
+ def has_branch_tag? str
30
+ m = str.match(/\Abranch:(\p{Alnum}+)\Z/i)
31
+
32
+ m[1] if m
33
+ end
34
+
19
35
  module Iroki
20
36
  module CoreExt
21
37
  module File
@@ -26,32 +42,114 @@ module Iroki
26
42
  "You must provide a #{which} file.#{help}"
27
43
 
28
44
  abort_unless Object::File.exists?(arg),
29
- "The file #{arg} doesn't exist.#{help}"
45
+ "The file '#{arg}' doesn't exist.#{help}"
30
46
 
31
47
  arg
32
48
  end
33
49
 
50
+ def parse_color_map fname,
51
+ exact_matching: true,
52
+ auto_color: false
53
+
54
+ check_file fname, :color_map
55
+
56
+
57
+ patterns = {}
58
+ Object::File.open(fname).each_line do |line|
59
+ unless line.start_with? "#"
60
+ label_tag = ""
61
+ branch_tag = ""
62
+
63
+ pattern, label_color, branch_color = line.chomp.split "\t"
64
+
65
+ # color = "black" if color.nil? || color.empty?
66
+
67
+ assert pattern, "found no pattern"
68
+
69
+ if exact_matching # TODO should this really be everytime?
70
+ pattern = pattern.clean
71
+ else
72
+ # TODO flag bad regexp
73
+ pattern = Regexp.new pattern
74
+ end
75
+
76
+ if color_given?(label_color) && color_given?(branch_color)
77
+ abort_if(has_label_tag?(label_color) &&
78
+ has_label_tag?(branch_color),
79
+ "Label tag specified twice for '#{line}'")
80
+
81
+ abort_if(has_branch_tag?(label_color) &&
82
+ has_branch_tag?(branch_color),
83
+ "Branch tag specified twice for '#{line}'")
84
+ end
85
+
86
+ if color_given?(label_color) && !color_given?(branch_color)
87
+ if (color = has_label_tag? label_color)
88
+ label_tag = Iroki::Color.get_tag color, auto_color
89
+ elsif (color = has_branch_tag? label_color)
90
+ branch_tag = Iroki::Color.get_tag color, auto_color
91
+ else
92
+ label_tag = Iroki::Color.get_tag label_color, auto_color
93
+ branch_tag = Iroki::Color.get_tag label_color, auto_color
94
+ end
95
+ else
96
+ if color_given? label_color
97
+ if (color = has_label_tag? label_color)
98
+ label_tag = Iroki::Color.get_tag color, auto_color
99
+ elsif (color = has_branch_tag? label_color)
100
+ branch_tag = Iroki::Color.get_tag color, auto_color
101
+ else
102
+ label_tag = Iroki::Color.get_tag label_color, auto_color
103
+ end
104
+ end
105
+
106
+ if color_given? branch_color
107
+ if (color = has_branch_tag? branch_color)
108
+ branch_tag = Iroki::Color.get_tag color, auto_color
109
+ elsif (color = has_label_tag? branch_color)
110
+ label_tag = Iroki::Color.get_tag color, auto_color
111
+ else
112
+ branch_tag = Iroki::Color.get_tag branch_color, auto_color
113
+ end
114
+ end
115
+ end
116
+
117
+ # if auto_color
118
+ # patterns[pattern] = "[&!color=\"#{auto_colors[color]}\"]"
119
+ # else
120
+ # patterns[pattern] = Iroki::Color.get_tag color, auto_color
121
+ # end
122
+
123
+ patterns[pattern] = { label: label_tag, branch: branch_tag }
124
+ end
125
+ end
126
+
127
+ patterns
128
+ end
129
+
34
130
  def parse_name_map fname
35
131
  check_file fname, :name_map
36
132
 
37
133
  name_map = {}
38
134
  Object::File.open(fname).each_line do |line|
39
- oldname, newname = line.chomp.split "\t"
135
+ unless line.start_with? "#"
136
+ oldname, newname = line.chomp.split "\t"
40
137
 
41
138
 
42
- abort_if oldname.nil? || oldname.empty?,
43
- "Column 1 missing for line: #{line.inspect}"
139
+ abort_if oldname.nil? || oldname.empty?,
140
+ "Column 1 missing for line: #{line.inspect}"
44
141
 
45
- abort_if newname.nil? || newname.empty?,
46
- "Column 2 missing for line: #{line.inspect}"
142
+ abort_if newname.nil? || newname.empty?,
143
+ "Column 2 missing for line: #{line.inspect}"
47
144
 
48
- oldname = clean oldname
49
- newname = clean newname
145
+ oldname = oldname.clean
146
+ newname = newname.clean
50
147
 
51
- abort_if name_map.has_key?(oldname),
52
- "#{oldname} is repeated in column 1"
148
+ abort_if name_map.has_key?(oldname),
149
+ "#{oldname} is repeated in column 1"
53
150
 
54
- name_map[oldname] = newname
151
+ name_map[oldname] = newname
152
+ end
55
153
  end
56
154
 
57
155
  abort_if duplicate_values?(name_map),
@@ -2,31 +2,27 @@ module Iroki
2
2
  module CoreExt
3
3
  module String
4
4
 
5
- def hex? str
6
- str.match(/^#[0-9A-Fa-f]{6}$/)
5
+ def hex?
6
+ self.match(/^#[0-9A-Fa-f]{6}$/)
7
7
  end
8
8
 
9
- def clean str
10
- str.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
9
+ def clean
10
+ self.strip.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
11
11
  end
12
12
 
13
- def has_color? name
14
- name.match(/(.*)(\[&!color="#[0-9A-Fa-f]{6}"\])/)
13
+ def has_color?
14
+ self.match(/(.*)(\[&!color="#[0-9A-Fa-f]{6}"\])/)
15
15
  end
16
16
  alias already_checked? has_color?
17
17
 
18
- def clean_name name
19
- if name.nil?
20
- nil
21
- else
22
- if (match = has_color? name)
23
- name = match[1]
24
- color = match[2]
18
+ def clean_name
19
+ if (match = self.has_color?)
20
+ name = match[1]
21
+ color = match[2]
25
22
 
26
- clean(name) + color
27
- else
28
- clean(name)
29
- end
23
+ name.clean + color
24
+ else
25
+ self.clean
30
26
  end
31
27
  end
32
28
  end
@@ -32,52 +32,28 @@ module Iroki
32
32
  newick_f: nil,
33
33
  out_f: nil)
34
34
 
35
-
36
-
37
35
  if display_auto_color_options
38
36
  puts "\n Choices for --auto-color ..."
39
- print " basic, basic_light, basic_dark, funky, funky_light, " +
40
- "funky_dark\n\n"
37
+ print " - kelly: up to 19 high contrast colors (purple, orange, light blue, red, ...)\n\n"
41
38
  exit
42
39
  end
43
40
 
44
- auto_color_options =
45
- ["basic", "basic_light", "basic_dark",
46
- "funky", "funky_light", "funky_dark",]
47
-
41
+ auto_color_options = ["kelly"]
48
42
 
49
- if(!auto_color.nil? &&
50
- !auto_color_options.include?(auto_color))
43
+ if !auto_color.nil? && !auto_color_options.include?(auto_color)
51
44
  puts "\n Choices for --auto-color ..."
52
- print " basic, basic_light, basic_dark, funky, funky_light, " +
53
- "funky_dark\n\n"
45
+ print " - kelly: up to 19 high contrast colors (purple, orange, light blue, red, ...)\n\n"
54
46
 
55
47
  Trollop.die :auto_color, "#{auto_color} is not a valid option"
56
48
  end
57
49
 
58
50
  case auto_color
59
51
  when nil
60
- auto_colors = BASIC
61
- when "basic"
62
- auto_colors = BASIC
63
- when "basic_light"
64
- auto_colors = BASIC_LIGHT
65
- when "basic_dark"
66
- auto_colors = BASIC_DARK
67
- when "funky"
68
- auto_colors = FUNKY
69
- when "funky_light"
70
- auto_colors = FUNKY_LIGHT
71
- when "funky_dark"
72
- auto_colors = FUNKY_DARK
52
+ auto_color_hash = nil
53
+ when "kelly"
54
+ auto_color_hash = Iroki::Color::Palette::KELLY
73
55
  end
74
56
 
75
- # color_branches = true
76
- # color_taxa_names = true
77
- # exact = false
78
- # color_map_f = "test_files/500.patterns_with_name_map"
79
- # name_map_f = "test_files/500.name_map"
80
- # ARGV[0] = "test_files/500.zetas.tre"
81
57
  newick = check_file newick_f, :newick
82
58
 
83
59
  color_f = nil
@@ -93,60 +69,11 @@ module Iroki
93
69
  "A pattern file was provided without specifying " +
94
70
  "any coloring options"
95
71
 
96
-
97
- # if passed color other than one defined, return black
98
- black = "#000000"
99
- red = "#FF1300"
100
- yellow = "#FFD700"
101
- blue = "#5311FF"
102
- green = "#00FF2C"
103
- color2hex = Hash.new "[&!color=\"#{black}\"]"
104
- color2hex.merge!({
105
- "black" => "[&!color=\"#{black}\"]",
106
- "red" => "[&!color=\"#{red}\"]",
107
- "blue" => "[&!color=\"#{blue}\"]",
108
- "yellow" => "[&!color=\"#{yellow}\"]",
109
- "green" => "[&!color=\"#{green}\"]"
110
- })
111
-
112
- # check if complementary colors requested
113
- if color_f
114
- colors = Set.new
115
- File.open(color_f).each_line do |line|
116
- _, color = line.chomp.split "\t"
117
-
118
- colors << color
119
- end
120
-
121
- auto_color = colors.all? { |color| color.match /\A[0-4]\Z/ }
122
- end
123
-
124
72
  # get the color patterns
125
73
  if color_f
126
- patterns = {}
127
- File.open(color_f).each_line do |line|
128
- pattern, color = line.chomp.split "\t"
129
-
130
- color = "black" if color.nil? || color.empty?
131
-
132
- if name_map_f || color_taxa_names || color_branches
133
- pattern = clean_name pattern
134
- end
135
-
136
- if !exact
137
- pattern = Regexp.new pattern
138
- end
139
-
140
- if auto_color
141
- patterns[pattern] = "[&!color=\"#{auto_colors[color]}\"]"
142
- else
143
- if hex? color
144
- patterns[pattern] = "[&!color=\"#{color}\"]"
145
- else
146
- patterns[pattern] = color2hex[color]
147
- end
148
- end
149
- end
74
+ patterns = parse_color_map color_f,
75
+ exact_matching: exact,
76
+ auto_color: auto_color_hash
150
77
  end
151
78
 
152
79
  treeio = Bio::FlatFile.open(Bio::Newick, newick)
@@ -174,10 +101,10 @@ module Iroki
174
101
 
175
102
  if color_taxa_names
176
103
  leaves = tree.leaves.map do |n|
177
- name = clean_name n.name
104
+ name = n.name.clean_name
178
105
 
179
106
  if (color = add_color_to_leaf_branch(patterns, name, exact))
180
- name + color
107
+ name + color[:label]
181
108
  else
182
109
  name
183
110
  end
@@ -18,9 +18,6 @@
18
18
 
19
19
  module Iroki
20
20
  module Utils
21
- include AbortIf
22
- include Iroki::CoreExt::String
23
-
24
21
  def leaf? tree, node
25
22
  tree.children(node).empty?
26
23
  end
@@ -69,10 +66,18 @@ module Iroki
69
66
  # color = add_color_to_leaf_branch patterns, node, exact
70
67
 
71
68
  # clean the name no matter what
72
- node.name = clean_name node.name
69
+ if node.name
70
+ node.name = node.name.clean_name
71
+ else
72
+ node.name = nil
73
+ end
73
74
 
74
75
  # if its a leaf that hasnt been checked & needs color
75
- if leaf?(tree, node) && !already_checked?(node.name) # && color
76
+ # TODO the node.name is there to make sure already_checked?
77
+ # doesn't blow up. When can node.name be nil?
78
+ if(leaf?(tree, node) &&
79
+ node.name &&
80
+ !node.name.already_checked?)
76
81
  # check if it needs color, if so set the color
77
82
 
78
83
  # NOTE: this was originally before cleaning the node name a
@@ -80,7 +85,7 @@ module Iroki
80
85
  color = add_color_to_leaf_branch patterns, node, exact
81
86
 
82
87
  # add color to the name
83
- node.name = node.name + color if color
88
+ node.name = node.name + color[:branch] if color
84
89
  elsif !leaf?(tree, node)
85
90
  children = tree.children(node) # get the children
86
91
  children_colors = []
data/lib/iroki/version.rb CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  # Library metadata
20
20
  module Iroki
21
- VERSION = "0.0.7"
21
+ VERSION = "0.0.8"
22
22
  COPYRIGHT = "2015 - 2016 Ryan Moore"
23
23
  CONTACT = "moorer@udel.edu"
24
24
  WEBSITE = "https://github.com/mooreryan/iroki"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iroki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moore
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-23 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler