Skip to content

Commit

Permalink
Do not read or write branch length for root (fixes Linux crash)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Ondov committed Feb 5, 2015
1 parent 25ae45a commit 4c4dbb6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/harvest/PhylogenyTreeNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,16 @@ PhylogenyTreeNode::PhylogenyTreeNode(char *& token, TrackList * trackList, bool
{
if ( *token == ')' )
{
state = STATE_nameInternal;
valueStart = token + 1;
token++;
if ( parent )
{
state = STATE_nameInternal;
valueStart = token + 1;
token++;
}
else
{
state = STATE_end; // root should not have bootstrap or branch length
}
}
else if ( *token == ',' )
{
Expand All @@ -95,11 +102,7 @@ PhylogenyTreeNode::PhylogenyTreeNode(char *& token, TrackList * trackList, bool
}
else if ( state == STATE_nameLeaf || state == STATE_nameInternal )
{
if ( *token == 0 )
{
state = STATE_end;
}
else if ( *token == ':' )
if ( *token == ':' )
{
if ( valueStart != token )
{
Expand Down Expand Up @@ -394,7 +397,11 @@ void PhylogenyTreeNode::writeToNewick(std::ostream &out, const TrackList & track
//by default, always use multiplier
//can be 1.0, or an adjusted value
//alternatively, this could be conditional based on the parameter, instead of using 1.0 vs non-1.0 values
out << ':' << distance * mult;

if ( parent ) // root should not have branch length
{
out << ':' << distance * mult;
}
}

void PhylogenyTreeNode::writeToProtocolBuffer(Harvest::Tree::Node * msgNode) const
Expand Down

0 comments on commit 4c4dbb6

Please sign in to comment.