Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a fastest way to ouput the unique kmer sequence ? not only output the kmer count #1

Open
xiongxu opened this issue Mar 11, 2020 · 1 comment

Comments

@xiongxu
Copy link

xiongxu commented Mar 11, 2020

let kh_val(h)=y when put the key into hash?

@slw287r
Copy link

slw287r commented Apr 8, 2020

Not sure if this is efficient enough, you can unpack the kmer out of uint64_t given k to a seq string:

#include <inttypes.h>

void u64s(uint64_t x, char* s, size_t k)
{
	size_t i = 0;
	for (i = 0; i < k; ++i) {
		s[k - i - 1] = "ACGT"[(uint8_t) x & 0x3];
		x >>= 2;
	}
	s[i] = '\0';
}

static void print_hist(const kc_c1_t *h)
{
	int i, j = 31;
	khint_t k;
	uint64_t cnt[256] = {0};
	char s[j + 1];
	//for (i = 0; i < 256; ++i) cnt[i] = 0;
	for (k = 0; k < kh_end(h); ++k)
	{
		if (kh_exist(h, k))
		{
			u64s(kh_key(h, k), s, j);
			printf("%"PRIu64"\t%d\t%s\n", kh_key(h, k), kh_val(h, k), s);
			//++cnt[kh_val(h, k) < 256? kh_val(h, k) : 255];
		}
	}
	/*
	for (i = 1; i < 256; ++i)
		printf("%d\t%ld\n", i, (long)cnt[i]);
	*/
}

reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants