12 #ifndef AP_TREE_NLEN_HXX
13 #define AP_TREE_NLEN_HXX
15 #ifndef _GLIBCXX_IOSTREAM
18 #ifndef _GLIBCXX_CLIMITS
30 #ifndef AP_MAIN_TYPE_HXX
95 :
AP_tree_root(aliView, seq_proto, add_delete_callbacks, scaling),
103 bool was_saved()
const {
return has_been_saved; }
117 Level remembered_for_frame;
122 void restore_structure(
const NodeState& state);
124 void restore_sequence_nondestructive(
const NodeState& state);
125 void restore_root(
const NodeState& state);
137 remembered_for_frame(0)
139 edge[0] = edge[1] = edge[2] =
NULp;
140 index[0] = index[1] = index[2] = 0;
146 void unhash_sequence();
152 void revertToPreviousState(
Level curr_frameLevel,
bool& rootPopped);
154 void restore_nondestructive(
const NodeState& state);
155 bool acceptCurrentState(
Level frame_level);
164 unsigned marked_childs = get_leftson()->gr.mark_sum + get_rightson()->gr.mark_sum;
165 if (marked_childs == gr.mark_sum)
return false;
166 gr.mark_sum = marked_childs;
171 if (recalc_marked_from_sons() &&
father) {
172 get_father()->recalc_marked_from_sons_and_forward_upwards();
177 void insert(AP_tree_nlen *new_brother);
178 void initial_insert(AP_tree_nlen *new_brother, AP_pars_root *troot);
183 void moveNextTo(AP_tree_nlen *new_brother,
AP_FLOAT rel_pos);
184 void set_root() OVERRIDE;
193 void exchange(AP_tree_nlen *other);
196 void parsimony_rec(
char *mutPerSite =
NULp);
203 void setBranchlen(
double leftLen,
double rightLen) { leftlen = leftLen; rightlen = rightLen; }
205 const char* fullname()
const;
206 const char* sortByName();
210 int indexOf(
const AP_tree_edge *e)
const {
int i;
for (i=0; i<3; i++)
if (edge[i]==e)
return i;
return -1; }
212 AP_tree_edge* edgeTo(
const AP_tree_nlen *brother)
const;
214 int unusedEdgeIndex()
const;
221 char *getSequenceCopy();
223 #if defined(PROVIDE_TREE_STRUCTURE_TESTS)
225 Validity sequence_state_valid()
const;
227 #endif // PROVIDE_TREE_STRUCTURE_TESTS
229 #if defined(PROVIDE_PRINT)
230 void print(std::ostream& out,
int indentLevel,
const char *
label)
const;
233 #if defined(UNIT_TESTS)
240 get_leftson()->remember_subtree(main);
241 get_rightson()->remember_subtree(main);
251 #if defined(ASSERTION_USED) || defined(UNIT_TESTS)
274 static long timeStamp;
278 bool is_linked()
const {
return node[0]; }
280 void set_inner_branch_length_and_calc_adj_leaf_lengths(
AP_FLOAT bcosts);
290 #if defined(UNIT_TESTS) // UT_DIFF
291 friend void TEST_basic_tree_modifications();
318 long Age()
const {
return age; }
322 bool is_root_edge()
const {
return node[0]->father != node[1] && node[1]->father != node[0]; }
323 bool is_leaf_edge()
const {
return node[0]->is_leaf() || node[1]->is_leaf(); }
327 ? node[0]->gr.mark_sum+node[1]->gr.mark_sum
367 operator bool()
const {
375 curr = curr->next_in_chain;
384 #error ap_tree_nlen.hxx included twice
385 #endif // AP_TREE_NLEN_HXX
bool isConnectedTo(const AP_tree_nlen *n) const
void moveNextTo(AP_tree *node, AP_FLOAT rel_pos) OVERRIDE
AP_tree_edge * makeEdge(AP_tree_nlen *n1, AP_tree_nlen *n2)
bool may_be_recollected() const
AP_tree_edge(AP_tree_nlen *node1, AP_tree_nlen *node2)
int indexOf(const AP_tree_edge *e) const
Level last_remembered_frame() const
Mutations nni_rec(EdgeSpec whichEdges, AP_BL_MODE mode, AP_tree_nlen *skipNode, bool includeStartEdge)
int main(int argc, char **argv)
AP_tree_nlen * sonNode() const
AP_pars_root(AliView *aliView, AP_sequence *seq_proto, bool add_delete_callbacks, const group_scaling *scaling)
AP_tree_edge * operator*()
void relink(AP_tree_nlen *node1, AP_tree_nlen *node2)
Mutations stored_costs() const
void set_visited(bool vis)
int rec_width[CUSTOM_DEPTHS]
bool recalc_marked_from_sons()
#define OVERRIDE_SEQ_ACCESSORS(SEQTYPE, BASETREETYPE)
virtual void insert(AP_tree *new_brother)
friend std::ostream & operator<<(std::ostream &, const AP_tree_edge *)
#define DOWNCAST(totype, expr)
void change_parsimony_start(Mutations offset)
KL_DYNAMIC_THRESHOLD_TYPE
EdgeChain(AP_tree_edge *start_, EdgeSpec whichEdges, bool depthFirst, const AP_tree_nlen *skip=NULp, bool includeStart=true)
virtual AP_tree * REMOVE()
bool push_node(AP_tree_nlen *node, AP_STACK_MODE)
POS_TREE1 * get_father() const
int indexOf(const AP_tree_nlen *n) const
DEFINE_TREE_ACCESSORS(AP_tree_root, AP_tree)
void initial_insert(AP_tree *new_brother, AP_tree_root *troot) OVERRIDE
static void destroy(AP_tree_nlen *root)
bool is_leaf_edge() const
std::ostream & operator<<(std::ostream &, const AP_tree_edge *)
AP_tree_nlen(AP_pars_root *troot)
const EdgeChain & operator++()
const StateStack & get_states() const
void destroyNode(AP_tree_nlen *node)
bool next_to_folded_group() const
KL_RECURSION_TYPE rec_type
QuadraticThreshold thresFunctor
virtual void initial_insert(AP_tree *new_brother, AP_tree_root *troot)
void insert(AP_tree *new_brother) OVERRIDE
Mutations calc_branchlengths()
void recalc_marked_from_sons_and_forward_upwards()
void destroyEdge(AP_tree_edge *edge)
TreeNode * makeNode() const OVERRIDE
bool allBranchlengthsAreDefined(AP_tree_nlen *tree)
AP_tree_nlen * otherNode(const AP_tree_nlen *n) const
friend class AP_tree_nlen
bool is_root_edge() const
void destroyNode(AP_tree_nlen *node)
static void initialize(AP_tree_nlen *root)
double calculate(double x) const
bool kl_rec(const KL_params &KL, const int rec_depth, Mutations pars_best)
void mixTree(int repeat, int percent, EdgeSpec whichEdges)
Mutations nni_mutPerSite(Mutations pars_one, AP_BL_MODE mode, MutationsPerSite *mps)
AP_tree_nlen * notSonNode() const
void setBranchlen(double leftLen, double rightLen)