Skip to content

Commit

Permalink
Fixed edge-case bug of tree comprising a single cluster of identical …
Browse files Browse the repository at this point in the history
…sequences (produced bad Newick format)
  • Loading branch information
Kevin Howe committed Mar 25, 2019
1 parent e6b8be9 commit 3260fa6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
2 changes: 1 addition & 1 deletion include/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
#define _VERSION

#define VERSION_MAJOR 2
#define VERSION_MINOR 4
#define VERSION_MINOR 5

#endif
15 changes: 3 additions & 12 deletions src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,6 @@ void write_newhampshire_Tree( FILE *handle, struct Tree *thetree,
if (thetree->child[0] != NULL) {
if (thetree->child[1] == NULL) {
/* draw rooted tree */

if (thetree->child[0]->left != NULL && thetree->child[0]->right != NULL) {
fprintf( handle, "(\n");
write_newhampshire_Tnode( handle, thetree->child[0]->left, show_bootstraps );
Expand All @@ -944,26 +943,18 @@ void write_newhampshire_Tree( FILE *handle, struct Tree *thetree,
or a cluser of sequences. If this leaf contains a single sequence,
then we have a tree of one sequence, in which case we print an
error, because trees of one sequence do not make sense */

if (thetree->child[0]->clust->clustersize == 1)
fatal_util( "Cannot build a tree with a single sequence %s",
thetree->child[0]->clust->members[0]->name);
else {
unsigned int i;

for (i=0; i < thetree->child[0]->clust->clustersize - 1; i++)
fprintf( handle, "(\n%s:%.5f,\n", thetree->child[0]->clust->members[i]->name, 0.0 );

fprintf( handle, "%s:%.5f", thetree->child[0]->clust->members[i]->name, 0.0);

for (i=0; i < thetree->child[0]->clust->clustersize - 2; i++)
fprintf( handle, ")\n:%.5f)\n", 0.0 );

fprintf( handle, "(\n");
write_newhampshire_Cluster( handle, thetree->child[0]->clust, 0, thetree->child[0]->clust->clustersize - 1);
fprintf( handle, ");\n");
}
}
}
else {

fprintf( handle, "(\n");
write_newhampshire_Tnode( handle, thetree->child[0], show_bootstraps );
fprintf( handle, ",\n");
Expand Down

0 comments on commit 3260fa6

Please sign in to comment.