Example #1
0
void DistPWScoreDist(const SeqVect &v, DistFunc &DF)
	{
	SEQWEIGHT SeqWeightSave = GetSeqWeightMethod();
	SetSeqWeightMethod(SEQWEIGHT_Henikoff);

	const unsigned uSeqCount = v.Length();
	DF.SetCount(uSeqCount);

	const unsigned uPairCount = (uSeqCount*(uSeqCount + 1))/2;
	unsigned uCount = 0;
	SetProgressDesc("PW ScoreDist");
	for (unsigned uSeqIndex1 = 0; uSeqIndex1 < uSeqCount; ++uSeqIndex1)
		{
		const Seq &s1 = v.GetSeq(uSeqIndex1);
		MSA msa1;
		msa1.FromSeq(s1);
		for (unsigned uSeqIndex2 = 0; uSeqIndex2 < uSeqIndex1; ++uSeqIndex2)
			{
			if (0 == uCount%20)
				Progress(uCount, uPairCount);
			++uCount;
			const Seq &s2 = v.GetSeq(uSeqIndex2);
			MSA msa2;
			msa2.FromSeq(s2);
		
			PWPath Path;
			MSA msaOut;
			AlignTwoMSAs(msa1, msa2, msaOut, Path, false, false);

			float d = (float) GetScoreDist(msaOut, 0, 1);
			DF.SetDist(uSeqIndex1, uSeqIndex2, d);
			}
		}
	ProgressStepsDone();

	SetSeqWeightMethod(SeqWeightSave);
	}
Example #2
0
void DistCalcMSA::CalcDistRange(unsigned i, dist_t Dist[]) const
	{
	for (unsigned j = 0; j < i; ++j)
		{
		switch (m_Distance)
			{
		case DISTANCE_PctIdKimura:
			{
			const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j);
			Dist[j] = (float) KimuraDist(PctId);
			break;
			}
		case DISTANCE_PctIdLog:
			{
			const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j);
			Dist[j] = (float) PctIdToMAFFTDist(PctId);
			break;
			}
		case DISTANCE_ScoreDist:
			{
			double GetScoreDist(const MSA &msa, unsigned SeqIndex1, unsigned SeqIndex2);
			Dist[j] = (float) GetScoreDist(*m_ptrMSA, i, j);
			continue;
			}
		case DISTANCE_Edit:
			{
			const float PctId = (float) m_ptrMSA->GetPctIdentityPair(i, j);
			if (PctId > 1.0)
				Quit("Internal error, DISTANCE_Edit, pct id=%.3g", PctId);
			Dist[j] = (float) 1.0 - PctId;
			break;
			}
		default:
			Quit("DistCalcMSA: Invalid DISTANCE_%u", m_Distance);
			}
		}
	}