1
1
2
- import re
2
+ import re , random
3
3
from czno import getMinBarrierPathDijkstra , basePairList , energyOfStr
4
4
from previous_direct_methods import MorganHiggs1998GreedyDirect , Voss2004GreedyDirect
5
5
@@ -19,8 +19,8 @@ def InterpretDatasetFile(filename):
19
19
if re .fullmatch (r"^[ACGU]+$" , line ) is not None :
20
20
if len (structures ) >= 1 :
21
21
dataset .append ([seq , structures ])
22
- seq = line
23
- structures = []
22
+ seq = line
23
+ structures = []
24
24
elif re .fullmatch (r"^[(.)]+$" , line ) is not None :
25
25
structures .append (line )
26
26
else :
@@ -40,15 +40,15 @@ def DirectPathSingleExperiment(sequence, structure1, structure2):
40
40
41
41
pathway1 = getMinBarrierPathDijkstra (sequence , structure1 , structure2 )
42
42
result .append (PathwayToBarrier (sequence , pathway1 ))
43
-
43
+
44
44
pathway2 = MorganHiggs1998GreedyDirect (sequence , structure1 , structure2 )
45
45
result .append (PathwayToBarrier (sequence , pathway2 ))
46
46
47
47
pathway3 = Voss2004GreedyDirect (sequence , structure1 , structure2 )
48
48
result .append (PathwayToBarrier (sequence , pathway3 ))
49
49
50
50
best_value4 = float ("inf" )
51
- for i in range (1000 ):
51
+ for i in range (10 ):
52
52
pathway4 = Voss2004GreedyDirect (sequence , structure1 , structure2 , 10 , i )
53
53
best_value4 = min (best_value4 , PathwayToBarrier (sequence , pathway4 ))
54
54
result .append (best_value4 )
@@ -58,11 +58,17 @@ def DirectPathSingleExperiment(sequence, structure1, structure2):
58
58
59
59
if __name__ == '__main__' :
60
60
dataset = InterpretDatasetFile ("s151-localminima-dataset.txt" )
61
+
61
62
for data in dataset :
62
- for i in range (len (data [1 ])):
63
- for j in range (i + 1 , len (data [1 ])):
64
- hamdist = HammingDistance (data [1 ][i ], data [1 ][j ])
65
- if 5 <= hamdist and hamdist <= 20 :
66
- result = DirectPathSingleExperiment (data [0 ], data [1 ][i ], data [1 ][j ])
63
+ starts = random .sample (data [1 ], min (1 , len (data [1 ])))
64
+ for i in range (len (starts )):
65
+ g1 = list (set (data [1 ]) - set (starts )) + starts [i + 1 :]
66
+ g2 = [HammingDistance (starts [i ],g1 [x ]) for x in range (len (g1 ))]
67
+ g3 = [g1 [x ] for x in range (len (g1 )) if 5 <= g2 [x ] and g2 [x ] <= 15 ]
68
+ goals = random .sample (g3 , min (1 , len (g3 )))
69
+ for j in range (len (goals )):
70
+ hamdist = HammingDistance (starts [i ], goals [j ])
71
+ if 5 <= hamdist and hamdist <= 15 :
72
+ result = DirectPathSingleExperiment (data [0 ], starts [i ], goals [j ])
67
73
print (str (len (data [0 ]))+ " " + str (hamdist )+ " " + " " .join ([str (x ) for x in result ]))
68
74
0 commit comments