File: UPGMAAlgorithm.h

package info (click to toggle)
clustalx 2.1%2Blgpl-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,868 kB
  • sloc: cpp: 40,050; sh: 163; xml: 102; makefile: 15
file content (59 lines) | stat: -rw-r--r-- 1,975 bytes parent folder | download | duplicates (11)
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
#ifndef __UPGMAALGORITHM_H
#define __UPGMAALGORITHM_H

#include "Node.h" 
#include <limits>
#include "../../general/clustalw.h"
#include "../AlignmentSteps.h"
#include "RootedGuideTree.h"
#include <list>
#include <memory>

namespace clustalw
{

using namespace std;

class UPGMAAlgorithm
{
    public:
        bool overwriteMatrix; 

        UPGMAAlgorithm();
        auto_ptr<AlignmentSteps> generateTree(RootedGuideTree* phyTree, 
                                    DistMatrix* distMat, SeqInfo* seqInfo,
                                    bool overwrite, ofstream* tree = 0);
        void setVerbose(bool _verbose){verbose = _verbose;}                            
                  
    private:
        Node **initialiseNodes(double *distanceMatrix, int firstSeq);

        Node *doUPGMA(Node **nodes, ofstream* tree);
        void printAllNodes(Node** nodes);
        void addAlignmentStep(vector<int>* group1, vector<int>* group2);
        Node** getNodeWithMinDist(Node** clusters);
        void recomputeNodeToJoin1DistMatRow(Node* nodeToJoin1, double** nodeToJoin2DistIter);
        void computeAllOtherDistsToNewNode(Node* nodeToJoin1, Node* nodeToJoin2,
                                                   double** nodeToJoin2DistIter);
        void computeDistsUpToNodeToJoin2(Node* nToJoin1, Node* nToJoin2, 
                                         double** nodeToJoin2DistIter);
        void computeDistsForNodesAfterNode2(Node* nToJoin2);
        void movePtrPastUnusedDistances(double** ptrToDist)
        {            
            while(**ptrToDist < 0)
            {
                (*ptrToDist)++;
            }
        }
        double calcNewDist(double dist1, double dist2);                             
        //vector<Node*>::iterator getIterToNodeWithMinDist(vector<Node*>* nodesLeft);
        
        auto_ptr<AlignmentSteps> progSteps;
        int numSeqs; 
        bool verbose;
        int orderNode1, orderNode2, orderNewNode;
};

}

#endif