Example #1
0
void PrintAlignment(
	const CSequence& inQuery, uint32 inQueryStart,
	const CSequence& inTarget, uint32 inTargetStart)
{
	assert(inQuery.length() == inTarget.length());
	
	CMutableSequence q(inQuery.begin(), inQuery.end());
	CMutableSequence s(inTarget.begin(), inTarget.end());
	
	while (q.length())
	{
		uint32 n = q.length();
		if (n > 60)
			n = 60;
		
		cout << setw(6) << inQueryStart << " ";
		for (uint32 i = 0; i < n; ++i)
		{
			if (q[i] == '-')
				cout << '-';
			else
			{
				cout << Decode(q[i]);
				++inQueryStart;
			}
		}
		cout << endl;

		cout << "       ";
		for (uint32 i = 0; i < n; ++i)
		{
			if (s[i] == q[i])
				cout << '|';
			else
				cout << " ";
		}
		cout << endl;

		cout << setw(6) << inTargetStart << " ";
		for (uint32 i = 0; i < n; ++i)
		{
			if (s[i] == '-')
				cout << '-';
			else
			{
				cout << Decode(s[i]);
				++inTargetStart;
			}
		}
		cout << endl << endl;
		
		q.erase(q.begin(), q.begin() + n);
		s.erase(s.begin(), s.begin() + n);
	}
	cout << endl;
}
Example #2
0
string Decode(CSequence inSequence)
{
	string result;
	for (CSequence::iterator i = inSequence.begin(); i != inSequence.end(); ++i)
		result.push_back(Decode(*i));
	return result;
}
Example #3
0
void MidLine(const CSequence& inQuery, const CSequence& inTarget,
	const CMatrix& inMatrix, uint32& outIdentity, uint32& outPositives,
	uint32& outGaps, string& outMidline)
{
	outMidline.clear();
	outIdentity = 0;
	outPositives = 0;
	outGaps = 0;
	
	assert(inQuery.length() == inTarget.length());
	if (inQuery.length() != inTarget.length())
		THROW(("To calculate a midline you need a query and a target of the same length"));

	for (CSequence::const_iterator a = inQuery.begin(), b = inTarget.begin();
		a != inQuery.end(); ++a, ++b)
	{
		if (*a == *b)
		{
			++outIdentity;
			++outPositives;
			outMidline += Decode(*a);
		}
		else if (inMatrix(*a, *b) > 0)
		{
			++outPositives;
			outMidline += '+';
		}
		else
		{
			if (*a == kSignalGapCode or *b == kSignalGapCode)
				++outGaps;
				
			outMidline += ' ';
		}
	}	
}