/TwoBit

2-bit reader in C++, reads .2bit formatted sequence data

Primary LanguageC++Apache License 2.0Apache-2.0

2-bit reader

This is a (work in progress) reader implementation, based on the specs at UCSC, http://genome.ucsc.edu/FAQ/FAQformat#format7. The implementation is intended to be more or less thread safe; to achieve that, each TwoBitSequence has it's own read-only file handle to the 2-bit data.

TODO

Example use

The following converts a 2-bit file into FASTA format, on stdout.

TwoBit::TwoBitFile f("/home/vanderva/.ucscgenome/hg19.2bit");
std::string buffer;
for (const std::string& s : f.sequenceNames())
{
	f[s].getSequence(buffer);
	std::cout << ">" << s << std::endl;
	for (uint32_t i = 0; i < buffer.size(); i += 80)
	{
		std::cout << buffer.substr(i, 80) << '\n';
	}
	std::cout.flush();
}