129 for (
int i=0;
i<nnodes; ++
i) {
156 if (idmin == jdmin) {
157 cerr <<
"Error: You cannot join node " << idmin <<
" to itself.\n";
161 if (idmin < 0 || idmin > maxIndex || jdmin < 0 || jdmin > maxIndex || m_nextNode < 0 || m_nextNode > maxIndex+1) {
165 cerr <<
"Warning: Out of range index in Join: " << idmin <<
" "
166 << jdmin <<
" " <<
m_nextNode <<
" Max allowed index: " << maxIndex << endl;
180 while (tmpi == idmin || tmpi == jdmin) {
185 cit->distance = tmpd;
189 tmpi = -(idmin+jdmin);
190 cerr <<
"Error: iterator found (id= " << cit->rowID <<
") not attached to hub.\n";
193 m_items[tmpi]->distance = tmpd;
199 cit->distance = tmpd;
201 tmpi = -(idmin+jdmin);
202 cerr <<
"Error: iterator found (id= " << cit->rowID <<
") not attached to hub for last nodes.\n";
205 m_items[tmpi]->distance = tmpd;
210 tmpi = (tmpi==idmin) ? jdmin : -(idmin+jdmin);
219 int* indexMap =
new int[
m_nseqs];
223 for (it=1; it<=
m_nseqs-1; ++it) {
247 int imin = 0, jmin = 0;
252 string newickStr =
"";
274 double* internalDistCorrection =
new double[
m_nseqs];
279 int* indexMap =
new int[
m_nseqs];
283 if (indexMap == 0 || internalDistCorrection == 0) {
290 internalDistCorrection[
i] = 0.0;
299 ppDists =
new double*[
m_nseqs];
312 for (
int it=1; it<=
m_nseqs-1; ++it) {
319 for (
i=0;
i<j; ++
i) {
321 if (ppDists[j][
i] < minval) {
322 minval = ppDists[j][
i];
333 idmin = indexMap[imin];
334 jdmin = indexMap[jmin];
344 ilen = 0.5*ppDists[imin][jmin] - internalDistCorrection[imin];
345 jlen = 0.5*ppDists[imin][jmin] - internalDistCorrection[jmin];
362 Join(idmin, jdmin, ilen, jlen);
364 internalDistCorrection[imin] = 0.5*ppDists[imin][jmin];
371 ppDists[k][imin] =
myMin(ppDists[k][imin], ppDists[k][jmin]);
372 ppDists[k][jmin] = 0.0;
373 ppDists[jmin][k] = 0.0;
374 ppDists[imin][k] = ppDists[k][imin];
377 ppDists[imin][imin] = 0.0;
391 delete [] internalDistCorrection;
double FastGet(const int RowIndex, const int ColIndex) const
static std::string toNestedString(const SeqTree &seqTree)
virtual void ComputeTree(SeqTree *tree, pProgressFunction pFunc)
virtual long GetNumLoopsForTreeCalc()
int numChildren(const TSeqIt &sit)
static const DistanceMatrix::TMatType INIT_MINIMA
static const ETreeMethod MY_TREE_METHOD
vector< SeqItem * > m_items
static const double REPLACE_NEG_DIST
virtual ~SLC_TreeAlgorithm()
static const int BAD_INDEX
virtual void SetDistMat(DistanceMatrix *dm)
static const Rootedness MY_ROOTEDNESS
static const int USED_ROW
virtual string toString()
void Join(int inode1, int inode2, double len1, double len2)
void midpointRootIfNeeded()
iter append_child(iter position)
pre_order_iterator begin() const
iter insert(iter position, const T &x)
unsigned int number_of_children(const iterator_base &) const
iter reparent(iter position, sibling_iterator begin, sibling_iterator end)
void(* pProgressFunction)(int Num, int Total)
double myMin(double a, double b)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.