Package com.nr.ci

Examples of com.nr.ci.Phylo_nj


      }
//      System.out.printf(endl;
    }

    // Create the NJ phylogenetic tree
    Phylo_nj tree=new Phylo_nj(dist);

    // Transfer to file in "newick" format
    for (i=0;i<NSEQ;i++) {
      for (j=0;j<NCHAR;j++)
        str[i][j]=base[sequence[i][j]];
      str[i][NCHAR]='\0';
    }
    Phylagglom.newick(tree,str,"newick.txt");

//    System.out.println("parents");
//    for (i=0;i<30;i++) {
//      System.out.printf(i << " %f\n", tree.t[i].mo);
//    }

    // Inspect the tree
//    System.out.println("Root: %f\n", tree.root);
    localflag = tree.root != 30;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Tree does not have expected number of nodes");
     
    }

    localflag = (tree.t[tree.root].nel != NSEQ);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Root node does not contain all the elements");
     
    }

//    System.out.printf(tree.t[tree.t[tree.root].ldau].nel);
    localflag = (tree.t[tree.t[tree.root].ldau].nel != NSEQ-1);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Left side of tree should have all but one leaf");
     
    }

    localflag = (tree.t[tree.t[tree.root].rdau].nel != 1);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Right side of tree should have one leaf");
     
    }

    localflag = (tree.t[tree.root].modist != 0.0);
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Mother distance of root is not zero");
     
    }

    for (i=0;i<NSEQ;i++) {
      localflag = abs(tree.t[i].modist-0.5) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Phylo_nj: Mother distances should be 0.5 for all leaves");
       
      }
    }

    localflag = abs(tree.t[29].modist) > sbeps;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Mother distances of node 29 should be zero");
     
    }
     
    for (i=0;i<NSEQ-2;i++) {
      mother = tree.t[i].mo;
      ndif=0;
      for (j=0;j<NCHAR;j++)
        if (sequence[tree.t[mother].ldau][j] != sequence[tree.t[mother].rdau][j]) ndif++;

      localflag = abs(tree.t[tree.t[mother].ldau].modist+tree.t[tree.t[mother].rdau].modist
        -(double)(ndif)) > sbeps;
      globalflag = globalflag || localflag;
      if (localflag) {
        fail("*** Phylo_nj: Distance of two daughters is not the sum of the mother distances");
       
      }
    }

//    System.out.println("Tree:");
//    print_tree(tree,tree.root);

//    System.out.println("Check expected order of leaves on tree:");
    Check_tree ct=new Check_tree(tree);
    ct.test(tree.root);

    localflag = ct.flag;
    globalflag = globalflag || localflag;
    if (localflag) {
      fail("*** Phylo_nj: Leaves of the tree were not encountered in the expected order");
     
    }

    i=tree.comancestor(0,7);
//    System.out.println("Common ancestor of 0,7: %f\n", i);
    Phylo_nj rerootedtree=new Phylo_nj(dist,i);

//    System.out.println("Rerooted Tree:");
//    print_tree(rerootedtree,rerootedtree.root);

    //  System.out.println("parents");
View Full Code Here

TOP

Related Classes of com.nr.ci.Phylo_nj

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.