Ticket #627: moveNextTo_replacement.patch
File moveNextTo_replacement.patch, 10.3 KB (added by westram, 10 years ago) |
---|
-
PARSIMONY/AP_tree_nlen.cxx
604 604 AP_tree::set_root(); 605 605 } 606 606 607 void AP_tree_nlen::moveNextTo (AP_tree_nlen *newBrother, AP_FLOAT rel_pos) {607 void AP_tree_nlen::moveNextToOld(AP_tree_nlen *newBrother, AP_FLOAT rel_pos) { 608 608 ap_assert(father); 609 609 ap_assert(newBrother); 610 610 ap_assert(newBrother->father); … … 781 781 ap_assert(get_brother() == newBrother); 782 782 } 783 783 784 void AP_tree_nlen::moveNextToNew(AP_tree_nlen *newBrother, AP_FLOAT rel_pos) { 785 ap_assert(father); 786 ap_assert(newBrother); 787 ap_assert(newBrother->father); 788 ap_assert(newBrother->father != father); // already there 789 790 ASSERT_VALID_TREE(rootNode()); 791 792 ap_assert(rel_pos == 0.5); // only works for 0.5 (hardcoded in insert) 793 794 if (father->leftson != this) get_father()->swap_sons(); 795 796 ap_assert(newBrother != father); 797 798 GBT_LEN oldLen = get_branchlength(); 799 800 REMOVE(); 801 insert(newBrother); 802 803 set_branchlength(oldLen); 804 805 if (!is_leftson()) { 806 get_father()->swap_sons(); 807 } 808 809 ASSERT_VALID_TREE(this); 810 ASSERT_VALID_TREE(rootNode()); 811 812 ap_assert(is_leftson()); 813 ap_assert(get_brother() == newBrother); 814 } 815 816 // #define USE_OLD_MOVENEXTTO 817 // USE_OLD_MOVENEXTTO defined -> try new method, revert, use old method, compare resulting topologies 818 // USE_OLD_MOVENEXTTO undefined -> try old method, revert, use new method, compare resulting topologies 819 // topologies are equal in both cases. 820 821 void AP_tree_nlen::moveNextTo(AP_tree_nlen *newBrother, AP_FLOAT rel_pos) { 822 NewickFormat format = NewickFormat(nLENGTH|nWRAP); 823 824 char *newick_this = GBT_tree_2_newick(this, format, false);; 825 char *newick_brot = GBT_tree_2_newick(newBrother, format, false);; 826 char *newick_prev = GBT_tree_2_newick(get_tree_root()->get_root_node(), format, false);; 827 828 // test other (=not "used") moveNextTo 829 ap_main->remember(); 830 #if defined(USE_OLD_MOVENEXTTO) 831 moveNextToNew(newBrother, rel_pos); 832 char *newick_new = GBT_tree_2_newick(get_tree_root()->get_root_node(), format, false); 833 #else // !defined(USE_OLD_MOVENEXTTO) 834 moveNextToOld(newBrother, rel_pos); 835 char *newick_old = GBT_tree_2_newick(get_tree_root()->get_root_node(), format, false); 836 #endif 837 ap_main->revert(); 838 839 // now really use moveNextTo 840 #if defined(USE_OLD_MOVENEXTTO) 841 moveNextToOld(newBrother, rel_pos); 842 char *newick_old = GBT_tree_2_newick(get_tree_root()->get_root_node(), format, false); 843 #else // !defined(USE_OLD_MOVENEXTTO) 844 moveNextToNew(newBrother, rel_pos); 845 char *newick_new = GBT_tree_2_newick(get_tree_root()->get_root_node(), format, false); 846 #endif 847 848 if (strcmp(newick_old, newick_new) != 0) { 849 fprintf(stderr, "this=%s\n", newick_this); 850 fprintf(stderr, "target=%s\n", newick_brot); 851 fprintf(stderr, "prev=%s\n", newick_prev); 852 fprintf(stderr, "old=%s\n", newick_old); 853 fprintf(stderr, "new=%s\n", newick_new); 854 855 ap_assert(0); 856 } 857 858 free(newick_new); 859 free(newick_old); 860 free(newick_prev); 861 free(newick_brot); 862 free(newick_this); 863 } 864 784 865 void AP_tree_nlen::unhash_sequence() { 785 866 /*! removes the parsimony sequence from an inner node 786 867 * (has no effect for leafs) -
PARSIMONY/ap_tree_nlen.hxx
145 145 void swap_sons() OVERRIDE; 146 146 void swap_assymetric(AP_TREE_SIDE mode) OVERRIDE; 147 147 void moveNextTo(AP_tree_nlen *new_brother, AP_FLOAT rel_pos); // if unsure, use cantMoveNextTo to test if possible 148 private: 149 void moveNextToOld(AP_tree_nlen *new_brother, AP_FLOAT rel_pos); 150 void moveNextToNew(AP_tree_nlen *new_brother, AP_FLOAT rel_pos); 151 public: 148 152 void set_root() OVERRIDE; 149 153 150 154 // overload virtual methods from AP_tree: -
PARSIMONY/PARS_main.cxx
1921 1921 TEST_EXPECT_EQUAL(env.combines_performed(), 3); 1922 1922 1923 1923 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_ADD, "nucl-add-quick", PARSIMONY_ORG-23, env, true)); // test quick-add 1924 TEST_EXPECT_EQUAL(env.combines_performed(), 5 91);1924 TEST_EXPECT_EQUAL(env.combines_performed(), 587); 1925 1925 1926 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_ADD_NNI, "nucl-add-NNI", PARSIMONY_ORG-2 5, env, true)); // test add + NNI1927 TEST_EXPECT_EQUAL(env.combines_performed(), 7 76);1926 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_ADD_NNI, "nucl-add-NNI", PARSIMONY_ORG-24, env, true)); // test add + NNI 1927 TEST_EXPECT_EQUAL(env.combines_performed(), 781); 1928 1928 1929 1929 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_ADD_CALC_LENS, "nucl-add-quick-cl", PARSIMONY_ORG-23, env, true)); // test quick-add + calc_branchlengths 1930 TEST_EXPECT_EQUAL(env.combines_performed(), 72 7);1930 TEST_EXPECT_EQUAL(env.combines_performed(), 726); 1931 1931 1932 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_ADD_NNI_CALC_LENS, "nucl-add-NNI-cl", PARSIMONY_ORG-2 5, env, true)); // test add + NNI + calc_branchlengths1933 TEST_EXPECT_EQUAL(env.combines_performed(), 9 14);1932 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_ADD_NNI_CALC_LENS, "nucl-add-NNI-cl", PARSIMONY_ORG-24, env, true)); // test add + NNI + calc_branchlengths 1933 TEST_EXPECT_EQUAL(env.combines_performed(), 922); 1934 1934 1935 1935 // test partial-add 1936 1936 { … … 1977 1977 } 1978 1978 1979 1979 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_ADD, "nucl-addPartialAsFull-CorGlutP", PARSIMONY_ORG, env, false)); 1980 TEST_EXPECT_EQUAL(env.combines_performed(), 25 4);1980 TEST_EXPECT_EQUAL(env.combines_performed(), 256); 1981 1981 TEST_EXPECT_EQUAL(is_partial(CorGlutP), 0); // check CorGlutP was added as full sequence 1982 1982 TEST_EXPECTATION(addedAsBrotherOf("CorGlutP", "CorGluta", env)); // partial created from CorGluta gets inserted next to CorGluta 1983 1983 … … 2091 2091 TEST_EXPECT_EQUAL(env.combines_performed(), 5); 2092 2092 2093 2093 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_ADD, "prot-add-quick", PARSIMONY_ORG, env, true)); // test quick-add 2094 TEST_EXPECT_EQUAL(env.combines_performed(), 30 6);2094 TEST_EXPECT_EQUAL(env.combines_performed(), 304); 2095 2095 2096 2096 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_ADD_NNI, "prot-add-NNI", PARSIMONY_ORG, env, true)); // test add + NNI 2097 TEST_EXPECT_EQUAL(env.combines_performed(), 44 2);2097 TEST_EXPECT_EQUAL(env.combines_performed(), 449); 2098 2098 2099 2099 // test partial-add 2100 2100 { … … 2139 2139 } 2140 2140 2141 2141 TEST_EXPECTATION(modifyingTopoResultsIn(MOD_QUICK_ADD, "prot-addPartialAsFull-MucRaceP", PARSIMONY_ORG+6, env, false)); 2142 TEST_EXPECT_EQUAL(env.combines_performed(), 1 75);2142 TEST_EXPECT_EQUAL(env.combines_performed(), 182); 2143 2143 TEST_EXPECT_EQUAL(is_partial(MucRaceP), 0); // check MucRaceP was added as full sequence 2144 2144 // TEST_EXPECTATION(addedAsBrotherOf("MucRaceP", "MucRacem", env)); // partial created from MucRacem gets inserted next to MucRacem 2145 2145 // TEST_EXPECTATION(addedAsBrotherOf("MucRaceP", "AbdGlauc", env)); // partial created from MucRacem gets inserted next to MucRacem … … 2549 2549 TEST_EXPECT_VALID_TREE(env.root_node()); 2550 2550 } 2551 2551 2552 TEST_EXPECT_EQUAL(env.combines_performed(), 44 44); // @@@ distribute2552 TEST_EXPECT_EQUAL(env.combines_performed(), 4455); // @@@ distribute 2553 2553 } 2554 2554 2555 2555 void TEST_node_edge_resources() { -
UNIT_TESTER/run/pars/nucl-add-NNI-cl.tree.expected
5 5 ( 6 6 ( 7 7 ( 8 CorGluta:0.329, 9 CytAquat:0.333 10 ):0.088, 11 CloBifer:0.190 12 ):0.050, 8 ( 9 ( 10 CloTyro3:1.000, 11 CloTyro4:0.027 12 ):0.049, 13 CloTyrob:0.013 14 ):0.000, 15 CloTyro2:0.013 16 ):0.317, 17 CloInnoc:0.384 18 ):0.179, 19 CloPaste:0.224 20 ):0.016, 21 CloCarni:0.171 22 ):0.029, 23 ( 24 ( 13 25 ( 14 26 CloButy2:0.000, 15 27 CloButyr:0.000 16 ):0.058 17 ):0.277, 28 ):0.087, 29 CloBifer:0.204 30 ):0.066, 18 31 ( 19 CloCarni:0.118, 20 CloPaste:0.224 21 ):0.031 22 ):0.044, 23 ( 24 ( 25 ( 26 ( 27 CloTyro3:1.000, 28 CloTyro4:0.027 29 ):0.049, 30 CloTyrob:0.013 31 ):0.000, 32 CloTyro2:0.013 33 ):0.366, 34 CloInnoc:0.370 35 ):0.211 36 ):0.165, 32 CorGluta:0.274, 33 CytAquat:0.333 34 ):0.053 35 ):0.274 36 ):0.088, 37 37 ( 38 CorAquat:0.0 76,38 CorAquat:0.089, 39 39 CurCitre:0.086 40 ):0.0 2641 ):0.0 76,42 CelBiazo:0.0 76);43 No newline at end of file 40 ):0.052 41 ):0.057, 42 CelBiazo:0.057); 43 No newline at end of file -
UNIT_TESTER/run/pars/nucl-add-NNI.tree.expected
5 5 ( 6 6 ( 7 7 ( 8 CorGluta:0.329, 9 CytAquat:0.333 10 ):0.088, 11 CloBifer:0.190 12 ):0.050, 8 ( 9 ( 10 CloTyro3:1.000, 11 CloTyro4:0.027 12 ):0.049, 13 CloTyrob:0.013 14 ):0.000, 15 CloTyro2:0.013 16 ):0.317, 17 CloInnoc:0.384 18 ):0.179, 19 CloPaste:0.224 20 ):0.016, 21 CloCarni:0.171 22 ):0.029, 23 ( 24 ( 13 25 ( 14 26 CloButy2:0.000, 15 27 CloButyr:0.000 16 ):0.058 17 ):0.277, 28 ):0.087, 29 CloBifer:0.204 30 ):0.066, 18 31 ( 19 CloCarni:0.118, 20 CloPaste:0.224 21 ):0.031 22 ):0.044, 23 ( 24 ( 25 ( 26 ( 27 CloTyro3:1.000, 28 CloTyro4:0.027 29 ):0.049, 30 CloTyrob:0.013 31 ):0.000, 32 CloTyro2:0.013 33 ):0.366, 34 CloInnoc:0.370 35 ):0.211 36 ):0.165, 32 CorGluta:0.274, 33 CytAquat:0.333 34 ):0.053 35 ):0.274 36 ):0.088, 37 37 ( 38 CorAquat:0.0 76,38 CorAquat:0.089, 39 39 CurCitre:0.086 40 ):0.0 2941 ):0.0 76,42 CelBiazo:0.0 76);43 No newline at end of file 40 ):0.057 41 ):0.057, 42 CelBiazo:0.057); 43 No newline at end of file