split stemma lib into util and object; make phylip_input microservice
[scpubgit/stemmatology.git] / lib / Text / Tradition / Collation.pm
index bf84fce..4b15dd1 100644 (file)
@@ -339,7 +339,10 @@ sub relationship_valid {
 sub reading_witnesses {
        my( $self, $reading ) = @_;
        # We need only check either the incoming or the outgoing edges; I have
-       # arbitrarily chosen "incoming".
+       # arbitrarily chosen "incoming".  Thus, special-case the start node.
+       if( $reading eq $self->start ) {
+               return map { $_->sigil } $self->tradition->witnesses;
+       }
        my %all_witnesses;
        foreach my $e ( $self->sequence->edges_to( $reading ) ) {
                my $wits = $self->sequence->get_edge_attributes( @$e );
@@ -716,7 +719,7 @@ sub make_alignment_table {
     }
     my $table = { 'alignment' => [], 'length' => $self->end->rank - 1 };
     my @all_pos = ( 1 .. $self->end->rank - 1 );
-    foreach my $wit ( $self->tradition->witnesses ) {
+    foreach my $wit ( sort { $a->sigil cmp $b->sigil } $self->tradition->witnesses ) {
        if( $include ) {
                next unless $include->{$wit->sigil};
        }