-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateREHT.py
executable file
·69 lines (57 loc) · 1.28 KB
/
createREHT.py
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
#!/bin/env python
from math import *
import numpy as np
import sys
if len(sys.argv) < 4:
print("Usage: statsHDB.py <HDB> <numPos> <numHT>")
sys.exit(1)
HDB = sys.argv[1]
numPos = int(sys.argv[2])
numHT = int(sys.argv[3])
N = 100
X = np.random.choice(list(range(numPos)), N, replace=False)
Y = np.random.choice(list(range(numHT)), N, replace=False)
assert (len(set(X)) == N)
assert (len(set(Y)) == N)
id = np.argsort(Y)
Y = Y[id]
X = X[id]
#print X
#print Y
#print HDB
HT = {}
def createRP(HDB, X, Y):
HF = open(HDB + "-hpth.txt")
HF.readline()
n = -1
k = 0
for l in HF:
n += 1
if n != Y[k]:
continue
fmId,prId,hpId,hpth = l.strip("\n\r").split("\t")
HT[(fmId,prId,hpId,X[k])] = [hpth[X[k]]]
k += 1
#print k
if k == N:
break
HF.close()
pos2ht = { k[3]:k for k in list(HT.keys())}
X = sorted(X)
HF = open(HDB + "-pos.txt")
HF.readline()
n = -1
k = 0
for l in HF:
n += 1
if n != X[k]:
continue
cs = l.strip("\n\r").split("\t")
HT[pos2ht[X[k]]].append(cs[1])
k += 1
if k == N:
break
HF.close()
createRP(HDB, X, Y)
for k in sorted(HT):
print('\t'.join(map(str, list(k) + HT[k])))