NOT WORKING!!! backup only

This commit is contained in:
Heng Li
2020-03-24 00:44:56 -04:00
parent e6ef2fb56f
commit 59a9d62df9
8 changed files with 131 additions and 714 deletions
+38 -11
View File
@@ -16,7 +16,7 @@
typedef struct
{
//can represent at most 64-mer
uint64_t x[2];
uint64_t x[4];
} Hash_code;
typedef struct {
@@ -83,16 +83,45 @@ inline uint64_t get_HPC_code(HPC_seq* seq, uint64_t* end_pos)
}
inline void k_mer_append(Hash_code* code, uint64_t c, int k)
inline void init_Hash_code(Hash_code* code)
{
uint64_t mask = ALL >> (64 -k);
code->x[0] = ((code->x[0]<<1) | (c&1)) & mask;
code->x[1] = ((code->x[1]<<1) | (c>>1)) & mask;
code->x[0] = code->x[1] = code->x[2] = code->x[3] = 0;
}
inline void Hashcode_to_string(Hash_code* code, char* str, int k)
inline void k_mer_append(Hash_code* code, uint64_t c, int k)
{
uint64_t mask = ALL >> (64 - k), shift = k - 1;
code->x[0] = ((code->x[0]<<1) | (c&1)) & mask;
code->x[1] = ((code->x[1]<<1) | (c>>1)) & mask;
code->x[2] = code->x[2] >> 1 | (uint64_t)(1 - (c&1)) << shift;
code->x[3] = code->x[3] >> 1 | (uint64_t)(1 - (c>>1)) << shift;
}
static inline uint64_t yak_hash64(uint64_t key, uint64_t mask) // invertible integer hash function
{
key = (~key + (key << 21)) & mask; // key = (key << 21) - key - 1;
key = key ^ key >> 24;
key = ((key + (key << 3)) + (key << 8)) & mask; // key * 265
key = key ^ key >> 14;
key = ((key + (key << 2)) + (key << 4)) & mask; // key * 21
key = key ^ key >> 28;
key = (key + (key << 31)) & mask;
return key;
}
static inline uint64_t yak_hash64_64(uint64_t key)
{
key = ~key + (key << 21);
key = key ^ key >> 24;
key = (key + (key << 3)) + (key << 8);
key = key ^ key >> 14;
key = (key + (key << 2)) + (key << 4);
key = key ^ key >> 28;
key = key + (key << 31);
return key;
}
inline void Hashcode_to_string(Hash_code* code, char* str, int k) // FIXME: not working
{
uint8_t c;
int i;
@@ -108,7 +137,5 @@ inline void Hashcode_to_string(Hash_code* code, char* str, int k)
}
void init_HPC_seq(HPC_seq* seq, char* str, long long l);
void init_Hash_code(Hash_code* code);
#endif
#endif