iroki 0.0.16 → 0.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/iroki/core_ext/file/file.rb +6 -3
- data/lib/iroki/main/main.rb +43 -34
- data/lib/iroki/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c60af26a59b2978ad8931b008ea757ffaef827b
|
4
|
+
data.tar.gz: f0af4f62235994a3f7dd4a3032cb2a131026b8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85a5df98c7c2e8258ee5a3247b9dab01d8a0b69651ae6a9aac9688542b574e68e3eb04dc27504b8e4213edf02945f01c1b5e0db359cc48c4e745857701490786
|
7
|
+
data.tar.gz: b5dd66465d49c85a68366bf9be7a9b0a22580cb1199bd83279df2bbc1e695d9ff45651ccb136a52160c1e21e85006669916b9e1612905b19738d2bad7c4ecde3
|
data/README.md
CHANGED
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
# Iroki #
|
4
4
|
|
5
|
-
[](https://badge.fury.io/rb/iroki)
|
5
|
+
[](https://badge.fury.io/rb/iroki)
|
6
|
+
[](https://travis-ci.org/mooreryan/iroki)
|
7
|
+
[](https://coveralls.io/github/mooreryan/iroki?branch=master)
|
8
|
+
[](https://github.com/mooreryan/iroki/issues)
|
9
|
+
[](https://raw.githubusercontent.com/mooreryan/iroki/master/COPYING)
|
6
10
|
|
7
11
|
Command line app and library code for Iroki, a phylogenetic tree
|
8
12
|
customization program.
|
@@ -144,3 +148,7 @@ Add `reorder_nodes` script.
|
|
144
148
|
|
145
149
|
- Allow unusual characters in label names ([GitHub issue](https://github.com/mooreryan/iroki/issues/2))
|
146
150
|
- Fix no method `clean` bug ([GitHub issue](https://github.com/mooreryan/iroki/issues/3))
|
151
|
+
|
152
|
+
### 0.0.17 ###
|
153
|
+
|
154
|
+
- Color map can override color gradient from biom file
|
@@ -20,14 +20,16 @@ def color_given? str
|
|
20
20
|
str && !str.empty?
|
21
21
|
end
|
22
22
|
|
23
|
+
# TODO spec this for hex matching
|
23
24
|
def has_label_tag? str
|
24
|
-
m = str.match(/\Alabel:(
|
25
|
+
m = str.match(/\Alabel:(#?\p{Alnum}+)\Z/i)
|
25
26
|
|
26
27
|
m[1] if m
|
27
28
|
end
|
28
29
|
|
30
|
+
# TODO spec this for hex matching
|
29
31
|
def has_branch_tag? str
|
30
|
-
m = str.match(/\Abranch:(
|
32
|
+
m = str.match(/\Abranch:(#?\p{Alnum}+)\Z/i)
|
31
33
|
|
32
34
|
m[1] if m
|
33
35
|
end
|
@@ -154,7 +156,8 @@ module Iroki
|
|
154
156
|
if name_to_iroki.has_key? pattern
|
155
157
|
pattern = name_to_iroki[pattern]
|
156
158
|
else
|
157
|
-
assert false, "String '#{pattern}' has no match
|
159
|
+
assert false, "String '#{pattern}' has no match " +
|
160
|
+
"in #{name_to_iroki.inspect}"
|
158
161
|
end
|
159
162
|
else
|
160
163
|
# TODO flag bad regexp
|
data/lib/iroki/main/main.rb
CHANGED
@@ -150,6 +150,9 @@ module Iroki
|
|
150
150
|
newick_f: nil,
|
151
151
|
out_f: nil)
|
152
152
|
|
153
|
+
args = method(__method__).parameters.map { |arg| arg[1] }
|
154
|
+
AbortIf::logger.info "Args " + args.map { |arg| "#{arg} = #{eval(arg.to_s).inspect}" }.join(', ')
|
155
|
+
|
153
156
|
if display_auto_color_options
|
154
157
|
STDERR.puts "\n Choices for --auto-color ..."
|
155
158
|
STDERR.print " - kelly: up to 19 high contrast colors (purple, orange, light blue, red, ...)\n\n"
|
@@ -171,10 +174,6 @@ module Iroki
|
|
171
174
|
abort_if single_color && biom_f.nil?,
|
172
175
|
"--single-color was passed but no biom file was given"
|
173
176
|
|
174
|
-
# this should be allowed
|
175
|
-
abort_if biom_f && color_map_f,
|
176
|
-
"--color-map and --biom-file cannot both be specified. Try iroki --help for help."
|
177
|
-
|
178
177
|
abort_if (biom_f || color_map_f) && color_branches.nil? && color_taxa_names.nil?,
|
179
178
|
"No coloring options selected."
|
180
179
|
|
@@ -191,6 +190,7 @@ module Iroki
|
|
191
190
|
|
192
191
|
color_f = nil
|
193
192
|
if !biom_f && (color_taxa_names || color_branches)
|
193
|
+
p color_map_f
|
194
194
|
color_f = check_file color_map_f, :color_map_f
|
195
195
|
end
|
196
196
|
|
@@ -230,10 +230,6 @@ module Iroki
|
|
230
230
|
name_map = nil
|
231
231
|
end
|
232
232
|
|
233
|
-
if name_map_f && color_map_f.nil? && biom_f.nil? # just name map
|
234
|
-
# put node names back
|
235
|
-
end
|
236
|
-
|
237
233
|
################
|
238
234
|
# parse name map
|
239
235
|
#################################################################
|
@@ -245,8 +241,46 @@ module Iroki
|
|
245
241
|
#################################################################
|
246
242
|
# get color patterns
|
247
243
|
####################
|
244
|
+
p [color_f, biom_f]
|
245
|
+
if color_map_f && biom_f
|
246
|
+
color_map_patterns = parse_color_map_iroki color_map_f,
|
247
|
+
iroki_to_name,
|
248
|
+
exact_matching: exact,
|
249
|
+
auto_color: auto_color_hash
|
250
|
+
samples, counts, is_single_group = Biom.open(biom_f, "rt").parse
|
248
251
|
|
249
|
-
|
252
|
+
if is_single_group
|
253
|
+
biom_patterns = SingleGroupGradient.new(samples, counts, single_color).patterns
|
254
|
+
else
|
255
|
+
g1_counts = counts.map(&:first)
|
256
|
+
g2_counts = counts.map(&:last)
|
257
|
+
biom_patterns = TwoGroupGradient.new(samples, g1_counts, g2_counts).patterns
|
258
|
+
end
|
259
|
+
|
260
|
+
# these patterns have the original name for the key, so change
|
261
|
+
# the key to the iroki name
|
262
|
+
name_to_iroki = iroki_to_name.invert
|
263
|
+
biom_patterns_iroki_name = {}
|
264
|
+
biom_patterns.each do |name, val|
|
265
|
+
biom_patterns_iroki_name[name_to_iroki[name]] = val
|
266
|
+
end
|
267
|
+
|
268
|
+
patterns = biom_patterns_iroki_name.merge(color_map_patterns) do |key, oldval, newval|
|
269
|
+
new_label = if !newval[:label].nil? && !newval[:label].empty?
|
270
|
+
newval[:label]
|
271
|
+
else
|
272
|
+
oldval[:label]
|
273
|
+
end
|
274
|
+
|
275
|
+
new_branch = if !newval[:branch].nil? && !newval[:branch].empty?
|
276
|
+
newval[:branch]
|
277
|
+
else
|
278
|
+
oldval[:branch]
|
279
|
+
end
|
280
|
+
|
281
|
+
{ label: new_label, branch: new_branch }
|
282
|
+
end
|
283
|
+
elsif color_f
|
250
284
|
patterns = parse_color_map_iroki color_f,
|
251
285
|
iroki_to_name,
|
252
286
|
exact_matching: exact,
|
@@ -280,27 +314,8 @@ module Iroki
|
|
280
314
|
#################################################################
|
281
315
|
|
282
316
|
|
283
|
-
# puts [:tree_after_change_names, tree.newick(indent: false)]
|
284
317
|
nil_val = { label: "", branch: "" }
|
285
318
|
|
286
|
-
# do this first cos everything after will use the "new" names
|
287
|
-
# if name_map_f
|
288
|
-
# name_map = parse_name_map name_map_f
|
289
|
-
|
290
|
-
# tree.collect_node! do |node|
|
291
|
-
# unless node.name.nil?
|
292
|
-
# # every name is cleaned no matter what
|
293
|
-
# # node.name = node.name.clean_name
|
294
|
-
|
295
|
-
# if name_map.has_key?(node.name)
|
296
|
-
# node.name = name_map[node.name]
|
297
|
-
# end
|
298
|
-
# end
|
299
|
-
|
300
|
-
# node
|
301
|
-
# end
|
302
|
-
# end
|
303
|
-
|
304
319
|
leaves_with_names = tree.leaves.reject { |leaf| leaf.name.nil? }
|
305
320
|
if color_taxa_names
|
306
321
|
leaves = leaves_with_names.map do |n|
|
@@ -339,12 +354,6 @@ module Iroki
|
|
339
354
|
# end
|
340
355
|
|
341
356
|
tre_str = tree.newick(indent: false)
|
342
|
-
# tree.each_node do |node|
|
343
|
-
# p [:node, node.name]
|
344
|
-
# end
|
345
|
-
# puts [:tree_str, tre_str]
|
346
|
-
# puts [:iroki_to_name, iroki_to_name]
|
347
|
-
# puts [:after_change, Iroki::Tree.gsub_iroki_newick_string(tre_str, iroki_to_name)]
|
348
357
|
|
349
358
|
# this hash can be used regardless of whether a name map was used
|
350
359
|
silly_iroki_to_name = {}
|
data/lib/iroki/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.17
|
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-08-
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|