lib/iroki/main/main.rb in iroki-0.0.33 vs lib/iroki/main/main.rb in iroki-0.0.34
- old
+ new
@@ -250,10 +250,14 @@
color_map_f.nil? &&
biom_f.nil? &&
name_map_f.nil?,
"Newick file was given but no other files were given")
+ abort_if biom_f && !exact,
+ "Regex matching cannot be used with a biom file. " +
+ "Pass the --exact flag"
+
# treeio = Bio::FlatFile.open(Bio::Newick, newick)
# newick = treeio.next_entry
str = File.read newick
newick = Bio::Newick.new str, parser: :iroki
@@ -283,33 +287,43 @@
end
#################################################################
# get color patterns
####################
- if color_map_f && biom_f
- color_map_patterns = parse_color_map_iroki color_map_f,
- iroki_to_name,
- exact_matching: exact,
- auto_color: auto_color_hash
+ if biom_f
+ abort_if single_color,
+ "--single-color is not compatible with a two " +
+ "group biom file. Please remove that option."
+
samples, counts, is_single_group = Biom.open(biom_f, "rt").parse
if is_single_group
biom_patterns = SingleGroupGradient.new(samples,
counts,
single_color,
min_lumin,
max_lumin).patterns
else
+ # abort_if single_color,
+ # "--single-color is incompatible with a two group biom file, please remove it."
+
g1_counts = counts.map(&:first)
g2_counts = counts.map(&:last)
biom_patterns = TwoGroupGradient.new(samples,
g1_counts,
g2_counts,
min_lumin,
max_lumin).patterns
end
+ end
+ if color_map_f && biom_f
+ color_map_patterns = parse_color_map_iroki color_map_f,
+ iroki_to_name,
+ exact_matching: exact,
+ auto_color: auto_color_hash
+
# these patterns have the original name for the key, so change
# the key to the iroki name
name_to_iroki = iroki_to_name.invert
biom_patterns_iroki_name = {}
biom_patterns.each do |name, val|
@@ -335,26 +349,10 @@
patterns = parse_color_map_iroki color_f,
iroki_to_name,
exact_matching: exact,
auto_color: auto_color_hash
elsif biom_f
- samples, counts, is_single_group = Biom.open(biom_f, "rt").parse
-
- if is_single_group
- patterns = SingleGroupGradient.new(samples,
- counts,
- single_color,
- min_lumin,
- max_lumin).patterns
- else
- g1_counts = counts.map(&:first)
- g2_counts = counts.map(&:last)
- patterns = TwoGroupGradient.new(samples,
- g1_counts,
- g2_counts,
- min_lumin,
- max_lumin).patterns
- end
+ patterns = biom_patterns
# these patterns have the original name for the key, so change
# the key to the iroki name
name_to_iroki = iroki_to_name.invert
h = {}