isa => 'Graph',
predicate => 'has_graph',
);
-
-has distance_trees => (
- is => 'ro',
- isa => 'ArrayRef[Graph]',
- writer => '_save_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.
return join( "\n", @dotlines );
}
-=head2 editable
+=head2 editable( $linesep )
-Returns a version of the graph rendered in our definition format.
+Returns a version of the graph rendered in our definition format. The
+$linesep argument defaults to newline; set it to the empty string or to
+a space if the result is to be sent via JSON.
=cut
sub editable {
my $self = shift;
+ my $join = shift || "\n";
my @dotlines;
push( @dotlines, 'digraph stemma {' );
my @real; # A cheap sort
push( @dotlines, " $from -> $to;" );
}
push( @dotlines, '}' );
- return join( "\n", @dotlines );
+ return join( $join, @dotlines );
}
sub _make_dotline {
return @wits;
}
-=head2 distance_trees( program => $program )
-
-Returns a set of undirected graphs, which are the result of running a distance
-tree calculation program on the collation. Currently the only supported
-program is phylip_pars.
-
-=cut
-
-#### Methods for calculating phylogenetic trees ####
-
-before 'distance_trees' => sub {
+sub hypotheticals {
my $self = shift;
- my %args = (
- 'program' => 'phylip_pars',
- @_ );
- # TODO allow specification of method for calculating distance tree
- if( !$self->has_distance_trees
- || $args{'program'} ne $self->distance_program ) {
- # We need to make a tree before we can return it.
- my $dsub = 'run_' . $args{'program'};
- my $result = $self->$dsub(); # this might throw an error - catch it?
- # Save the resulting trees
- my $trees = parse_newick( $result );
- $self->_save_distance_trees( $trees );
- $self->distance_program( $args{'program'} );
- }
-};
-
-=head2 run_phylip_pars
-
-Runs Phylip Pars on the collation, returning the results in Newick format.
-Used for the distance_trees calculation.
-
-=cut
-
-sub run_phylip_pars {
- my $self = shift;
- my $cdata = character_input( $self->collation->make_alignment_table() );
- return phylip_pars( $cdata );
+ my @wits = grep
+ { $self->graph->get_vertex_attribute( $_, 'class' ) eq 'hypothetical' }
+ $self->graph->vertices;
+ return @wits;
}
sub throw {