830 - MaqIndex::BuildIndex()

From Genome Analysis Wiki
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();
}