示例#1
0
static char *pllTreeToNewickREC(char *treestr, tree *tr, nodeptr p, boolean printBranchLengths, boolean printNames, 
			    boolean printLikelihood, boolean rellTree, boolean finalPrint, int perGene, boolean branchLabelSupport, boolean printSHSupport)
{
  char  *nameptr;            
      
  if(isTip(p->number, tr->mxtips)) 
    {	       	  
      if(printNames)
	{
	  nameptr = tr->nameList[p->number];     
	  sprintf(treestr, "%s", nameptr);
	}
      else
	sprintf(treestr, "%d", p->number);    
	
      while (*treestr) treestr++;
    }
  else 
    {                 	 
      *treestr++ = '(';
      treestr = pllTreeToNewickREC(treestr, tr, p->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
			       finalPrint, perGene, branchLabelSupport, printSHSupport);
      *treestr++ = ',';
      treestr = pllTreeToNewickREC(treestr, tr, p->next->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
			       finalPrint, perGene, branchLabelSupport, printSHSupport);
      if(p == tr->start->back) 
	{
	  *treestr++ = ',';
	  treestr = pllTreeToNewickREC(treestr, tr, p->back, printBranchLengths, printNames, printLikelihood, rellTree, 
				   finalPrint, perGene, branchLabelSupport, printSHSupport);
	}
      *treestr++ = ')';                    
    }

  if(p == tr->start->back) 
    {	      	 
      if(printBranchLengths && !rellTree)
	sprintf(treestr, ":0.0;\n");
      else
	sprintf(treestr, ";\n");	 	  	
    }
  else 
    {                   
      if(rellTree || branchLabelSupport || printSHSupport)
	{	 	 
	  if(( !isTip(p->number, tr->mxtips)) && 
	     ( !isTip(p->back->number, tr->mxtips)))
	    {	
	      assert(0);
		      
	      /*assert(p->bInf != (branchInfo *)NULL);*/
	      
	      /*if(rellTree)
		sprintf(treestr, "%d:%8.20f", p->bInf->support, p->z[0]);
	      if(branchLabelSupport)
		sprintf(treestr, ":%8.20f[%d]", p->z[0], p->bInf->support);
	      if(printSHSupport)
		sprintf(treestr, ":%8.20f[%d]", getBranchLength(tr, perGene, p), p->bInf->support);
	      */
	      
	    }
	  else		
	    {
	      if(rellTree || branchLabelSupport)
		sprintf(treestr, ":%8.20f", p->z[0]);	
	      if(printSHSupport)
		sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));
	    }
	}
      else
	{
	  if(printBranchLengths)	    
	    sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));	      	   
	  else	    
	    sprintf(treestr, "%s", "\0");	    
	}      
    }
  
  while (*treestr) treestr++;
  return  treestr;
}
示例#2
0
static char *rootedTreeREC(char *treestr, tree *tr, nodeptr p, boolean printBranchLengths, boolean printNames, 
			   boolean printLikelihood, boolean rellTree, 
			   boolean finalPrint, analdef *adef, int perGene, boolean branchLabelSupport, boolean printSHSupport)
{
  char  *nameptr;

  if(isTip(p->number, tr->rdta->numsp)) 
    {	     
      if(printNames)
	{
	  nameptr = tr->nameList[p->number];     
	  sprintf(treestr, "%s", nameptr);
	}
      else
	sprintf(treestr, "%d", p->number);
      
      while (*treestr) treestr++;
    }
  else 
    {
      *treestr++ = '(';
      treestr = rootedTreeREC(treestr, tr, p->next->back, printBranchLengths, printNames, printLikelihood, 
			      rellTree, finalPrint, adef, perGene, branchLabelSupport, printSHSupport);
      *treestr++ = ',';
      treestr = rootedTreeREC(treestr, tr, p->next->next->back, printBranchLengths, printNames, printLikelihood, 
			      rellTree, finalPrint, adef, perGene, branchLabelSupport, printSHSupport);      
      *treestr++ = ')';            
    }

  if(rellTree || branchLabelSupport || printSHSupport)
    {	 	 
      if(( !isTip(p->number, tr->rdta->numsp)) && 
	 ( !isTip(p->back->number, tr->rdta->numsp)))
	{			      
	  assert(p->bInf != (branchInfo *)NULL);
	      
	  if(rellTree)
	    sprintf(treestr, "%d:%8.20f", p->bInf->support, p->z[0]);     
	  if(branchLabelSupport)
	    sprintf(treestr, ":%8.20f[%d]", p->z[0], p->bInf->support);
	  if(printSHSupport)
	    sprintf(treestr, ":%8.20f[%d]", getBranchLength(tr, perGene, p), p->bInf->support);	      
	}
      else		
	{
	  if(rellTree || branchLabelSupport)
	    sprintf(treestr, ":%8.20f", p->z[0]);	
	  if(printSHSupport)
	    sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));
	}
    }
  else
    {
      if(printBranchLengths)	    
	sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));	      	   
      else	    
	sprintf(treestr, "%s", "\0");	    
    }     

  while (*treestr) treestr++;
  return  treestr;
}
示例#3
0
static char *TreeInner2StringREC(char *treestr, tree *tr, nodeptr p, boolean printBranchLengths, boolean printNames, 
			    boolean printLikelihood, boolean rellTree, boolean finalPrint, int perGene, boolean branchLabelSupport, boolean printSHSupport, boolean printInnerNodes)
{
  /* TODOFER simplify this, should be used just to print inner nodes for testing */
  char  *nameptr;            

  if(isTip(p->number, tr->mxtips)) 
  {	       	  
    if(printNames)
    {
      nameptr = tr->nameList[p->number];     
      sprintf(treestr, "%s", nameptr);
    }
    else
      sprintf(treestr, "%d", p->number);    

    while (*treestr) treestr++;
  }
  else 
  {                 	 
    *treestr++ = '(';
    treestr = TreeInner2StringREC(treestr, tr, p->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
        finalPrint, perGene, branchLabelSupport, printSHSupport, printInnerNodes);
    *treestr++ = ',';
    treestr = TreeInner2StringREC(treestr, tr, p->next->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
        finalPrint, perGene, branchLabelSupport, printSHSupport, printInnerNodes);
    if(p == tr->start->back) 
    {
      *treestr++ = ',';
      treestr = TreeInner2StringREC(treestr, tr, p->back, printBranchLengths, printNames, printLikelihood, rellTree, 
          finalPrint, perGene, branchLabelSupport, printSHSupport, printInnerNodes);
    }
    *treestr++ = ')';                    
  }

  if(p == tr->start->back) 
  {	      	 
    if(printBranchLengths && !rellTree)
      sprintf(treestr, ":0.0;\n");
    else
      sprintf(treestr, ";\n");	 	  	
  }
  else 
  {                   
    if(rellTree || branchLabelSupport || printSHSupport || printInnerNodes)
    {	 	 
      if(( !isTip(p->number, tr->mxtips)) && 
          ( !isTip(p->back->number, tr->mxtips)))
      {			      
        //assert(p->bInf != (branchInfo *)NULL);

        if(rellTree)
          sprintf(treestr, "%d:%8.20f", p->bInf->support, p->z[0]);
        if(branchLabelSupport)
          sprintf(treestr, ":%8.20f[%d]", p->z[0], p->bInf->support);
        if(printSHSupport)
          sprintf(treestr, ":%8.20f[%d]", getBranchLength(tr, perGene, p), p->bInf->support);
        if(printInnerNodes)
          sprintf(treestr, "[%d]", p->number);

      }
      else		
      {
        if(rellTree || branchLabelSupport)
          sprintf(treestr, ":%8.20f", p->z[0]);	
        if(printSHSupport)
          sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));
      }
    }
    else
    {
      if(printBranchLengths)	    
        sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));	      	   
      else	    
        sprintf(treestr, "%s", "\0");	    
    }      
  }

  while (*treestr) treestr++;
  return  treestr;
}
示例#4
0
static char *Tree2StringREC(char *treestr, tree *tr, nodeptr p, boolean printBranchLengths, boolean printNames, 
			    boolean printLikelihood, boolean rellTree, boolean finalPrint, int perGene, boolean branchLabelSupport, boolean printSHSupport, boolean printIC, boolean printSHSupports)
{
  char  *nameptr;            
      
  if(isTip(p->number, tr->rdta->numsp)) 
    {	       	  
      if(printNames)
	{
	  nameptr = tr->nameList[p->number];     
	  sprintf(treestr, "%s", nameptr);
	}
      else
	sprintf(treestr, "%d", p->number);    
	
      while (*treestr) treestr++;
    }
  else 
    {                 	 
      *treestr++ = '(';
      treestr = Tree2StringREC(treestr, tr, p->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
			       finalPrint, perGene, branchLabelSupport, printSHSupport, printIC, printSHSupports);
      *treestr++ = ',';
      treestr = Tree2StringREC(treestr, tr, p->next->next->back, printBranchLengths, printNames, printLikelihood, rellTree, 
			       finalPrint, perGene, branchLabelSupport, printSHSupport, printIC, printSHSupports);
      if(p == tr->start->back) 
	{
	  *treestr++ = ',';
	  treestr = Tree2StringREC(treestr, tr, p->back, printBranchLengths, printNames, printLikelihood, rellTree, 
				   finalPrint, perGene, branchLabelSupport, printSHSupport, printIC, printSHSupports);
	}
      *treestr++ = ')';                    
    }

  if(p == tr->start->back) 
    {	      	 
      if(printBranchLengths && !rellTree)
	sprintf(treestr, ":0.0;\n");
      else
	sprintf(treestr, ";\n");	 	  	
    }
  else 
    {                   
      if(rellTree || branchLabelSupport || printSHSupport || printIC || printSHSupports)
	{	 	 
	  if(( !isTip(p->number, tr->rdta->numsp)) && 
	     ( !isTip(p->back->number, tr->rdta->numsp)))
	    {			      
	      assert(p->bInf != (branchInfo *)NULL);	      	    
	      
	      assert(rellTree + branchLabelSupport + printSHSupport + printSHSupports == 1);

	      if(rellTree)
		{
		  if(printIC)
		    sprintf(treestr, "%1.2f:%8.20f", p->bInf->ic, p->z[0]);
		  else
		    sprintf(treestr, "%d:%8.20f", p->bInf->support, p->z[0]);
		}
	      
	      if(branchLabelSupport)
		{
		  if(printIC)
		    sprintf(treestr, ":%8.20f[%1.2f,%1.2f]", p->z[0], p->bInf->ic, p->bInf->icAll);
		  else		    
		    sprintf(treestr, ":%8.20f[%d]", p->z[0], p->bInf->support);
		}
	      
	      if(printSHSupport)
		sprintf(treestr, ":%8.20f[%d]", getBranchLength(tr, perGene, p), p->bInf->support);

	      if(printSHSupports)
		{
		  int 
		    model;
		  
		  sprintf(treestr, ":%8.20f[", getBranchLength(tr, perGene, p));
		  while(*treestr) 
		    treestr++;
		  
		  for(model = 0; model < tr->NumberOfModels - 1; model++)		    
		    {
		      sprintf(treestr, "%d,", p->bInf->supports[model]);
		       while(*treestr) 
			 treestr++;
		    }

		  sprintf(treestr, "%d]", p->bInf->supports[model]);
		}
	      
	    }
	  else		
	    {
	      if(rellTree || branchLabelSupport)
		sprintf(treestr, ":%8.20f", p->z[0]);	
	      if(printSHSupport || printSHSupports)
		sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));
	    }
	}
      else
	{
	  if(printBranchLengths)	    
	    sprintf(treestr, ":%8.20f", getBranchLength(tr, perGene, p));	      	   
	  else	    
	    sprintf(treestr, "%s", "\0");	    
	}      
    }
  
  while (*treestr) treestr++;
  return  treestr;
}