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
|
#include "muscle.h"
#include "seqvect.h"
#include "distfunc.h"
#include "clust.h"
#include "clustsetdf.h"
#include "tree.h"
#include "clust.h"
#include "distcalc.h"
#include <math.h>
static void TreeFromSeqVect_NJ(const DistFunc &DF, CLUSTER Cluster, Tree &tree)
{
ClustSetDF CSD(DF);
Clust C;
C.Create(CSD, Cluster);
tree.FromClust(C);
}
static void TreeFromSeqVect_UPGMA(const DistFunc &DF, CLUSTER Cluster, Tree &tree)
{
LINKAGE Linkage = LINKAGE_Undefined;
switch (Cluster)
{
case CLUSTER_UPGMA:
Linkage = LINKAGE_Avg;
break;
case CLUSTER_UPGMAMin:
Linkage = LINKAGE_Min;
break;
case CLUSTER_UPGMAMax:
Linkage = LINKAGE_Max;
break;
case CLUSTER_UPGMB:
Linkage = LINKAGE_Biased;
break;
default:
Quit("TreeFromSeqVect_UPGMA, CLUSTER_%u not supported", Cluster);
}
DistCalcDF DC;
DC.Init(DF);
UPGMA2(DC, tree, Linkage);
}
void TreeFromSeqVect(const SeqVect &v, Tree &tree, CLUSTER Cluster,
DISTANCE Distance, ROOT Root)
{
DistFunc DF;
DistUnaligned(v, Distance, DF);
if (CLUSTER_NeighborJoining == Cluster)
TreeFromSeqVect_NJ(DF, Cluster, tree);
else
TreeFromSeqVect_UPGMA(DF, Cluster, tree);
FixRoot(tree, Root);
}
|