예제 #1
0
void
tree_addendum_rep::notify_var_join (tree& ref, tree t, int offset) {
  // cout << "Notify var join " << ref << ", " << t << ", " << offset << "\n";
  (void) ref; (void) offset;
  (void) set_tree (t);
  // cout << "position -> " << obtain_position (observer (this)) << "\n";
}
예제 #2
0
void
tree_addendum_rep::notify_detach (tree& ref, tree closest, bool right) {
  // cout << "Notify detach " << ref << ", " << closest <<", "<< right << "\n";
  (void) right; (void) ref;
  (void) set_tree (closest);
  // cout << "position -> " << obtain_position (observer (this)) << "\n";
}
예제 #3
0
void
tree_addendum_rep::notify_var_split (tree& ref, tree t1, tree t2) {
  // cout << "Notify var split " << ref << ", " << t1 << ", " << t2 << "\n";
  (void) t2; (void) ref;
  (void) set_tree (t1); // always at the left
  // cout << "position -> " << obtain_position (observer (this)) << "\n";
}
예제 #4
0
파일: test.cpp 프로젝트: kgori/pllpy
int main(int argc, char const *argv[])
{
    std::string FILE="/homes/kgori/scratch/basic_pll/GGPS1.phy";
    std::string PART="/homes/kgori/scratch/basic_pll/GGPS1.partitions.txt";
    std::string TREE="/homes/kgori/scratch/basic_pll/GGPS1.tree";

    auto inst = make_unique<pll>(FILE, PART, TREE, 1, 123);
    std::cout << inst->get_likelihood() << std::endl;
    std::cout << inst->get_partition_name(0) << std::endl;
    std::cout << inst->get_model_name(0) << std::endl;
    std::cout << inst->get_epsilon() << std::endl;
    std::cout << inst->get_alpha(0) << std::endl;
    std::cout << inst->get_number_of_partitions() << std::endl;
    std::cout << inst->get_tree() << std::endl;
    std::cout << inst->get_frac_change() << std::endl;
    inst->set_tree("((Ptro:0.00147084048849247711,Ppan:0.00106294370976534763):0.00444598321816729036,(Cjac:0.05157798212603657839,(Csab:0.00440006365327790666,(Mmul:0.00652936575529242547,Panu:0.00101047194512476272):0.00381049900890796569):0.01359968787254225639):0.01375788728353777995,Hsap:0.00674547067186638278):0.0;");
    inst->set_epsilon(0.001);
    inst->set_alpha(2, 0, true);
    auto ef = inst->get_empirical_frequencies();

    inst->optimise(true, true, true, true);
    inst->optimise_tree_search(true);
    std::cout << inst->get_likelihood() << std::endl;
    std::cout << inst->get_tree() << std::endl;
    return 0;
}
예제 #5
0
void get_args (char *argv[])
{
    FILE *fp, *ofp = NULL;

    fp = fopen(argv[2], "r");
    if (fp == NULL) {
        fprintf(stderr, "Can't open input file %s!\n",
                "data.txt");
        exit(1);
    }
    ofp = fopen("bin/proto_tree.txt", "w");
    if (ofp == NULL) {
        fprintf(stderr, "Can't open output file %s!\n",
                "proto_tree.txt");
        exit(1);
    }
    Tree *T = set_tree (argv);
    read_data(fp, ofp, T);
    if(fclose(fp) != 0 || fclose(ofp) != 0)
    {
        printf("\nError closing files.\n");
    }
    /* free_tree(T, T->head->child[R]); */
}
예제 #6
0
void
tree_addendum_rep::notify_assign (tree& ref, tree t) {
  // cout << "Notify assign " << ref << ", " << t << "\n";
  (void) ref; (void) set_tree (t);
  // cout << "position -> " << obtain_position (observer (this)) << "\n";
}
예제 #7
0
void
tree_addendum_rep::notify_remove_node (tree& ref, int pos) {
  // cout << "Notify remove node " << ref << ", " << pos << "\n";
  (void) set_tree (ref[pos]);
  // cout << "position -> " << obtain_position (observer (this)) << "\n";
}
예제 #8
0
static PetscErrorCode gsi_via_bit_mask(gs_id *gs)
{
   PetscInt i, nel, *elms;
  PetscInt t1;
  PetscInt **reduce;
  PetscInt *map;
  PetscErrorCode ierr;

  PetscFunctionBegin;
  /* totally local removes ... ct_bits == 0 */
  get_ngh_buf(gs);

  if (gs->level)
    {set_pairwise(gs);}

  if (gs->max_left_over)
    {set_tree(gs);}

  /* intersection local and pairwise/tree? */
  gs->num_local_total = gs->num_local;
  gs->gop_local_reduce = gs->local_reduce;
  gs->num_gop_local_reduce = gs->num_local_reduce;

  map = gs->companion;

  /* is there any local compression */
  if (!gs->num_local) {
    gs->local_strength = NONE;
    gs->num_local_gop = 0;
  } else {
      /* ok find intersection */
      map = gs->companion;
      reduce = gs->local_reduce;  
      for (i=0, t1=0; i<gs->num_local; i++, reduce++)
        {
          if ((ivec_binary_search(**reduce,gs->pw_elm_list,gs->len_pw_list)>=0)
              ||
              ivec_binary_search(**reduce,gs->tree_map_in,gs->tree_map_sz)>=0)
            {
              t1++; 
              if (gs->num_local_reduce[i]<=0) SETERRQ(PETSC_ERR_PLIB,"nobody in list?");
              gs->num_local_reduce[i] *= -1;
            }
           **reduce=map[**reduce];
        }

      /* intersection is empty */
      if (!t1)
        {
          gs->local_strength = FULL;
          gs->num_local_gop = 0;          
        }
      /* intersection not empty */
      else
        {
          gs->local_strength = PARTIAL;
          ierr = SMI_sort((void*)gs->num_local_reduce, (void*)gs->local_reduce, gs->num_local + 1, SORT_INT_PTR);CHKERRQ(ierr);

          gs->num_local_gop = t1;
          gs->num_local_total =  gs->num_local;
          gs->num_local    -= t1;
          gs->gop_local_reduce = gs->local_reduce;
          gs->num_gop_local_reduce = gs->num_local_reduce;

          for (i=0; i<t1; i++)
            {
              if (gs->num_gop_local_reduce[i]>=0) SETERRQ(PETSC_ERR_PLIB,"they aren't negative?");
              gs->num_gop_local_reduce[i] *= -1;
              gs->local_reduce++;
              gs->num_local_reduce++;
            }
          gs->local_reduce++;
          gs->num_local_reduce++;
        }
    }

  elms = gs->pw_elm_list;
  nel  = gs->len_pw_list;
  for (i=0; i<nel; i++)
    {elms[i] = map[elms[i]];}

  elms = gs->tree_map_in;
  nel  = gs->tree_map_sz;
  for (i=0; i<nel; i++)
    {elms[i] = map[elms[i]];}

  /* clean up */
  free((void*) gs->local_elms);
  free((void*) gs->companion);
  free((void*) gs->elms);
  free((void*) gs->ngh_buf);
  gs->local_elms = gs->companion = gs->elms = gs->ngh_buf = NULL;
  PetscFunctionReturn(0);
}