-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path[
140 lines (116 loc) · 4.53 KB
/
[
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# args: cpounthap
import crit # return evaluation value. param: left, right, other
import sys
import crit
import dijkstra as dks
hikisuu = sys.argv
con_blo = {}
ookisa = {}
contigs_10X = []
numbers = []
if len(hikisuu)-1 == 0:
sys.stderr.write("Error: no argument")
else:
for i in range(len(hikisuu)-1):
# filename=hikisuu[i+1].split("/")[-1]
filename = hikisuu[i+1]
# changeg if error
filenum = int(hikisuu[i+1].split('X')[1].split('.')[0])
numbers.append(filenum)
if not (filename in contigs_10X):
contigs_10X.append(filename)
f1 = open(hikisuu[i+1])
for lineline in f1:
if lineline != '\n':
linea=lineline.split()
rname = linea[0]
qname = linea[1]
count_left = linea[2]
count_right = linea[3]
count_other = linea[4]
if linea[0] == "rname":
pass
else:
if linea[2] == linea[3]:
pass
elif int(linea[2]) > int(linea[3]):
if linea[1] in con_blo:
con_blo[linea[1]][filename+"left"] = [linea[2], linea[3], linea[4]]#+"@"+linea[2]+">"+linea[3])
else:
#con_blo[linea[1]]=[filename+"_left"+" :"+linea[2]+">"+linea[3]]
con_blo[linea[1]] = {}
con_blo[linea[1]][filename+"left"] = [linea[2], linea[3], linea[4]]
elif int(linea[3]) > int(linea[2]):
if linea[1] in con_blo:
con_blo[linea[1]][filename+"right"] = [linea[2], linea[3], linea[4]]
else:
#con_blo[linea[1]]=[filename+"_right"+" :"+linea[3]+">"+linea[2]]
con_blo[linea[1]] = {}
con_blo[linea[1]][filename+"right"] = [linea[2], linea[3], linea[4]]
else:
sys.stderr.write("There may be strange row")
grapha = {}
for i in con_blo.keys():
loop = []
for j in con_blo[i].keys():
loop.append(j)
for k in range(len(loop)):
for l in range(k+1, len(loop)):
lef = con_blo[i][loop[k]][0]
rig = con_blo[i][loop[k]][1]
oth = con_blo[i][loop[k]][2]
lefr = con_blo[i][loop[l]][0]
rigr = con_blo[i][loop[l]][1]
othr = con_blo[i][loop[l]][2]
evall = crit.keisan(int(lef), int(rig), int(oth))
evalr = crit.keisan(int(lefr), int(rigr), int(othr))
if (loop[k], loop[l]) in grapha.keys():
if int(grapha[loop[k], loop[l]]) < evall + evalr:
pass
else:
grapha[loop[k], loop[l]] = evall + evalr
else:
grapha[loop[k], loop[l]] = evall + evalr
print(grapha)
# grapha: {(10X,10X):evalue, ...}
numbers.sort()
def saisyo():
for i in range(len(numbers)):
ki1 = 0
ki2 = 0
for j in grapha.keys():
if '10X'+str(numbers[i])+'.counthapleft' in j:
ki1 = 1
if '10X'+str(numbers[i])+'.counthapright' in j:
ki2 = 1
if ki1 == 1 and ki2 ==1:
return i
def saigo():
for i in range(len(numbers)):
ki1 = 0
ki2 = 0
for j in grapha.keys():
if '10X'+str(numbers[len(numbers)-1-i])+'.counthapleft' in j:
ki1 = 1
if '10X'+str(numbers[len(numbers)-1-i])+'.counthapright' in j:
ki2 = 1
if ki1 == 1 and ki2 == 1:
return len(numbers)-i-1
# '10X'+str(i)+'.counthapleft'
# '10X'+str(i)+'.counthapright'
edges = []
for i in grapha.keys():
edges.append((i[0], i[1], grapha[i]))
LR = dks.dijkstra(edges, '10X'+str(numbers[saisyo()])+'.counthapleft', '10X'+str(numbers[saigo()])+'.counthapright')
LL = dks.dijkstra(edges, '10X'+str(numbers[saisyo()])+'.counthapleft', '10X'+str(numbers[saigo()])+'.counthapleft')
RR = dks.dijkstra(edges, '10X'+str(numbers[saisyo()])+'.counthapright', '10X'+str(numbers[saigo()])+'.counthapright')
RL = dks.dijkstra(edges, '10X'+str(numbers[saisyo()])+'.counthapright', '10X'+str(numbers[saigo()])+'.counthapleft')
print(LR[0])
if LR[0] > LL[0]:
AA = LL
elif LR[0] < LL[0]:
AA = LR
if RR[0] > RL[0]:
BB = RR
elif RR[0] < RL[0]:
BB = RL