-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathPepVis.py
2832 lines (2783 loc) · 121 KB
/
PepVis.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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from Tkinter import *
import tkFileDialog
import tkMessageBox
import subprocess
import os
import ConfigParser
import multiprocessing
root = Tk()
root.title("PepVis")
MODPEP=""
PSIPRED=""
MGLROOT=""
GROMACS_PREFIX=""
ZDOCK=""
ZRANK=""
HBPLUS=""
FLEXPEPDOCK=""
ADFRROOT=""
RANKALL="YES" # For ADCP: YES-to consider all top 10 ranking solutions, NO- to consider top 1 solution alone
#~~
PEPTIDE=""
INPUTPEP=""
WORKING=""
RECEPTOR=""
joobs=""
#~~
NUMMOD=""
CWD=os.getcwd()
def run_pepmod():
run_pep=Toplevel(root)
run_pep.title("Peptide Modelling")
global CWD
# if CONFIG_check.get() == 0:
# if MODPEP:
# asd_config.set("softwares","MODPEP",MODPEP)
# if PSIPRED:
# asd_config.set("softwares","PSIPRED",PSIPRED)
# if MGLROOT:
# asd_config.set("softwares","MGLROOT",MGLROOT)
# if GROMACS_PREFIX:
# asd_config.set("softwares","GROMACS_PREFIX",GROMACS_PREFIX)
# if ZDOCK:
# asd_config.set("softwares","ZDOCK",ZDOCK)
# if ZRANK:
# asd_config.set("softwares","ZRANK",ZRANK)
# if HBPLUS:
# asd_config.set("softwares","HBPLUS",HBPLUS)
# if FLEXPEPDOCK:
# asd_config.set("softwares","FLEXPEPDOCK",FLEXPEPDOCK)
# if ADFRROOT:
# asd_config.set("softwares","ADFRROOT",ADFRROOT)
# config_file=open('config.ini','w')
# asd_config.write(config_file)
# config_file.close()
#~~~~~
#~~~~~~ Peptide model start
PEPMODEL_check=IntVar()
PEPSS_check=IntVar()
Label(run_pep,bg="white",text="Do you want to model the peptides?",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=0,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=PEPMODEL_check,font=("Times",15,"bold"),relief=SOLID,width=10,height=2).grid(row=0,column=1,sticky=E+W+N+S)
def pepmodel_check(*args):
if PEPMODEL_check.get() == 1:
Label(run_pep,bg="white",text="Provide the peptide sequence file",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=1,column=0,sticky=E+W+N+S)
def get_peptide_dir():
filetemp=tkFileDialog.askopenfilename(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/peptide",title="Enter the peptide sequence file",parent=run_pep)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=run_pep)
return
else:
if os.path.exists(filetemp):
global PEPTIDE
global INPUTPEP
PEPTIDE=os.path.split(filetemp)[0]
INPUTPEP=os.path.split(filetemp)[1]
else:
tkMessageBox.showinfo("Warning!","File not found in the directory path!",parent=run_pep)
return
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=run_pep)
return
Button(run_pep,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=2,command=get_peptide_dir).grid(row=1,column=1,sticky=E+W+N+S)
Label(run_pep,bg="white",text="Predict peptide secondary structure \nusing PSI-PRED?",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=2,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=PEPSS_check,font=("Times",15,"bold"),relief=SOLID,width=10,height=2).grid(row=2,column=1,sticky=E+W+N+S)
NUM_MODEL=StringVar()
Label(run_pep,bg="white",text="Enter the number of models to \n generate per peptide",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=3,column=0,sticky=E+W+N+S)
Entry(run_pep,bd=5,textvariable=NUM_MODEL,font=("Times",15,'bold'),justify=CENTER).grid(row=3,column=1,sticky=W+E+N+S)
def num_model(*args):
if len(NUM_MODEL.get()) > 0:
for f in NUM_MODEL.get():
if f not in '0123456789':
tkMessageBox.showinfo("Warning","Please provide the integer Values!",parent=run_pep)
return
global NUMMOD
NUMMOD=int(NUM_MODEL.get())
else:
tkMessageBox.showinfo("Warning","Please provide the integer Values!",parent=run_pep)
return
NUM_MODEL.trace('w',num_model)
if PEPMODEL_check.get() == 0:
Label(run_pep,bg="white",text="Provide the peptide sequence file",font=("Times",15,"bold"),state=DISABLED,width=35,height=2).grid(row=1,column=0,sticky=E+W+N+S)
Button(run_pep,text="Open",bg="gold",font=("Times",15,"bold","underline"),state=DISABLED,relief=RAISED,borderwidth=3,width=10,height=2).grid(row=1,column=1,sticky=E+W+N+S)
Label(run_pep,bg="white",text="Predict peptide secondary structure \nusing PSI-PRED?",font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=35,height=2).grid(row=2,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=PEPSS_check,font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=10,height=2).grid(row=2,column=1,sticky=E+W+N+S)
Label(run_pep,bg="white",text="Enter the number of models to \n generate per peptide",font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=35,height=2).grid(row=3,column=0,sticky=E+W+N+S)
Entry(run_pep,bd=5,font=("Times",15,'bold'),state=DISABLED,justify=CENTER).grid(row=3,column=1,sticky=W+E+N+S)
PEPMODEL_check.trace('w',pepmodel_check)
#~~~~~~ Peptide model end
#~~~~~ Peptide minim start
MINIM_check=IntVar()
Label(run_pep,bg="white",text="Do you want to minimize \nthe peptides structures?",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=4,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=MINIM_check,font=("Times",15,"bold"),relief=SOLID,width=10,height=2).grid(row=4,column=1,sticky=E+W+N+S)
def minim_check(*args):
if MINIM_check.get() == 1:
if PEPMODEL_check.get() == 0:
Label(run_pep,bg="white",text="Provide the peptide structure directory",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=5,column=0,sticky=E+W+N+S)
def get_peptide_str_dir():
filetemp=tkFileDialog.askdirectory(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/peptide",title="Enter the peptide sequence file",parent=run_pep)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=run_pep)
return
else:
global PEPTIDE
PEPTIDE=filetemp
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=run_pep)
return
Button(run_pep,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=2,command=get_peptide_str_dir).grid(row=5,column=1,sticky=E+W+N+S)
elif PEPMODEL_check.get() == 1:
Label(run_pep,bg="white",text="Provide the peptide structure directory",font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=35,height=2).grid(row=5,column=0,sticky=E+W+N+S)
Button(run_pep,text="Open",bg="gold",font=("Times",15,"bold","underline"),state=DISABLED,relief=RAISED,borderwidth=3,width=10,height=2).grid(row=5,column=1,sticky=E+W+N+S)
MINIM_check.trace('w',minim_check)
#~~~~ Peptide minim end
#~~~~ PDBQT start
PDBQT_check=IntVar()
TORSION_check=IntVar()
Label(run_pep,bg="white",text="Do you want the peptides \n structures in PDBQT format?",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=6,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=PDBQT_check,font=("Times",15,"bold"),relief=SOLID,width=10,height=2).grid(row=6,column=1,sticky=E+W+N+S)
def pdbqt_check(*args):
if PDBQT_check.get() == 1:
Label(run_pep,bg="white",text="Do you want to the inactivate \npeptide torsions?",font=("Times",15,"bold"),relief=SOLID,width=35,height=2).grid(row=7,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=TORSION_check,font=("Times",15,"bold"),relief=SOLID,width=10,height=2).grid(row=7,column=1,sticky=E+W+N+S)
elif PDBQT_check.get() == 0:
Label(run_pep,bg="white",text="Do you want to the inactivate \npeptide torsions?",font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=35,height=2).grid(row=7,column=0,sticky=E+W+N+S)
Checkbutton(run_pep,bg="white",offvalue=0,onvalue=1,variable=TORSION_check,font=("Times",15,"bold"),state=DISABLED,relief=SOLID,width=10,height=2).grid(row=7,column=1,sticky=E+W+N+S)
PDBQT_check.trace('w',pdbqt_check)
#~~~~ PDBQT end
Label(run_pep,bg="white",text="Enter the working directory:",font=("Times",15,"bold"),relief=SOLID,width=30,height=2).grid(row=8,column=0,sticky=E+W+N+S)
def get_working_dir():
filetemp=tkFileDialog.askdirectory(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/working",title="Enter the working directory",parent=run_pep)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=run_pep)
return
else:
os.chdir(filetemp)
zxc=os.listdir('.')
if zxc:
tkMessageBox.showinfo("Warning!","Working directory is not empty!",parent=run_pep)
return
else:
global WORKING
WORKING=filetemp
os.chdir(CWD)
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=run_pep)
return
Button(run_pep,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=2,command=get_working_dir).grid(row=8,column=1,sticky=E+W+N+S)
#~~~~~~~~~~~~~~ Number of CPU calculation start
Ncpu=multiprocessing.cpu_count()
Label(run_pep,bg="white",text=str(Ncpu)+" number of CPU processors \n detected in your system",relief=SOLID,font=("Times",15,'bold'),width=30,height=3,justify=CENTER).grid(row=9,column=0,columnspan=2,sticky=E+W+N+S)
Label(run_pep,bg="white",text="Enter the number of CPU \n for running jobs in parallel:",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=10,column=0,sticky=W+E+N+S)
global Numcpu
Numcpu=StringVar()
Numcpu.set(Ncpu)
joobs=int(Numcpu.get())
if joobs:
Label(run_pep,bg="white",text= Numcpu.get()+" Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=11,column=0,columnspan=2,sticky=W+E+N+S)
Entry(run_pep,bd=5,textvariable=Numcpu,font=("Times",15,'bold'),justify=CENTER).grid(row=10,column=1,sticky=W+E+N+S)
def checkback(*args):
for f in Numcpu.get():
if f not in '1234567890' :
tkMessageBox.showinfo("Warning","Please provide the integer Values!",parent=run_pep)
return
global joobs
joobs=0
if len(Numcpu.get()) > 0:
if int(Numcpu.get()) > Ncpu or int(Numcpu.get()) == 0 :
tkMessageBox.showinfo("Warning","Please provide the values less than "+str(Ncpu)+"!",parent=run_pep)
return
else:
Label(run_pep,bg="white",text= Numcpu.get()+" Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=11,column=0,columnspan=2,sticky=W+E+N+S)
joobs=int(Numcpu.get())
else:
Label(run_pep,bg="white",text= "0 Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=11,column=0,columnspan=2,sticky=W+E+N+S)
Numcpu.trace('w',checkback)
#~~~~~~~~~~ Number of CPU calculation end
def print_bash_script():
#~~~ CHECK for installation and input start
if PARALLEL_check.get() == 0:
tkMessageBox.showinfo("Warning!","GNU Parallel not found!",parent=run_pep)
return
if PDBQT_check.get() == 1:
if not MGLROOT:
tkMessageBox.showinfo("Warning!","MGLROOT not found!",parent=run_pep)
return
if not MODPEP:
tkMessageBox.showinfo("Warning!","Modpep not found!",parent=run_pep)
return
if PEPMODEL_check.get() == 1:
if not NUMMOD:
tkMessageBox.showinfo("Warning!","Number of peptides model not specified!",parent=run_pep)
return
if PEPSS_check.get() == 1:
if not PSIPRED:
tkMessageBox.showinfo("Warning!","PSIPRED not found!",parent=run_pep)
return
if MINIM_check.get() == 1:
if not GROMACS_PREFIX:
tkMessageBox.showinfo("Warning!","GNU Parallel not found!",parent=run_pep)
return
if not joobs:
tkMessageBox.showinfo("Warning!","Number of jobs to run in parallel not specified!",parent=run_pep)
return
if not PEPTIDE:
tkMessageBox.showinfo("Warning!","PEPTIDE directory not specified!",parent=run_pep)
return
if not WORKING:
tkMessageBox.showinfo("Warning!","WORKING directory not specified!",parent=run_pep)
return
#~~~ CHECK for installation and input end
BASHSCRIPT='''
#!/bin/bash
PEPTIDE="%s"
WORKING="%s"
joobs=%d''' %(PEPTIDE,WORKING,joobs)
if PEPMODEL_check.get() == 1:
BASHSCRIPT+='''\nMODPEP="%s"\nNUMMOD=%d\nINPUTPEP="%s"\n''' %(MODPEP,NUMMOD,INPUTPEP)
if PEPSS_check.get() == 1:
BASHSCRIPT+='''\nPSIPRED="%s"\n''' %(PSIPRED)
if MINIM_check.get() == 1:
BASHSCRIPT+='''\nGROMACS_PREFIX="%s"\n''' %(GROMACS_PREFIX)
if PDBQT_check.get() == 1:
BASHSCRIPT+='''\nMGLROOT="%s"\n''' %(MGLROOT)
BASHSCRIPT+='''\n\n
echo -e "================================================================================"
echo -e "Peptide directory: "$PEPTIDE""
echo -e "Working directory: "$WORKING""
echo -e "Number of parallel jobs: "$joobs""'''
if PEPMODEL_check.get() == 1:
BASHSCRIPT+='''\necho -e "Number of models per peptide: "$NUMMOD""'''
if PEPSS_check.get() == 1:
BASHSCRIPT+='''\necho -e "Secondary structure Prediction using PSI-PRED: YES"'''
if MINIM_check.get() == 1:
BASHSCRIPT+='''\necho -e "Minimization using Gromacs: YES"\necho -e "GROMACS Prefix: "$GROMACS_PREFIX""'''
if PDBQT_check.get() == 1:
BASHSCRIPT+='''\necho -e "PDBQT conversion: YES"'''
if TORSION_check.get() == 1:
BASHSCRIPT+='''\necho -e "Peptide Torsions: OFF"'''
if TORSION_check.get() == 0:
BASHSCRIPT+='''\necho -e "Peptide Torsions: ON"'''
BASHSCRIPT+='''
echo -e "================================================================================"
echo -e "Please enter [1] to accept the input [2] to quit"
i=1
while [ "$i" -ge 0 ]
do
read -ep ">>>" check
if [ "$check" == 1 ]
then
:
break
elif [ "$check" == 2 ]
then
exit
else
echo "Wrong input! Enter again"
fi
done
echo -e "\\n-------------------------------------------------------------------------------\\n---------------------------------Summary Report--------------------------------\\n-------------------------------------------------------------------------------\\n\\n\\nPeptide Input Directory="$PEPTIDE"\\nWorking directory="$WORKING"\\nNumber of parallel jobs: "$joobs"\\n" >>"$WORKING"/summary.txt'''
if PEPMODEL_check.get() == 1:
BASHSCRIPT+='''\necho -e "Number of models per peptide: "$NUMMOD"" >>"$WORKING"/summary.txt'''
if PEPSS_check.get() == 1:
BASHSCRIPT+='''\necho -e "Secondary structure Prediction using PSI-PRED: YES" >>"$WORKING"/summary.txt'''
if MINIM_check.get() == 1:
BASHSCRIPT+='''\necho -e "Minimization using Gromacs: YES\\nGROMACS Prefix: "$GROMACS_PREFIX"" >>"$WORKING"/summary.txt'''
if PDBQT_check.get() == 1:
BASHSCRIPT+='''\n echo -e "PDBQT conversion: YES" >>"$WORKING"/summary.txt'''
if TORSION_check.get() == 1:
BASHSCRIPT+='''\n echo -e "Peptide Torsions: OFF" >>"$WORKING"/summary.txt'''
if TORSION_check.get() == 0:
BASHSCRIPT+='''\n echo -e "Peptide Torsions: ON" >>"$WORKING"/summary.txt'''
BASHSCRIPT+='''\ntime=`date +"%c"`;echo -e "\\n\\nPeptide preparation start time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt'''
if PEPMODEL_check.get() == 1:
if PEPSS_check.get() == 1:
BASHSCRIPT+='''
clear
#~~~~~ Peptide Secondary Structure ~~~~~~~~~~~~~~
echo -e "##~~~ Running PSI-PRED prediction ~~~~##"
time=`date +"%c"`;echo -e "Secondary structure prediction start time : "$time"\\n" >>"$WORKING"/summary.txt
cd "$WORKING"; mkdir psipred modpep; cd psipred;
echo -n "ls -1 | parallel -j 1 rm {}" >del.bash
cat "$PEPTIDE"/"$INPUTPEP" | parallel -j "$joobs" --eta "mkdir {}; cd {};echo '>seq1' >{}.txt; echo {} >>{}.txt;"$PSIPRED"/runpsipred {}.txt &>>log_{}.txt;cp {}.ss2 ../; bash ../del.bash;cd ../;rmdir {};"
clear
time=`date +"%c"`;echo -e "Secondary structure prediction end time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
#~~~~~~~~~~~~ Peptide Modelling ~~~~~~~~~~~~~~~~~~~
echo -e "##~~~ Running Peptide structure modelling using MODPEP ~~~~##"
time=`date +"%c"`;echo -e "Peptide modelling using modpep start time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
cd "$WORKING"/modpep;mv ../psipred/del.bash .;mkdir temp; cd temp; cp "$MODPEP"/*.pdb .; rm 1kv6_C.pdb;cd ..;
cat "$PEPTIDE"/"$INPUTPEP" | parallel -j "$joobs" --eta "mkdir {}; cd {};echo '>seq1' >{}.txt; echo {} >>{}.txt;cp ../temp/*.pdb .;"$MODPEP"/modpep {}.txt {}.pdb -n "$NUMMOD" -L ./ -h ../../psipred/{}.ss2 &>>log_{}.txt;cp {}.pdb ../; bash ../del.bash;cd ../;rmdir {};"
cd temp; ls -1 | parallel "rm {}"; cd ../; rmdir temp; rm del.bash
'''
elif PEPSS_check.get() == 0:
BASHSCRIPT+='''
clear
echo -e "##~~~ Running Peptide structure modelling using MODPEP ~~~~##"
time=`date +"%c"`;echo -e "Peptide modelling using modpep start time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
cd "$WORKING"; mkdir modpep;
cd modpep;
echo -n "ls -1 | parallel -j 1 rm {}" >del.bash
mkdir temp; cd temp; cp "$MODPEP"/*.pdb .; rm 1kv6_C.pdb;cd ..;
cat "$PEPTIDE"/"$INPUTPEP" | parallel -j "$joobs" --eta "mkdir {}; cd {};echo '>seq1' >{}.txt; echo {} >>{}.txt;cp ../temp/*.pdb .;"$MODPEP"/modpep {}.txt {}.pdb -n "$NUMMOD" -L ./ &>>log_{}.txt;cp {}.pdb ../; bash ../del.bash;cd ../;rmdir {};"
cd temp; ls -1 | parallel -j 1 "rm {}"; cd ../; rmdir temp;rm del.bash
'''
if NUMMOD > 1:
BASHSCRIPT+='''
if [ "$NUMMOD" -gt 1 ]
then
clear
cd "$WORKING"/modpep;
echo -e "##~~ Spliting the Modelled Peptides~~~##"
echo -n "a=1;while read -r l;do echo \\"\$l\\" >>\$1_\$a.pdb; if [ \\"\$l\\" == 'ENDMDL' ]; then a=\`expr \$a + 1\`; fi; done <\$1.pdb; rm \$1.pdb" >split.bash
ls -1U | grep 'pdb' | parallel -j "$joobs" --eta "bash split.bash {.}"
rm split.bash
fi
'''
BASHSCRIPT+='''
cd "$WORKING"/modpep
echo -n "
#-*- coding: utf-8 -*-
import sys
asd=open(sys.argv[1],'r')
FILE1=asd.readlines()
asd.close()
asd=open(sys.argv[1],'w')
for f in FILE1:
if f[0:6].strip() == 'ATOM':
stump=f[0:21]+'P'+f[22:]
asd.write(stump)
asd.close()" >chainadd.py
echo -e "##~~ Adding Chain name to the Peptides~~~##"
ls -1U | grep 'pdb' | parallel -j "$joobs" --eta "python chainadd.py {}"
rm chainadd.py
time=`date +"%c"`;echo -e "Peptide modelling using modpep end time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
'''
if MINIM_check.get() == 1:
BASHSCRIPT+='''
clear
#~~~~~ MINIMIZATION
cd "$WORKING"
mkdir minim; cd minim; mkdir error_minim
#~~~ MDP FILE: Vacuum ~~~~#
echo -n "
integrator = steep
emtol = 1000.0
nsteps = 50000
nstenergy = 1
emstep = 0.01
energygrps = system
nstlist = 1
cutoff-scheme = group
ns_type = grid
rlist = 1.0
coulombtype = cut-off
rcoulomb = 1.0
rvdw = 1.0
pbc = no" >minim_vacuum.mdp
#~~~ MDP FILE: Solvated ~~~~#
echo -n "
define = -DFLEXIBLE
integrator = steep
emtol = 1000.0
nsteps = 50000
nstenergy = 1
emstep = 0.01
energygrps = system
nstlist = 1
ns_type = grid
rlist = 1.0
coulombtype = PME
rcoulomb = 1.0
rvdw = 1.0
pbc = xyz" >minim_solv.mdp
#~~~~ Gromacs Minimization python script ~~~~~~#
echo -n "
#-*- coding: utf-8 -*-
#Check rmdir in local system.
import subprocess
import re
import sys
import os
from shutil import copyfile
from shutil import move
def ant (line,at):
### Extract the details about atom type, reisdue name, chain ID, atom number, residue number and x,y,z co-ordinates.
atom_hetatm=line[0:6].strip()
if atom_hetatm in ['ATOM','HETATM']: #splicing the second index value omited i.e [7:11] means will return value from 7-10
if at=='an':
atom_number=line[6:11].strip()
return atom_number
#print(atom_number)
elif at=='aa':
atom_name=line[12:16].strip()
return atom_name
#print(atom_name)
elif at=='ra':
res_name=line[17:20].strip() #check
return res_name
#print(res_name)
elif at=='ca':
chain=line[21].strip() #check
return chain
#print(chain)
elif at=='rn':
res_number=line[22:26].strip()
return res_number
#print(res_number)
elif at=='x':
x_co=line[30:38].strip()
return x_co
#print(x_co)
elif at=='y':
y_co=line[38:46].strip()
return y_co
#print(y_co)
elif at=='z':
z_co=line[46:54].strip()
return z_co
#print(z_co)
elif at=='xyz':
xyz_co=[line[30:38].strip()]
xyz_co.append(line[38:46].strip())
xyz_co.append(line[46:54].strip())
return xyz_co
#print (xyz_co)
else:
return 'ERROR'
#print (Error)
return 0
GMX_PREFIX='"$GROMACS_PREFIX"' # gromacs prefix
GROMACS='True'
SIM_INPUT=sys.argv[1]
FORCEFIELD='gromos53a6' # Forcefield
WATER='spc' # water-model
WATERGRO='spc216.gro' # water-model gro file
os.mkdir(SIM_INPUT.split('.')[0])
os.chdir(SIM_INPUT.split('.')[0])
move('../'+SIM_INPUT,SIM_INPUT)
if GROMACS == 'True':
copyfile('../minim_vacuum.mdp','minim_vacuum.mdp')
copyfile('../minim_solv.mdp','minim_solv.mdp')
asd=subprocess.Popen([GMX_PREFIX,'pdb2gmx','-f',SIM_INPUT,'-p','protein.top','-o','protein.gro','-ignh','-ff',FORCEFIELD,'-water',WATER], stdin=subprocess.PIPE,stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at pdb2gmx!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at pdb2gmx!'+'\\n')
errq.close()
sys.exit(1)
if re.match('Total charge', f):
CHARGE=float(f.split()[2])
if os.path.isfile('protein.gro') and os.path.getsize('protein.gro') > 0:
pass
else:
#print('Fatal Error: Found at pdb2gmx!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at pdb2gmx!'+'\\n')
errq.close()
sys.exit(1)
#print(CHARGE)
#print('~~~~~PDB2GMX Finished!~~~~~~~~~~~~')
pass
##pdb2gmx##
#~~~~~~vacuum minimization~~~~~~#
asd=subprocess.Popen([GMX_PREFIX,'grompp', '-f', 'minim_vacuum.mdp', '-c', 'protein.gro','-p', 'protein.top', '-o', 'protein_vacuum.tpr'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
#print('Fatal Error: Found at grompp vacuum!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at grompp vacuum!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_vacuum.tpr') and os.path.getsize('protein_vacuum.tpr') > 0:
pass
else:
#print('Fatal Error: Found at grompp vacuum!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at grompp vacuum!'+'\\n')
errq.close()
sys.exit(1)
pass
asd=subprocess.Popen([GMX_PREFIX,'mdrun', '-deffnm', 'protein_vacuum'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at mdrun vacuum!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at mdrun vacuum!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_vacuum.gro') and os.path.getsize('protein_vacuum.gro') > 0:
pass
else:
#print('Fatal Error: Found at mdrun vacuum!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at mdrun vacuum!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~Minimization in vacuum Finished!~~~~~~~~~~~~')
pass
#~~~~~Editconf~~~~~~~~~~~
asd=subprocess.Popen([GMX_PREFIX,'editconf','-f','protein_vacuum.gro','-o','protein_pbc.gro','-bt','cubic','-d','1.0'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at editconf!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at editconf!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_pbc.gro') and os.path.getsize('protein_pbc.gro') > 0:
pass
else:
#print('Fatal Error: Found at editconf!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at editconf!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~EDITCONF Finished!~~~~~~~~~~~~')
pass
asd=subprocess.Popen([GMX_PREFIX,'solvate', '-cp', 'protein_pbc.gro', '-cs', WATERGRO, '-p', 'protein.top', '-o', 'protein_water.gro'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at solvate!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at solvate!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_water.gro') and os.path.getsize('protein_water.gro') > 0:
pass
else:
#print('Fatal Error: Found at solvate!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at solvate!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~GENBOX Finished!~~~~~~~~~~~~')
pass
if CHARGE < 0:
IONS='POS'
CHARGE=int(round(CHARGE*(-1)))
elif CHARGE > 0:
IONS='NEG'
CHARGE=int(round(CHARGE*(1)))
elif CHARGE == 0:
IONS='NEU'
os.rename('protein_water.gro','protein_ions.gro')
if CHARGE != 0:
asd=subprocess.Popen([GMX_PREFIX,'grompp', '-f', 'minim_solv.mdp', '-c', 'protein_water.gro', '-p', 'protein.top', '-o', 'protein_ions.tpr'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at grompp genion!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at grompp genion!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_ions.tpr') and os.path.getsize('protein_ions.tpr') > 0:
pass
else:
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at grompp genion!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at genion!'+'\\n')
errq.close()
sys.exit(1)
pass
if IONS == 'POS':
asd=subprocess.Popen([GMX_PREFIX,'genion', '-s', 'protein_ions.tpr', '-o', 'protein_ions.gro', '-p', 'protein.top', '-pname', 'NA', '-np', str(CHARGE)], stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,error=asd.communicate('SOL')
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at genion!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at genion!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_ions.gro') and os.path.getsize('protein_ions.gro') > 0:
pass
else:
#print('Fatal Error: Found at genion!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at genion!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~GENION Finished!~~~~~~~~~~~~')
elif IONS == 'NEG':
asd=subprocess.Popen([GMX_PREFIX,'genion', '-s', 'protein_ions.tpr', '-o', 'protein_ions.gro', '-p', 'protein.top', '-nname', 'CL', '-nn', str(CHARGE)], stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,error=asd.communicate('SOL')
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at genion!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at genion!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_ions.gro') and os.path.getsize('protein_ions.gro') > 0:
pass
else:
#print('Fatal Error: Found at genion!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at genion!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~GENION Finished!~~~~~~~~~~~~')
pass
#~~~~~~~~~Steep minimization~~~~~~~~~~~
asd=subprocess.Popen([GMX_PREFIX,'grompp', '-f', 'minim_solv.mdp', '-c', 'protein_ions.gro', '-p', 'protein.top', '-o', 'protein_minim.tpr'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
#print('Fatal Error: Found at grompp minim steep!')
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at grompp minim steep!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_minim.tpr') and os.path.getsize('protein_minim.tpr') > 0:
pass
else:
#print('Fatal Error: Found at grompp minim steep!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at grompp minim!'+'\\n')
errq.close()
sys.exit(1)
asd=subprocess.Popen([GMX_PREFIX,'mdrun', '-v', '-deffnm', 'protein_minim'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
#~~Check for fatal error~~~
for f in error.split('\\n'):
if (re.match('Fatal error',f) or re.match('Can not open file',f)):
#print('Fatal Error: Found at mdrun minim steep!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at mdrun minim!'+'\\n')
errq.close()
sys.exit(1)
if os.path.isfile('protein_minim.gro') and os.path.getsize('protein_minim.gro') > 0:
pass
else:
#print('Fatal Error: Found at mdrun minim steep!')
copyfile(SIM_INPUT,'../error_minim/'+SIM_INPUT)
delete=os.listdir('.')
for ff in delete:
os.remove(ff)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
errq=open('error_minim/error_log.txt','a')
errq.write(str(SIM_INPUT.split('.')[0])+' Fatal Error: Found at mdrun minim!'+'\\n')
errq.close()
sys.exit(1)
#print('~~~~~MINIMIZATION USING STEEPEST DESCENTS Finished!~~~~~~~~~~~~')
pass
asd=subprocess.Popen([GMX_PREFIX,'editconf','-f','protein_minim.gro','-o','protein_minim.pdb'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output,error=asd.communicate()
asd.wait()
pass
zxc=open('protein_minim.pdb','r')
mnb=zxc.readlines()
zxc.close
CHAIN='P'
zxc=open('../'+SIM_INPUT,'w')
for f in mnb:
if ant(f,'ra') not in ['SOL','NA','CL']:
if f[0:6].strip() in ['ATOM']:
stump=f[0:21]+CHAIN+f[22:]
zxc.write(stump) #add chain and atom type in the end column
# else:
# zxc.write(f)
zxc.close()
delete=os.listdir('.')
for f in delete:
os.remove(f)
os.chdir('..')
os.rmdir(SIM_INPUT.split('.')[0])
#print('~~~~~MINIMIZATION Finished!~~~~~~~~~~~~')
" >PepLib_Minim.py
echo -e "#~~~ Running Peptide Minimization~~~~#"
time=`date +"%c"`;echo -e "Peptide minimization start time : "$time"\\n" >>"$WORKING"/summary.txt\n'''
if PEPMODEL_check.get() == 1:
BASHSCRIPT+='''\nls -1U ../modpep/ | grep 'pdb' | parallel -j 1 --eta "cp ../modpep/{} .; python PepLib_Minim.py {}"'''
elif PEPMODEL_check.get() == 0:
BASHSCRIPT+='''\nls -1U "$PEPTIDE" | grep 'pdb' | parallel -j 1 --eta "cp "$PEPTIDE"/{} .; python PepLib_Minim.py {}"'''
BASHSCRIPT+='''
rm *.mdp; rm PepLib_Minim.py
errcheck=`ls -1 error_minim/`
if [ -n "$errcheck" ]
then
:
else
rmdir error_minim
fi
time=`date +"%c"`;echo -e "Peptide minimization end time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
'''
if PDBQT_check.get() == 1:
BASHSCRIPT+='''
clear
cd "$WORKING"
mkdir pdbqt; cd pdbqt; mkdir error_pdbqt
cp "$MGLROOT"/MGLToolsPckgs/AutoDockTools/Utilities24/prepare_ligand4.py .
echo -n "
#!/bin/bash
MINIM="$MINIM"
pdbqt_error=\`grep \\"Sorry\\\, there are no Gasteiger parameters\\" \\"\$1\\"\`
pdbqt_warn_error=\`grep \\"WARNING:\\" \\"\$1\\"\`
traceback_error=\`grep \\"Traceback\\" \\"\$1\\"\`
if [ -n \\"\$pdbqt_error\\" ] || [ -n \\"\$pdbqt_warn_error\\" ] || [ -n \\"\$tracebackerror\\" ]
then
if [ \\"\$MINIM\\" == \\"YES\\" ]
then
cp "$WORKING"/minim/\\"\$2\\" "$WORKING"/pdbqt/error_pdbqt/ 2>/dev/null
else
cp "$WORKING"/modpep/\\"\$2\\" "$WORKING"/pdbqt/error_pdbqt/ 2>/dev/null
fi
rm \\"\$3\\" 2>/dev/null
fi" >pddbqt_error_check.bash
echo -e "#~~~ Running PDBQT conversion ~~~~#"
time=`date +"%c"`;echo -e "PDBQT conversion start time : "$time"\\n" >>"$WORKING"/summary.txt
'''
if MINIM_check.get() == 1:
if TORSION_check.get() == 1:
BASHSCRIPT+='''
ls -1 "$WORKING"/minim/ | grep 'pdb' | parallel -j "$joobs" --eta --no-notice ""$MGLROOT"/bin/pythonsh prepare_ligand4.py -l "$WORKING"/minim/{} -A bonds_hydrogens -Z &>>{.}_log.txt ; bash pddbqt_error_check.bash {.}_log.txt {} {.}.pdbqt ; rm {.}_log.txt"
'''
elif TORSION_check.get() == 0:
BASHSCRIPT+='''
ls -1 "$WORKING"/minim/ | grep 'pdb' | parallel -j "$joobs" --eta --no-notice ""$MGLROOT"/bin/pythonsh prepare_ligand4.py -l "$WORKING"/minim/{} -A bonds_hydrogens &>>{.}_log.txt ; bash pddbqt_error_check.bash {.}_log.txt {} {.}.pdbqt ; rm {.}_log.txt"
'''
elif MINIM_check.get() == 0:
if TORSION_check.get() == 1:
BASHSCRIPT+='''
ls -1 "$WORKING"/modpep/ | grep 'pdb' | parallel -j "$joobs" --eta --no-notice ""$MGLROOT"/bin/pythonsh prepare_ligand4.py -l "$WORKING"/modpep/{} -A bonds_hydrogens -Z &>>{.}_log.txt ; bash pddbqt_error_check.bash {.}_log.txt {} {.}.pdbqt ; rm {.}_log.txt"
'''
elif TORSION_check.get() == 0:
BASHSCRIPT+='''
ls -1 "$WORKING"/modpep/ | grep 'pdb' | parallel -j "$joobs" --eta --no-notice ""$MGLROOT"/bin/pythonsh prepare_ligand4.py -l "$WORKING"/modpep/{} -A bonds_hydrogens &>>{.}_log.txt ; bash pddbqt_error_check.bash {.}_log.txt {} {.}.pdbqt ; rm {.}_log.txt"
'''
BASHSCRIPT+='''
rm pddbqt_error_check.bash prepare_ligand4.py
errcheck=`ls -1 error_pdbqt/`
if [ -n "$errcheck" ]
then
:
else
rmdir error_pdbqt
fi
time=`date +"%c"`;echo -e "PDBQT conversion end time : "$time"\\n\\n\\n" >>"$WORKING"/summary.txt
'''
BASHSCRIPT+='''\ntime=`date +"%c"`;echo -e "\\n\\n\\n\\nPeptide preparation end time : "$time"\\n" >>"$WORKING"/summary.txt'''
os.chdir(WORKING)
pep_write=open('Pep_Mod.bash','w')
pep_write.write(BASHSCRIPT)
pep_write.close()
root.destroy()
Button(run_pep,text="Hit Run!",bg="black",fg="white",font=("Times",15,"bold","underline"),width=10,height=2,command=print_bash_script).grid(row=12,column=0,columnspan=2,sticky=E+W+N+S)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peptide Screening Tools ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#~~~ AutoDock Vina: start
def run_vina():
docktools.destroy()
vina_vs=Toplevel(root)
global CWD
Label(vina_vs,text="AutoDock Vina: Inputs",bg="white",font=("Times",15,"bold"),relief=SOLID,width=30,height=3).grid(row=0,column=0,columnspan=2,sticky=E+W+N+S)
Label(vina_vs,bg="white",text="Enter the peptide structures \n in pdbqt format:",font=("Times",15,"bold"),relief=SOLID,width=30,height=3).grid(row=1,column=0,sticky=E+W+N+S)
def get_peptide_dir():
filetemp=tkFileDialog.askdirectory(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/peptide",title="Enter the peptide structures directory",parent=vina_vs)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=vina_vs)
return
else:
global PEPTIDE
PEPTIDE=filetemp
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=vina_vs)
return
Button(vina_vs,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=3,command=get_peptide_dir).grid(row=1,column=1,sticky=E+W+N+S)
Label(vina_vs,bg="white",text="Enter the receptor structures:",font=("Times",15,"bold"),relief=SOLID,width=30,height=3).grid(row=2,column=0,sticky=E+W+N+S)
def get_receptor_dir():
filetemp=tkFileDialog.askdirectory(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/receptor",title="Enter the receptor structures directory",parent=vina_vs)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=vina_vs)
return
else:
global RECEPTOR
RECEPTOR=filetemp
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=vina_vs)
return
Button(vina_vs,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=3,command=get_receptor_dir).grid(row=2,column=1,sticky=E+W+N+S)
Label(vina_vs,bg="white",text="Enter the working directory:",font=("Times",15,"bold"),relief=SOLID,width=30,height=3).grid(row=3,column=0,sticky=E+W+N+S)
def get_working_dir():
filetemp=tkFileDialog.askdirectory(initialdir="/home/bioinfo/Desktop/sam/pep_docking/gui/working",title="Enter the working directory",parent=vina_vs)
if filetemp:
if ' ' in filetemp:
tkMessageBox.showinfo("Warning!","Space found in the directory path!\nKindly remove the space",parent=vina_vs)
return
else:
os.chdir(filetemp)
zxc=os.listdir('.')
if zxc:
tkMessageBox.showinfo("Warning!","Working directory is not empty!",parent=vina_vs)
return
else:
global WORKING
WORKING=filetemp
os.chdir(CWD)
else:
tkMessageBox.showinfo("Warning!","Directory not specified!",parent=vina_vs)
return
Button(vina_vs,text="Open",bg="gold",font=("Times",15,"bold","underline"),relief=RAISED,borderwidth=3,width=10,height=3,command=get_working_dir).grid(row=3,column=1,sticky=E+W+N+S)
#~~~~~~~~~~~~~~ Number of CPU calculation start
Ncpu=multiprocessing.cpu_count()
Label(vina_vs,bg="white",text=str(Ncpu)+" number of CPU processors \n detected in your system",relief=SOLID,font=("Times",15,'bold'),width=30,height=3,justify=CENTER).grid(row=4,column=0,columnspan=2,sticky=E+W+N+S)
Label(vina_vs,bg="white",text="Enter the No. of CPU \nfor single vina job:",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=5,column=0,sticky=W+E+N+S)
global Numcpu
Numcpu=StringVar()
Numcpu.set(8)
joobs=int(Ncpu/int(Numcpu.get()))
if joobs:
Label(vina_vs,bg="white",text= str(int(Ncpu/int(Numcpu.get())))+" Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=6,column=0,columnspan=2,sticky=W+E+N+S)
Entry(vina_vs,bd=5,textvariable=Numcpu,font=("Times",15,'bold'),justify=CENTER).grid(row=5,column=1,sticky=W+E+N+S)
def checkback(*args):
for f in Numcpu.get():
if f not in '1234567890' :
tkMessageBox.showinfo("Warning","Please provide the integer Values!",parent=vina_vs)
return
global joobs
joobs=0
if len(Numcpu.get()) > 0:
if int(Numcpu.get()) > Ncpu or int(Numcpu.get()) == 0 :
tkMessageBox.showinfo("Warning","Please provide the values less than "+str(Ncpu)+"!",parent=vina_vs)
return
else:
Label(vina_vs,bg="white",text= str(int(Ncpu/int(Numcpu.get())))+" Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=6,column=0,columnspan=2,sticky=W+E+N+S)
joobs=int(Ncpu/int(Numcpu.get()))
else:
Label(vina_vs,bg="white",text= "0 Jobs will run in parallel",relief=SOLID,font=("Times",15,'bold'),width=30,height=2,justify=CENTER).grid(row=6,column=0,columnspan=2,sticky=W+E+N+S)
Numcpu.trace('w',checkback)
#~~~~~~~~~~ Number of CPU calculation end
#~~~~~ Exhaustiveness start
Label(vina_vs,bg="white",text="Enter the exhaustiveness:",font=("Times",15,"bold"),relief=SOLID,width=30,height=3).grid(row=7,column=0,sticky=E+W+N+S)
Exhaust=StringVar()
Exhaust.set(8)