X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition%2FStemma.pm;h=ba0d51fc87645993132d62863897aa899df3e928;hb=0f5d05c6adca96ece82661de0a262b038a00ba5f;hp=70fd634860257032c6bd2ca7cda96887ee7745fb;hpb=457b1620fd58822d243cb43d538fdf6f228585c8;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition/Stemma.pm b/lib/Text/Tradition/Stemma.pm index 70fd634..ba0d51f 100644 --- a/lib/Text/Tradition/Stemma.pm +++ b/lib/Text/Tradition/Stemma.pm @@ -30,6 +30,12 @@ has distance_trees => ( predicate => 'has_distance_trees', ); +has distance_program => ( + is => 'rw', + isa => 'Str', + default => '', + ); + sub BUILD { my( $self, $args ) = @_; # If we have been handed a dotfile, initialize it into a graph. @@ -181,15 +187,20 @@ sub witnesses { before 'distance_trees' => sub { my $self = shift; - my %args = @_; + my %args = ( + 'program' => 'phylip_pars', + @_ ); # TODO allow specification of method for calculating distance tree - if( $args{'recalc'} || !$self->has_distance_trees ) { + if( !$self->has_distance_trees + || $args{'program'} ne $self->distance_program ) { # We need to make a tree before we can return it. - my( $ok, $result ) = $self->run_phylip_pars(); + my $dsub = 'run_' . $args{'program'}; + my( $ok, $result ) = $self->$dsub(); if( $ok ) { # Save the resulting trees my $trees = _parse_newick( $result ); $self->_save_distance_trees( $trees ); + $self->distance_program( $args{'program'} ); } else { warn "Failed to calculate distance trees: $result"; } @@ -306,7 +317,7 @@ sub run_phylip_pars { # And then we run the program. my $program = File::Which::which( 'pars' ); unless( -x $program ) { - return( undef, "Phylip pars not found in path" ); + return( undef, "Phylip pars not found in path" ); } {