Skip to content

Commit 78d30e7

Browse files
authored
Add files via upload
1 parent 4e4f048 commit 78d30e7

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

directpath-comparison-experiment.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import re
2+
import re, random
33
from czno import getMinBarrierPathDijkstra, basePairList, energyOfStr
44
from previous_direct_methods import MorganHiggs1998GreedyDirect, Voss2004GreedyDirect
55

@@ -19,8 +19,8 @@ def InterpretDatasetFile(filename):
1919
if re.fullmatch(r"^[ACGU]+$", line) is not None:
2020
if len(structures) >= 1:
2121
dataset.append([seq, structures])
22-
seq = line
23-
structures = []
22+
seq = line
23+
structures = []
2424
elif re.fullmatch(r"^[(.)]+$", line) is not None:
2525
structures.append(line)
2626
else:
@@ -40,15 +40,15 @@ def DirectPathSingleExperiment(sequence, structure1, structure2):
4040

4141
pathway1 = getMinBarrierPathDijkstra(sequence, structure1, structure2)
4242
result.append(PathwayToBarrier(sequence, pathway1))
43-
43+
4444
pathway2 = MorganHiggs1998GreedyDirect(sequence, structure1, structure2)
4545
result.append(PathwayToBarrier(sequence, pathway2))
4646

4747
pathway3 = Voss2004GreedyDirect(sequence, structure1, structure2)
4848
result.append(PathwayToBarrier(sequence, pathway3))
4949

5050
best_value4 = float("inf")
51-
for i in range(1000):
51+
for i in range(10):
5252
pathway4 = Voss2004GreedyDirect(sequence, structure1, structure2, 10, i)
5353
best_value4 = min(best_value4, PathwayToBarrier(sequence, pathway4))
5454
result.append(best_value4)
@@ -58,11 +58,17 @@ def DirectPathSingleExperiment(sequence, structure1, structure2):
5858

5959
if __name__ == '__main__':
6060
dataset = InterpretDatasetFile("s151-localminima-dataset.txt")
61+
6162
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])
6773
print(str(len(data[0]))+" "+str(hamdist)+" "+" ".join([str(x) for x in result]))
6874

previous_direct_methods.py

+1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ def Voss2004GreedyDirect(sequence, structure1, structure2, k = 1, seed = 12345):
4747
PossibleNextStateAndEnergy = [(energyOfStr(sequence, x), x) for x in PossibleNextState]
4848
NextState = random.choice(sorted(PossibleNextStateAndEnergy)[0:k])[1]
4949
answer.append(NextState)
50+
A = set(basePairList(NextState))
5051
return answer

0 commit comments

Comments
 (0)