File: constrainttree.h

package info (click to toggle)
iqtree 1.5.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 9,780 kB
  • ctags: 11,529
  • sloc: cpp: 96,162; ansic: 59,874; python: 242; sh: 189; makefile: 45
file content (81 lines) | stat: -rw-r--r-- 2,308 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// C++ Interface: phylotree.h
//
// Description:
//
//
// Copyright: See COPYING file that comes with this distribution
//
//

#ifndef CONSTRAINTTREE_H
#define CONSTRAINTTREE_H

#include "mtree.h"
#include "alignment.h"

struct NNIMove;

/**
    ConstraintTree used to guide tree search.
    Note that constraint tree may contain only a subset of taxa from a full tree.
*/
class ConstraintTree : public MTree, public SplitIntMap {
public:

    ConstraintTree();

    /**
            initialize constraint tree
            @param constraint_file the name of the constraint tree file
            @param fulltaxname the full list of all taxa names
     */
    void initConstraint(const char *constraint_file, StrVector &fulltaxname);

    /** 
        check if a "partial" split defined by two taxa name sets is compatible with the constraint tree.
        The union of 2 taxa set do not need to comprise all taxa in the constraint tree.
        @param[in] tax1 names of taxa in one side of split
        @param[in] tax2 names of taxa in other side of split
        @return true if the split is compatible with all splits in the constraint tree, false otherwise.
     */ 
    bool isCompatible(StrVector &tax1, StrVector &tax2);

    /**
        check if a branch defined by two nodes in any tree is compatible or not
        @param node1 one end node of the branch
        @param node2 the other end node of the same branch
        @return TRUE if the branch is compatible, FALSE otherwise 
    */
    bool isCompatible(Node *node1, Node *node2);

    /**
        @param tree input tree
        @return TRUE if input tree is compatible with constraint, FALSE otherwise
    */
    bool isCompatible (MTree *tree);


    /** 
        check if an NNI is compatible with the constraint tree or not
        @param nni an NNIMove
        @return TRUE if the NNI is compatible, FALSE otherwise
    */
    bool isCompatible(NNIMove &nni);

    /**
        @param taxname taxon name to search for
        @return TRUE if constraint tree has a taxon, FALSE otherwise
    */
    bool hasTaxon(string &taxname) {
        return taxname_index.find(taxname) != taxname_index.end();
    }

protected:

    /* map from taxon name to its index, used for quick taxon name search */
    StringIntMap taxname_index;

};

#endif