-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.py
More file actions
105 lines (94 loc) · 2.79 KB
/
parser.py
File metadata and controls
105 lines (94 loc) · 2.79 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
import numpy as py
sequence_bps = input("Enter Sequence bps file: ")
IRE_bps = input("Enter IRE bps file: ")
shift = input("Enter position of IRE: ")
IRE = {(1,34): 0.9963,
(2, 33): 0.9980,
(3, 32): 0.9982,
(4, 31): 0.9869,
(6, 28): 0.4434,
(5, 30): 0.9869,
(7, 29): 0.5971,
(8, 26): 0.4558,
(9, 28): 0.8125,
(10, 27): 0.8200,
(11, 26): 0.8224,
(12, 21): 0.5144,
(13, 20): 0.4505,
(14, 23): 0.8479,
(15, 22): 0.8481,
(16, 21): 0.6457,
(17, 21): 0.0281,
(18, 25): 0.0031,
(19, 26): 0.0042,
(20, 28): 0.0114,
(21, 27): 0.0123,
(22, 29): 0.0448,
(23, 29): 0.0123,
(24, 33): 0.0021,
(25, 31): 0.0050,
(26, 35): 0.0205,
(27, 34): 0.0219,
(28, 33): 0.0194
}
IRE2 = {(1, 28): 0.565990427,
(2, 27): 0.834558937,
(3, 26): 0.852239847,
(4, 25): 0.845962168,
(5, 25): 0.522992586,
(6, 24): 0.791836762,
(7, 22): 0.067498629,
(8, 23): 0.984339729,
(9, 22): 0.992869075,
(10, 21): 0.996729211,
(11, 20): 0.996517286,
(12, 19): 0.993328370,
(13, 17): 0.036324522,
(14, 20): 0.005116260,
(15, 24): 0.004863894,
(16, 23): 0.004853327,
}
"""
Function to parse through the IRE bps file to compare with sequence
"""
def IRE_Parse(file):
"""
Function to parse through the sequence bps files and store all of the bps in dictionary
file: Path of the file
"""
def SequenceParse(file):
array = py.loadtxt(file)
Sequence_bps = {}
for index in range(len(array)):
i = array[index][0]
j = array[index][1]
temp = [i,j]
Sequence_bps[tuple(temp)] = array[index][2]
return Sequence_bps
"""
Function to check and see the bps of the IRE inserted into the sequence
IRE_bps: IRE stored as a dictionary.
Sequence_bps: Sequence Candidate stored as a dictionary.
Offset: Index of where the IRE was inserted, Int
"""
def BPS_Comp(IRE_bps, Sequence_bps, Offset):
results = {}
for sequence in IRE_bps:
key = (sequence[0] + shift, sequence[1] + shift)
if key in Sequence_bps:
results[key] = Sequence_bps[key]
return results
"""
Function to Write to the file
results_dictionary: Dictionary generated by BPS_Comp
"""
def Write_File(results_dictionary):
file = open('results.txt', 'w')
file.write("i j Sqrt(Prob(i,j))" + "\n")
BPS = results.items()
for result_bps in BPS:
file.write(" ".join(map(str, result_bps)) + "\n")
file.close()
Candidate = SequenceParse(sequence_bps)
results = BPS_Comp(IRE2, Candidate, 0)
Write_File(results)