[Bioperl-guts-l] [16369] bioperl-live/trunk/Bio/Tree/TreeFunctionsI.pm: let distance() take two nodes as args
Mark Allen Jensen
maj at dev.open-bio.org
Sat Nov 14 19:44:04 EST 2009
Revision: 16369
Author: maj
Date: 2009-11-14 19:44:03 -0500 (Sat, 14 Nov 2009)
Log Message:
-----------
let distance() take two nodes as args
Modified Paths:
--------------
bioperl-live/trunk/Bio/Tree/TreeFunctionsI.pm
Modified: bioperl-live/trunk/Bio/Tree/TreeFunctionsI.pm
===================================================================
--- bioperl-live/trunk/Bio/Tree/TreeFunctionsI.pm 2009-11-13 18:34:17 UTC (rev 16368)
+++ bioperl-live/trunk/Bio/Tree/TreeFunctionsI.pm 2009-11-15 00:44:03 UTC (rev 16369)
@@ -798,6 +798,7 @@
Function: returns the distance between two given nodes
Returns : numerical distance
Args : -nodes => arrayref of nodes to test
+ or ($node1, $node2)
=cut
@@ -805,9 +806,19 @@
my ($self, at args) = @_;
my ($nodes) = $self->_rearrange([qw(NODES)], at args);
if( ! defined $nodes ) {
- $self->warn("Must supply -nodes parameter to distance() method");
+ $self->warn("Must supply two nodes or -nodes parameter to distance() method");
return;
}
+ elsif (ref($nodes) eq 'ARRAY') {
+ 1;
+ }
+ elsif ( @args == 2) { # assume these are nodes...
+ $nodes = \@args;
+ }
+ else {
+ $self->warn("Must supply two nodes or -nodes parameter to distance() method");
+ return;
+ }
$self->throw("Must provide 2 nodes") unless @{$nodes} == 2;
my $lca = $self->get_lca(@{$nodes});
More information about the Bioperl-guts-l
mailing list