Skip to content

Commit 3260fa6

Browse files
author
Kevin Howe
committed
Fixed edge-case bug of tree comprising a single cluster of identical sequences (produced bad Newick format)
1 parent e6b8be9 commit 3260fa6

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

include/version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
#define _VERSION
2323

2424
#define VERSION_MAJOR 2
25-
#define VERSION_MINOR 4
25+
#define VERSION_MINOR 5
2626

2727
#endif

src/tree.c

+3-12
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ void write_newhampshire_Tree( FILE *handle, struct Tree *thetree,
931931
if (thetree->child[0] != NULL) {
932932
if (thetree->child[1] == NULL) {
933933
/* draw rooted tree */
934-
935934
if (thetree->child[0]->left != NULL && thetree->child[0]->right != NULL) {
936935
fprintf( handle, "(\n");
937936
write_newhampshire_Tnode( handle, thetree->child[0]->left, show_bootstraps );
@@ -944,26 +943,18 @@ void write_newhampshire_Tree( FILE *handle, struct Tree *thetree,
944943
or a cluser of sequences. If this leaf contains a single sequence,
945944
then we have a tree of one sequence, in which case we print an
946945
error, because trees of one sequence do not make sense */
947-
948946
if (thetree->child[0]->clust->clustersize == 1)
949947
fatal_util( "Cannot build a tree with a single sequence %s",
950948
thetree->child[0]->clust->members[0]->name);
951949
else {
952-
unsigned int i;
953-
954-
for (i=0; i < thetree->child[0]->clust->clustersize - 1; i++)
955-
fprintf( handle, "(\n%s:%.5f,\n", thetree->child[0]->clust->members[i]->name, 0.0 );
956-
957-
fprintf( handle, "%s:%.5f", thetree->child[0]->clust->members[i]->name, 0.0);
958-
959-
for (i=0; i < thetree->child[0]->clust->clustersize - 2; i++)
960-
fprintf( handle, ")\n:%.5f)\n", 0.0 );
961-
950+
fprintf( handle, "(\n");
951+
write_newhampshire_Cluster( handle, thetree->child[0]->clust, 0, thetree->child[0]->clust->clustersize - 1);
962952
fprintf( handle, ");\n");
963953
}
964954
}
965955
}
966956
else {
957+
967958
fprintf( handle, "(\n");
968959
write_newhampshire_Tnode( handle, thetree->child[0], show_bootstraps );
969960
fprintf( handle, ",\n");

0 commit comments

Comments
 (0)