830 - MaqIndex::BuildIndex()

From Genome Analysis Wiki
Revision as of 13:38, 28 October 2013 by Goncalo (talk | contribs) (Created page with "<source lang="cpp"> void MaqIndex::BuildIndex() { // This function could use quite a lot of memory ... // 4 bytes per word // 4 bytes per position // 4 bytes per ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
void MaqIndex::BuildIndex()
{
	// This function could use quite a lot of memory ...
	//    4 bytes per word
	//    4 bytes per position
	//    4 bytes per word in the word index

	bases = 0;
	for (unsigned int i = 0; i < mask.Length(); i++)
		if (mask[i] == '1')
			bases++;

	unsigned int indexSize = 0;
	for (unsigned int i = 0; i < reference.Length(); i++)
		if (GetReferenceWord(i) != -1)
			indexSize++;

	sortedPositions.PreAllocate(indexSize);
	for (unsigned int i = 0; i < reference.Length(); i++)
		if (GetReferenceWord(i) != -1)
			sortedPositions.Push(i);

	SortIndex();
}