void Test() { SetListFileName("c:\\tmp\\lobster.log", false); DistCalcTest DC; Tree tree; UPGMA2(DC, tree, LINKAGE_Avg); }
void TestEstrings() { SetListFileName("c:\\tmp\\muscle.log", false); //{ //short es1[] = { -1, 1, -1, 0 }; //short es2[] = { 1, -1, 2, 0 }; //short esa[] = { -2, 1, -1, 0 }; //test(es1, es2, esa); //} //{ //short es1[] = { 2, -1, 2, 0 }; //short es2[] = { 1, -1, 3, -1, 1, 0 }; //short esa[] = { 1, -1, 1, -1, 1, -1, 1, 0 }; //test(es1, es2, esa); //} //{ //short es1[] = { -1, 3, 0 }; //short es2[] = { 2, -1, 2, 0 }; //short esa[] = { -1, 1, -1, 2, 0 }; //test(es1, es2, esa); //} //{ //short es1[] = { -1, 1, -1, 1, 0}; //short es2[] = { 4, 0 }; //short esa[] = { -1, 1, -1, 1, 0}; //test(es1, es2, esa); //} //{ //short es1[] = { 1, -1, 1, -1, 0}; //short es2[] = { 4, 0 }; //short esa[] = { 1, -1, 1, -1, 0}; //test(es1, es2, esa); //} //{ //short es1[] = { 1, -1, 1, -1, 0}; //short es2[] = { -1, 4, -1, 0 }; //short esa[] = { -1, 1, -1, 1, -2, 0}; //test(es1, es2, esa); //} { short es1[] = { 106, -77, 56, -2, 155, -3, 123, -2, 0}; short es2[] = { 50, -36, 34, -3, 12, -6, 1, -6, 18, -17, 60, -5, 349, -56, 0 }; short esa[] = { 0 }; test(es1, es2, esa); } exit(0); }
void TestBiPart() { SetListFileName("c:\\tmp\\lobster.log", false); Tree tree; TextFile fileIn("c:\\tmp\\test.phy"); tree.FromFile(fileIn); tree.LogMe(); const unsigned uNodeCount = tree.GetNodeCount(); unsigned *Leaves1 = new unsigned[uNodeCount]; unsigned *Leaves2 = new unsigned[uNodeCount]; PhyEnumEdgeState ES; bool bDone = false; for (;;) { unsigned uCount1 = uInsane; unsigned uCount2 = uInsane; bool bOk = PhyEnumBiParts(tree, ES, Leaves1, &uCount1, Leaves2, &uCount2); Log("PEBP=%d ES.Init=%d ES.ni1=%d ES.ni2=%d\n", bOk, ES.m_bInit, ES.m_uNodeIndex1, ES.m_uNodeIndex2); if (!bOk) break; Log("\n"); Log("Part1: "); for (unsigned n = 0; n < uCount1; ++n) Log(" %d(%s)", Leaves1[n], tree.GetLeafName(Leaves1[n])); Log("\n"); Log("Part2: "); for (unsigned n = 0; n < uCount2; ++n) Log(" %d(%s)", Leaves2[n], tree.GetLeafName(Leaves2[n])); Log("\n"); } }
void SPTest() { SetPPScore(PPSCORE_SV); SetListFileName("c:\\tmp\\muscle.log", false); TextFile file1("c:\\tmp\\msa1.afa"); TextFile file2("c:\\tmp\\msa2.afa"); MSA msa1; MSA msa2; msa1.FromFile(file1); msa2.FromFile(file2); Log("msa1=\n"); msa1.LogMe(); Log("msa2=\n"); msa2.LogMe(); const unsigned uColCount = msa1.GetColCount(); if (msa2.GetColCount() != uColCount) Quit("Different lengths"); const unsigned uSeqCount1 = msa1.GetSeqCount(); const unsigned uSeqCount2 = msa2.GetSeqCount(); const unsigned uSeqCount = uSeqCount1 + uSeqCount2; MSA::SetIdCount(uSeqCount); for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount1; ++uSeqIndex1) { msa1.SetSeqWeight(uSeqIndex1, 1.0); msa1.SetSeqId(uSeqIndex1, uSeqIndex1); } for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqCount2; ++uSeqIndex2) { msa2.SetSeqWeight(uSeqIndex2, 1.0); msa2.SetSeqId(uSeqIndex2, uSeqCount1 + uSeqIndex2); } MSA alnA; MSA alnB; char strPathA[1024]; char strPathB[1024]; MakePath(uColCount, INDELS, strPathA); MakePath(uColCount, INDELS, strPathB); PWPath PathA; PWPath PathB; PathA.FromStr(strPathA); PathB.FromStr(strPathB); Log("PathA=\n"); PathA.LogMe(); Log("PathB=\n"); PathB.LogMe(); AlignTwoMSAsGivenPath(PathA, msa1, msa2, alnA); AlignTwoMSAsGivenPath(PathB, msa1, msa2, alnB); for (unsigned uSeqIndex = 0; uSeqIndex < uSeqCount; ++uSeqIndex) { alnA.SetSeqWeight(uSeqIndex, 1.0); alnB.SetSeqWeight(uSeqIndex, 1.0); } unsigned Seqs1[1024]; unsigned Seqs2[1024]; for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount1; ++uSeqIndex1) Seqs1[uSeqIndex1] = uSeqIndex1; for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqCount2; ++uSeqIndex2) Seqs2[uSeqIndex2] = uSeqCount1 + uSeqIndex2; MSA msaA1; MSA msaA2; MSA msaB1; MSA msaB2; MSAFromSeqSubset(alnA, Seqs1, uSeqCount1, msaA1); MSAFromSeqSubset(alnB, Seqs1, uSeqCount1, msaB1); MSAFromSeqSubset(alnA, Seqs2, uSeqCount2, msaA2); MSAFromSeqSubset(alnB, Seqs2, uSeqCount2, msaB2); for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount1; ++uSeqIndex1) { msaA1.SetSeqWeight(uSeqIndex1, 1.0); msaB1.SetSeqWeight(uSeqIndex1, 1.0); } for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqCount2; ++uSeqIndex2) { msaA2.SetSeqWeight(uSeqIndex2, 1.0); msaB2.SetSeqWeight(uSeqIndex2, 1.0); } Log("msaA1=\n"); msaA1.LogMe(); Log("msaB1=\n"); msaB1.LogMe(); Log("msaA2=\n"); msaA2.LogMe(); Log("msaB2=\n"); msaB2.LogMe(); Log("alnA=\n"); alnA.LogMe(); Log("AlnB=\n"); alnB.LogMe(); Log("\nSPA\n---\n"); SCORE SPA = ObjScoreSP(alnA); Log("\nSPB\n---\n"); SCORE SPB = ObjScoreSP(alnB); Log("\nXPA\n---\n"); SCORE XPA = ObjScoreXP(msaA1, msaA2); Log("\nXPB\n---\n"); SCORE XPB = ObjScoreXP(msaB1, msaB2); Log("SPA=%.4g SPB=%.4g Diff=%.4g\n", SPA, SPB, SPA - SPB); Log("XPA=%.4g XPB=%.4g Diff=%.4g\n", XPA, XPB, XPA - XPB); }