-
Notifications
You must be signed in to change notification settings - Fork 6
/
utilities.cpp
74 lines (58 loc) · 1.52 KB
/
utilities.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "utilities.h"
using namespace std;
extern Param param;
static time_t time_begin;
static time_t time_last;
time_t Initial_Time() {
time_begin = time(NULL);
time_last = time_begin;
return time_begin;
};
//time used during the past step
time_t Cal_StepTime() {
time_t tused = time(NULL)-time_last;
time_last = time(NULL);
return tused;
};
//total time exhaust
time_t Cal_AllTime() {
return time(NULL)-time_begin;
};
//current time on string format
char * Curr_Time() {
time_t t=time(NULL);
char *atime=ctime(&t);
atime[strlen(atime)-1]=0;
return atime;
}
//generate randomness
bit32_t myrand(int i, bit32_t* rseed) {
if(param.randseed == 0) return rand_r(rseed);
else{
bit64_t v;
v = ((bit64_t) i+ param.randseed*1000000) * 3935559000370003845LL + 2691343689449507681LL;
v ^= v >> 21; v ^= v << 37; v ^= v >> 4;
v *= 4768777513237032717LL;
v ^= v << 20; v ^= v >> 41; v ^= v << 5;
return (bit32_t) (v&0xffffffffUL);
}
}
bool HitComp(gHit a, gHit b) {
return ((a.chr<b.chr)||(a.chr==b.chr)&&(a.loc<b.loc));
}
bool HitComp2(gHit a, gHit b) {
return ((a.chr/2<b.chr/2)||(a.chr/2==b.chr/2)&&(a.loc<b.loc));
}
bool HitCompChr(Hit a, Hit b) {return a.chr<b.chr;}
void disp_bfa(bit32_t a, int len) {
for(int i=len-1; i>=0; i--) {
cout<<param.useful_nt[(a>>(i*2))&0x3];
}
cout<<" ";
}
void disp_bfa64(bit64_t a, int len) {
for(int i=len-1; i>=0; i--) {
cout<<param.useful_nt[(a>>(i*2))&0x3];
}
cout<<" ";
}