Skip to content

Commit

Permalink
Add some treenode utility functions
Browse files Browse the repository at this point in the history
Updates #600
  • Loading branch information
shawnlaffan committed Sep 3, 2016
1 parent a68eb20 commit 9e47d00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/Biodiverse/GUI/Dendrogram.pm
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ sub get_palette {
# ed: actually don't - adjacent clusters may get wildly different hues
# because the hashes are randomly sorted...
#my $hue_slice = 180 / $num_clusters;
@colourset = (DEFAULT_LINE_COLOUR_RGB) x $num_clusters; # saves looping over them all
@colourset = (DEFAULT_LINE_COLOUR_RGB) x $num_clusters;
# saves looping over them all
}

my @colours = @colourset[0 .. $num_clusters - 1]; # return the relevant slice
Expand Down Expand Up @@ -661,7 +662,8 @@ sub do_colour_nodes_below {
@colour_nodes = values %node_hash;
#print "[Dendrogram] Done Grouping...\n";

# FIXME: why loop instead of just grouping with num_clusters => $self->get_palette_max_colours
# FIXME: why loop instead of just grouping with
# num_clusters => $self->get_palette_max_colours
# make sure we don't exceed the maximum number of colours
while (scalar @colour_nodes > $self->get_palette_max_colours) {
$excess_flag = 1;
Expand Down
17 changes: 17 additions & 0 deletions lib/Biodiverse/TreeNode.pm
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ sub get_name {
// croak "name parameter missing or undefined\n";
}

sub get_node_values {
wantarray ? %{$_[0]->{NODE_VALUES}} : $_[0]->{NODE_VALUES};
}

sub set_length {
my $self = shift;
my %args = @_;
Expand Down Expand Up @@ -1494,6 +1498,19 @@ sub assign_plot_coords_inner {
return;
}

sub get_terminal_node_first_number {
my $self = shift;
no autovivification;
my $values = $self->get_node_values;
return $values->{TERMINAL_NODE_FIRST};
}

sub get_terminal_node_last_number {
my $self = shift;
no autovivification;
my $values = $self->get_node_values;
return $values->{TERMINAL_NODE_LAST};
}

# number the nodes below this one based on the terminal nodes
# this allows us to export to CSV and retain some of the topology
Expand Down

0 comments on commit 9e47d00

Please sign in to comment.