Ejemplo n.º 1
0
void 
freeBEncode(struct BEncode *b)
{
     if (b->type == BInt) {
          free(b);

          return;
     }

     if (b->type == BString) {
          free(b->cargo.bStr);
          free(b);

          return;
     }

     if (b->type == BList) {
          freeBList(b->cargo.bList);
          free(b);

          return;
     }

     if (b->type == BDict) {
          freeBDict(b->cargo.bDict);
          free(b);

          return;
     }
}
Ejemplo n.º 2
0
void calcBipartitions(tree *tr, analdef *adef, char *bestTreeFileName, char *bootStrapFileName)
{
  bList *ML_Tree = (bList *)NULL, *BOOT_Tree = (bList *)NULL;
  int countML_Tree = 0, countBOOT_Tree = 0, numberOfTrees = 0, i;
  char ch;
  FILE *infoFile;  
 
  INFILE = fopen(bestTreeFileName, "r");
  treeReadTopologyOnly(INFILE, tr, adef, FALSE);
  fclose(INFILE); 
  
  ML_Tree = bipartitionList(tr, &countML_Tree);
  
  INFILE = fopen(bootStrapFileName, "r");
       

  while((ch = getc(INFILE)) != EOF)
    {
      if(ch == ';')
	numberOfTrees++;
    }	 
  rewind(INFILE);
 
/*  if(!adef->allInOne)
    {
      infoFile = fopen(infoFileName, "a");
      printf("\n\nFound %d trees in File %s\n\n", numberOfTrees, bootStrapFileName);
      fprintf(infoFile, "\n\nAA Found %d trees in File %s\n\n", numberOfTrees, bootStrapFileName);
      fclose(infoFile);
    }
*/
  for(i = 0; i < numberOfTrees; i++)
    {
      /*printf("Tree %d\n", i);*/
      treeReadTopologyOnly(INFILE, tr, adef, FALSE);
      BOOT_Tree = bipartitionList(tr, &countBOOT_Tree);
      updateReferenceList(ML_Tree, countML_Tree, BOOT_Tree, countBOOT_Tree);  
      freeBList(BOOT_Tree, countBOOT_Tree);
      free(BOOT_Tree);
    }

  fclose(INFILE);

  /*printBlist(ML_Tree, countML_Tree);*/
 
  INFILE = fopen(bestTreeFileName, "r");
  treeReadTopologyOnly(INFILE, tr, adef, TRUE);
  fclose(INFILE);

  /*for(i = 0; i < countML_Tree; i++)
    {
      p = ML_Tree[i].p;
      p->z = p->back->z =  ((double)ML_Tree[i].support) / ((double) numberOfTrees);
      }            */

  tr->ML_Tree = ML_Tree;
  tr->countML_Tree = countML_Tree;
  tr->numberOfTrees = numberOfTrees; 

  printBipartitionResult(tr, adef, TRUE);  
  freeBList(ML_Tree, countML_Tree);  
  free(ML_Tree);
}