forked from harigali/PepSy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPepSy-manual.py
340 lines (285 loc) · 12.3 KB
/
PepSy-manual.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
'''
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
PepSy - An open-source peptide synthesizer
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Developed by:
Dr. Hariprasad Gali, Ph.D.
Associate Professor of Research
Department of Pharmaceutical Sciences
College of Pharmacy
The University of Oklahoma Health Sciences Center
Oklahoma City, OK 73117
Email: hgali@ouhsc.edu.
Tested only with Python 3.5.0
First full version - December 16, 2015
Last update - November 06, 2018
This script is written for the manual control of PepSy and cleaning amino acid/reagent line.
Save device configuration file (config.txt) in the same folder where PepSy.py and PepSy-manual.py scripts are saved.
Only Arduino UNO digital pins are used.
COM port numbers of VICI stream selector valve (ps) and Arduino UNO (board) needs to be updated in the device configuration file according to their current assignment on the PC.
VICI CHEMINERT low pressure 24 position stream selector valve
Position 1 - Air
Position 2 - DMF
Position 3 - DCM
Position 4 - Piperidine solution
Position 5 - DIPEA solution
Position 6 - HOBT solution
Position 7 - HBTU solution
Position 8 to 24 - Amino acid solutions or other reagent solutions
'''
import time
import serial
import _thread
import configparser
from tkinter import *
from pyfirmata import Arduino, util
# Functions
def n2On():
n2OnBtn.config(state=DISABLED)
n2OffBtn.config(state=NORMAL)
n2.write(1)
def n2Off():
n2OffBtn.config(state=DISABLED)
n2OnBtn.config(state=NORMAL)
n2.write(0)
def ventOn():
ventOnBtn.config(state=DISABLED)
ventOffBtn.config(state=NORMAL)
vent.write(1)
def ventOff():
ventOffBtn.config(state=DISABLED)
ventOnBtn.config(state=NORMAL)
vent.write(0)
def reagentOn():
reagentOnBtn.config(state=DISABLED)
reagentOffBtn.config(state=NORMAL)
reagent.write(1)
def reagentOff():
reagentOffBtn.config(state=DISABLED)
reagentOnBtn.config(state=NORMAL)
reagent.write(0)
def wasteOn():
wasteOnBtn.config(state=DISABLED)
wasteOffBtn.config(state=NORMAL)
waste.write(1)
def wasteOff():
wasteOffBtn.config(state=DISABLED)
wasteOnBtn.config(state=NORMAL)
waste.write(0)
def primeOn():
primeOnBtn.config(state=DISABLED)
primeOffBtn.config(state=NORMAL)
prime.write(1)
def primeOff():
primeOffBtn.config(state=DISABLED)
primeOnBtn.config(state=NORMAL)
prime.write(0)
def pumpon(v): # v is volume (integer) to be pumped in microliters, pumping rate is 1.2 ml/min, this function is required as a solenoid valve based micro pump is being used
pumpOnBtn.config(state=DISABLED)
for p in range(0,v,piv):
pump.write(1)
time.sleep(0.25)
pump.write(0)
time.sleep(0.25)
pumpOnBtn.config(state=NORMAL)
def pumponvol():
psGoBtn.config(state=DISABLED)
cleanBtn.config(state=DISABLED)
washBtn.config(state=DISABLED)
resetBtn.config(state=DISABLED)
vol = int(pumpvol.get())
pumpon(vol)
psGoBtn.config(state=NORMAL)
cleanBtn.config(state=NORMAL)
washBtn.config(state=NORMAL)
resetBtn.config(state=NORMAL)
def go():
pos = int(pspos.get())
position = 'GO%d\r' % (pos)
ps.write(position.encode())
def clean():
pos1 = int(ps1pos.get())
pos2 = int(ps2pos.get())
psGoBtn.config(state=DISABLED)
cleanBtn.config(state=DISABLED)
washBtn.config(state=DISABLED)
resetBtn.config(state=DISABLED)
for n in range(pos1, pos2+1):
cleaninfo = 'Cleaning port ' + str(n)
cleanstatus.set(cleaninfo)
position = 'GO%d\r' % (n)
ps.write(position.encode())
primeOn()
pumpon(500+len1+len2)
primeOff()
ps.write('HM\r'.encode())
cleanstatus.set('Cleaning completed')
psGoBtn.config(state=NORMAL)
cleanBtn.config(state=NORMAL)
washBtn.config(state=NORMAL)
resetBtn.config(state=NORMAL)
def wash():
x = int(washTimes.get())
psGoBtn.config(state=DISABLED)
cleanBtn.config(state=DISABLED)
washBtn.config(state=DISABLED)
resetBtn.config(state=DISABLED)
for n in range(1, x+1):
washinfo = 'Resin washing ' + str(n)
washstatus.set(washinfo)
reagentOn()
ps.write('GO2\r'.encode())
pumpon(2000)
ps.write('HM\r'.encode())
time.sleep(1)
reagentOff()
n2On()
wasteOn()
ventOn()
time.sleep(60)
ventOff()
wasteOff()
n2Off()
washstatus.set('Resin washing completed')
psGoBtn.config(state=NORMAL)
cleanBtn.config(state=NORMAL)
washBtn.config(state=NORMAL)
resetBtn.config(state=NORMAL)
def reset():
volvar.set('0')
psvar.set('1')
ps1var.set('1')
ps2var.set('1')
washvar.set('0')
cleanstatus.set('Ready')
washstatus.set('Ready')
n2Off()
ventOff()
reagentOff()
wasteOff()
primeOff()
go()
psGoBtn.config(state=NORMAL)
cleanBtn.config(state=NORMAL)
washBtn.config(state=NORMAL)
resetBtn.config(state=NORMAL)
# Main
config = configparser.ConfigParser()
config.readfp(open('config.txt'))
pscom = config.get('Parameters', 'pscom')
arduinocom = config.get('Parameters', 'arduinocom')
tubevol = float(config.get('Parameters', 'tubevol'))
length1 = float(config.get('Parameters', 'length1'))
length2 = float(config.get('Parameters', 'length2'))
piv = int(config.get('Parameters', 'piv'))
ps = serial.Serial(port=pscom, baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) # VICI port selector
board = Arduino(arduinocom) # Arduino Uno
n2 = board.get_pin('d:2:o') # Solenoid valve normally closed, connected to digital pin 2
vent = board.get_pin('d:3:o') # Solenoid valve normally open, connected to digital pin 3
reagent = board.get_pin('d:4:o') # Solenoid valve normally closed, connected to digital pin 4
waste = board.get_pin('d:5:o') # Solenoid valve normally closed, connected to digital pin 5
prime = board.get_pin('d:6:o') # Solenoid valve normally closed, connected to digital pin 6
pump = board.get_pin('d:7:o') # Solenoid micro pump with an internal volume of 20 microliter and maximum pumping speed 2.4 ml/min or 40 microliter/sec, connected to digital pin 7
font16 = ('Helvetica', 16, 'bold')
font12 = ('Helvetica', 12, 'bold')
root = Tk()
root.wm_title('PepSy')
frame = Frame(root)
frame.grid()
len1 = int(tubevol*length1) # tubing volume aa to ps
len2 = int(tubevol*length1) # tubing volume ps to pump
volvar = StringVar()
psvar = StringVar()
ps1var = StringVar()
ps2var = StringVar()
washvar = StringVar()
cleanstatus = StringVar()
washstatus = StringVar()
line1Lbl = Label(frame, text = '-----------------------------------------------------------------')
line1Lbl.grid(row = 1, column = 1, columnspan = 3)
title1Lbl = Label(frame, text = 'PepSy', font = font16)
title1Lbl.grid(row = 2, column = 1, columnspan = 3)
line2Lbl = Label(frame, text = '-----------------------------------------------------------------')
line2Lbl.grid(row = 3, column = 1, columnspan = 3)
title2Lbl = Label(frame, text = 'Control Panel', font = font12)
title2Lbl.grid(row = 4, column = 1, columnspan = 3)
n2Lbl = Label(frame, text = 'Nitrogen Gas')
n2Lbl.grid(row = 5, column = 1, pady = 5, sticky = E)
n2OnBtn = Button(frame, text = ' ON ', command = lambda:n2On())
n2OnBtn.grid(row = 5, column = 2, pady = 5, sticky = E)
n2OffBtn = Button(frame, text = ' OFF ', command = lambda:n2Off())
n2OffBtn.grid(row = 5, column = 3, pady = 5, sticky = W)
ventLbl = Label(frame, text = 'Vent')
ventLbl.grid(row = 6, column = 1, pady = 5, sticky = E)
ventOnBtn = Button(frame, text = ' ON ', command = lambda:ventOn())
ventOnBtn.grid(row = 6, column = 2, pady = 5, sticky = E)
ventOffBtn = Button(frame, text = ' OFF ', command = lambda:ventOff())
ventOffBtn.grid(row = 6, column = 3, pady = 5, sticky = W)
reagentLbl = Label(frame, text = 'Reagent')
reagentLbl.grid(row = 7, column = 1, pady = 5, sticky = E)
reagentOnBtn = Button(frame, text = ' ON ', command = lambda:reagentOn())
reagentOnBtn.grid(row = 7, column = 2, pady = 5, sticky = E)
reagentOffBtn = Button(frame, text = ' OFF ',command = lambda:reagentOff())
reagentOffBtn.grid(row = 7, column = 3, pady = 5, sticky = W)
wasteLbl = Label(frame, text = 'Waste')
wasteLbl.grid(row = 8, column = 1, pady = 5, sticky = E)
wasteOnBtn = Button(frame, text = ' ON ', command = lambda:wasteOn())
wasteOnBtn.grid(row = 8, column = 2, pady = 5, sticky = E)
wasteOffBtn = Button(frame, text = ' OFF ', command = lambda:wasteOff())
wasteOffBtn.grid(row = 8, column = 3, pady = 5,sticky = W)
primeLbl = Label(frame, text = 'Prime')
primeLbl.grid(row = 9, column = 1, pady = 5, sticky = E)
primeOnBtn = Button(frame, text = ' ON ', command = lambda:primeOn())
primeOnBtn.grid(row = 9, column = 2, pady = 5, sticky = E)
primeOffBtn = Button(frame, text = ' OFF ',command = lambda:primeOff())
primeOffBtn.grid(row = 9, column = 3, pady = 5, sticky = W)
pumpLbl = Label(frame, text = 'Pump Volume')
pumpLbl.grid(row = 10, column = 1, pady = 5, sticky = E)
pumpvol = Entry(frame, textvariable = volvar, width = 5)
pumpvol.grid(row = 10, column = 2, pady = 5, sticky = E)
pumpOnBtn = Button(frame, text = ' ON ', command = lambda:_thread.start_new(pumponvol, ()))
pumpOnBtn.grid(row = 10, column = 3, pady = 5, sticky = W)
psLbl = Label(frame, text = 'Port')
psLbl.grid(row = 11, column = 1, pady = 5, sticky = E)
pspos = Entry(frame, textvariable = psvar, width = 5)
pspos.grid(row = 11, column = 2, pady = 5, sticky = E)
psGoBtn = Button(frame, text = ' GO ', command = lambda:go())
psGoBtn.grid(row = 11, column = 3, pady = 5, sticky = W)
line3Lbl = Label(frame, text = '-----------------------------------------------------------------')
line3Lbl.grid(row = 12, column = 1, columnspan = 3)
title4Lbl = Label(frame, text = 'Amino Acid/Reagent Line Cleaning', font = font12)
title4Lbl.grid(row = 13, column = 1, columnspan = 3)
title5Lbl = Label(frame, text = ' ')
title5Lbl.grid(row = 14, column = 1, columnspan = 3)
ps1Lbl = Label(frame, text = 'Starting Port')
ps1Lbl.grid(row = 15, column = 1, sticky = E)
ps1pos = Entry(frame, textvariable = ps1var, width = 5)
ps1pos.grid(row = 15, column = 2, sticky = E)
ps2Lbl = Label(frame, text = 'Ending Port')
ps2Lbl.grid(row = 16, column = 1, sticky = E)
ps2pos = Entry(frame, textvariable = ps2var, width = 5)
ps2pos.grid(row = 16, column = 2, sticky = E)
cleanBtn = Button(frame, text = ' CLEAN ', command = lambda:_thread.start_new(clean, ()))
cleanBtn.grid(row = 17, column = 1, pady = 5, columnspan = 3)
cleanstatusLbl = Label(frame, textvariable = cleanstatus)
cleanstatusLbl.grid(row = 18, column = 1, pady = 5, columnspan = 3)
line4Lbl = Label(frame, text = '-----------------------------------------------------------------')
line4Lbl.grid(row = 19, column = 1, columnspan = 3)
title6Lbl = Label(frame, text = 'Resin Washing', font = font12)
title6Lbl.grid(row = 20, column = 1, columnspan = 3)
title7Lbl = Label(frame, text = ' ')
title7Lbl.grid(row = 21, column = 1, columnspan = 3)
washLbl = Label(frame, text = 'Times')
washLbl.grid(row = 22, column = 1, sticky = E)
washTimes = Entry(frame, textvariable = washvar, width = 5)
washTimes.grid(row = 22, column = 2, sticky = E)
washBtn = Button(frame, text = ' WASH ', command = lambda:_thread.start_new(wash, ()))
washBtn.grid(row = 23, column = 1, pady = 5, columnspan = 3)
washstatusLbl = Label(frame, textvariable = washstatus)
washstatusLbl.grid(row = 24, column = 1, pady = 5, columnspan = 3)
line5Lbl = Label(frame, text = '-----------------------------------------------------------------')
line5Lbl.grid(row = 25, column = 1, columnspan = 3)
resetBtn = Button(frame, text = ' RESET ', command = lambda:reset())
resetBtn.grid(row = 26, column = 1, pady = 5, columnspan = 3)
reset()
root.mainloop()