2 struct highOccPatternCell
{
3 unsigned int l
[1024*1024];
4 unsigned int r
[1024*1024];
5 struct highOccPatternCell
* next
;
10 unsigned int ho_hashTableSize
=14814445;
11 unsigned int ho_prime
=3080419483; //a relative prime to the dna length
12 unsigned int ho_hash_a
=0, ho_hash_b
=0;
13 unsigned int ho_ttlItem
=0;
14 unsigned int ho_ttlOccurrence
=0;
17 typedef struct hashItem
* hashItemPtr
;
21 unsigned int occCount
;
22 unsigned int occIndex
;
27 typedef struct hashTyp
* hashTypPtr
;
34 hashTypPtr ho_hashtable
;
37 //===============================
38 const unsigned int ho_Size
= 104857600;
40 typedef struct ho_cellSpace
* ho_cellSpacePtr
;
45 struct ho_cellSpace
* next
;
49 ho_cellSpacePtr ho_root
;
50 ho_cellSpacePtr ho_currentRoot
;
52 void ho_initialize() {
53 // fprintf(stderr,"Initialize temporary hash.\n");
54 srand((unsigned)time(0));
55 ho_hash_a
= rand()%ho_prime
;
56 ho_hash_b
= rand()%ho_prime
;
58 ho_root
=malloc(sizeof(struct ho_cellSpace
));
59 ho_root
->saL
= malloc(sizeof(unsigned int) * ho_Size
);
60 ho_root
->saR
= malloc(sizeof(unsigned int) * ho_Size
);
64 ho_currentRoot
=ho_root
;
71 void ho_append(unsigned int saL
, unsigned int saR
) {
72 if (ho_currentRoot
->count
>= ho_Size
) {
73 ho_currentRoot
->next
= malloc(sizeof(struct ho_cellSpace
));
74 ho_currentRoot
=ho_currentRoot
->next
;
76 ho_currentRoot
->saL
=malloc(sizeof(unsigned int)*ho_Size
);
77 ho_currentRoot
->saR
=malloc(sizeof(unsigned int)*ho_Size
);
78 ho_currentRoot
->count
=0;
79 ho_currentRoot
->next
=NULL
;
81 ho_currentRoot
->saL
[ho_currentRoot
->count
]=saL
;
82 ho_currentRoot
->saR
[ho_currentRoot
->count
]=saR
;
83 ho_currentRoot
->count
++;
85 ho_ttlOccurrence
+=saR
-saL
+1;
88 void ho_recurFree(ho_cellSpacePtr node
) {
90 ho_recurFree(node
->next
);
94 void ho_recurFreeItem(hashItemPtr node
) {
96 ho_recurFreeItem(node
->next
);
101 unsigned int ho_count() {
105 ho_recurFree(ho_root
);
107 for (i
=0;i
<ho_hashTableSize
;i
++) {
108 if (ho_hashtable
[i
].count
>0) {
109 ho_recurFreeItem(ho_hashtable
[i
].item
);
116 unsigned int ho_hash(unsigned int key
) {
118 unsigned long long multipleA
=(key
* ho_hash_a
)% ho_prime
;
119 unsigned int g
=(unsigned int) (( multipleA
+ ho_hash_b
) % ho_prime
);
122 unsigned int f
=g
% (ho_hashTableSize
);