-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathduck.svl
More file actions
988 lines (831 loc) · 28.5 KB
/
Copy pathduck.svl
File metadata and controls
988 lines (831 loc) · 28.5 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
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
#svl
// duck.svl : GUI for setting up a dynamic undocking calculation
// 04 Feb 2017 (PS) added support for newer amber versions
//
// COPYRIGHT (C) 1996-2016 CHEMICAL COMPUTING GROUP INC. ALL RIGHTS RESERVED.
//
// PERMISSION TO USE, COPY, MODIFY AND DISTRIBUTE THIS SOFTWARE IS HEREBY
// GRANTED PROVIDED THAT: (1) UNMODIFIED OR FUNCTIONALLY EQUIVALENT CODE
// DERIVED FROM THIS SOFTWARE MUST CONTAIN THIS NOTICE; (2) ALL CODE DERIVED
// FROM THIS SOFTWARE MUST ACKNOWLEDGE THE AUTHOR(S) AND INSTITUTION(S); (3)
// THE NAMES OF THE AUTHOR(S) AND INSTITUTION(S) NOT BE USED IN ADVERTISING
// OR PUBLICITY PERTAINING TO THE DISTRIBUTION OF THE SOFTWARE WITHOUT
// SPECIFIC, WRITTEN PRIOR PERMISSION; (4) ALL CODE DERIVED FROM THIS SOFTWARE
// BE EXECUTED WITH THE MOLECULAR OPERATING ENVIRONMENT (MOE) LICENSED FROM
// CHEMICAL COMPUTING GROUP INC.
//
// CHEMICAL COMPUTING GROUP INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
// SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
// AND IN NO EVENT SHALL CHEMICAL COMPUTING GROUP INC. BE LIABLE FOR ANY
// SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
// RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
// CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#set title 'Dynamic UndoCKing'
#set class 'MOE:simulation'
#set version '2016.09'
#set main 'DuckPanel'
const CLI = 0;
const WINDOW_NAME = 'DynamicUndocking';
global JPATH;
global FFPATH;
global SCRIPTSPATH;
function _Atoms;
function fwrite_MOE;
function fwrite_AmberMOL2;
function export2FRCMod;
function writeAmberInputs;
function launchAmber;
//SRC GTI
function writeAmberLaunchScripts;
function launchAmber_GTI;
function launchAmber_Workstation;
function writeAmberLaunchScripts_GTI;
function my_fwrite_PDB;
function MM;
function PartialCharge;
function ph4_aDonor, ph4_aAcceptor;
// estimate the memory needed for the calculation
// returns all the atoms from set a that are within 'dist' angstrom from b
local function atoms_within[ a, b, dist ]
if (length b) == 0 or (length a) == 0 then
return [];
endif
local pkey = prox_open [ dist, aPos b, dist ];
local [seg,idx,sqr_dist] = prox_find[ pkey, aPos a, 0.0 ];
prox_close pkey;
local aidx = x_pack seg;
return a[aidx];
endfunction
// stolen from prolib.svl
local function replace_string [s, pos, replacement]
local s1, s2;
s1 = keep [s, (first pos) -1];
s2 = keep [s, -(length s - (last pos))];
return cat [s1, replacement, s2];
endfunction
// stolen from prolib.svl
local function inside_bracket [s,p]
local bc = strpos ["]", drop [s, p]];
if bc > 0 then bc = bc + p; endif
local bo = strpos ["[", drop [s, p]];
if bo > 0 then bo = bo + p; endif
local c;
if bo == 0 and bc <> 0 then
c = 1;
elseif bc == 0 and bo <> 0 then
c = 1;
else
c = select [1,0, bc < bo];
endif
return c and not (s(p) == "[" or s(p) == "]");
endfunction
// stolen from prolib.svl
local function search_and_replace_all [s, word, replacement, opt]
opt = cat [opt, [add_brackets:0]];
local p, rplmnt;
if word === "" then return s; endif
while p = strpos [word, s] loop
if opt.add_brackets === 1 then
if not inside_bracket [s, p] then
rplmnt = cat ["[", replacement, "]"];
else
rplmnt = replacement;
endif
endif
s = replace_string [s, [p, p + length word - 1 ], rplmnt];
endloop
return s;
endfunction
local function MyBrowseFile [wkey, trig, targets]
const DEF_OPT = [ title: 'Select File', mode: 'none', filter: '' ];
local wname = token drop [string trig, length "browse_"];
if m_diff [wname, tags targets] then return 0; endif
// Parent task: create a child task and return immediately
// the task id of the child.
local [taskid, taskcode] = task_fork [master:'parent', errmsg:'ignore'];
if taskcode <> 'child' then return taskid; endif
// Child task: does not return, only exits.
// If there is a filename, we update the textfield "wname" in wkey.
local opt = cat [targets.(wname), DEF_OPT];
local fn = FilePrompt [opt.title, opt.mode, opt.filter];
if length fn then WindowSetData [wkey, tag [wname, fn]]; endif
exit[];
endfunction
local function makeMDDirs[]
local fileList=fbase ftail flist [];
if indexof['lib',fileList]==0 then
fmkdir 'lib';
endif
endfunction
local function writeDoLeap[ligand,dirName,options,suppFFParams,lenRec,solvation]
local fh;
if(solvation==1) then
fh=fopenw twrite['{}/do.leap',dirName]; //open file handle
else
fh=fopenw twrite['{}/doleaped.leap',dirName]; //open file handle
endif
print options.ffParams;
fwrite [fh,'source oldff/leaprc.ff99SBildn\n'];
fwrite [fh,'source leaprc.ff99SBildn\n'];
fwrite [fh,'loadOff ions94.lib\n'];
if length options.ffParams[1]>0 then
local el;
local mkeyList=[];
local mkey;
local paramFileName;
for el in cat options.ffParams[1] loop
mkeyList=cat [mkeyList,Message[0,twrite['Adding additional parameters to leap file: {}',el]]];
paramFileName=(cat suppFFParams) | rotr (cat suppFFParams)==el;
fwrite [fh,'loadOff {}/{}.lib\n',FFPATH,paramFileName];
fwrite [fh,'loadAmberPrep {}/{}.prp\n',FFPATH,paramFileName];
endloop
sleep 2;
for mkey in mkeyList loop
Message[mkey,''];
endloop
endif
if length ligand>0 then
// local resNames=uniq rName oResidues ligand;
local res;
for res in uniq oResidues ligand loop
local ligName=rName res;
print cat['Identified Residue ',ligName,' as ligand'];
fwrite [fh,'loadAmberParams {}.frcmod\n',ligName];
fwrite [fh,'{}=loadMol2 {}_ok.mol2\n',ligName,ligName];
endloop
fwrite [fh,'receptor=loadPdb system.pdb\n'];
fwrite [fh,'system=combine \{{receptor'];
for res in uniq oResidues ligand loop
fwrite [fh,' {}',rName res];
endloop
fwrite [fh,'\}\n'];
else
fwrite [fh,'system=loadPdb system.pdb\n'];
endif
if(solvation==1) then
fwrite [fh,'addIons system Cl- 0\n'];
fwrite [fh,'addIons system Na+ 0\n'];
fwrite [fh,'solvateBox system TIP3PBOX 18.0 0.65\n'];
fwrite [fh,'saveAmberParm system system_solv.prmtop system_solv.prmcrd\n'];
fwrite [fh,'savePdb system system_solv.pdb\n'];
else
fwrite [fh,'savePdb system system_leaped.pdb\n'];
endif
fwrite [fh,'quit'];
fclose fh; //close file handle
endfunction
local function writeSystemPdb[receptor,fName]
local pdb_options = [
use_chain_id : 1,
force_TER : 1
];
pdb_options.hnames = 'PDB v3.0';
pdb_options.amber = 1;
my_fwrite_PDB [fName,receptor,pdb_options];
endfunction
local function writeLigand[ligand,dirName]
if length ligand == 0 then
return [];
endif
local count=0;
local res= uniq oResidues ligand;
local curRes;
for curRes in res loop
print "writing";
local resName=rName curRes;
local selection=cat oAtoms curRes;
print resName;
print length selection;
export2FRCMod[tok_cat[dirName,resName,'.frcmod'],selection];
fwrite_AmberMOL2[tok_cat[dirName,resName,'_ok.mol2'], selection, []];
endloop
//local resName=first rName oResidues ligand;
endfunction
local function executeLeap [path,leapfile]
local currentDir= cd '.';
cd path;
local pid=exe_open [twrite['tleap -f {}',leapfile]];
local fout=exe_stdout pid;
local ferr=exe_stdout pid;
local tleap_msg_key = Message [0, 'Configuring the system using Ambertools'];
loop
sleep 1;
until exe_status pid ==0
endloop
exe_close pid;
Message[tleap_msg_key,[]];
local msgKey=Message [0,'Tleap finished running.'];
cd currentDir;
return msgKey;
endfunction
//local function DEPR_selectAtomsFromReceptorAndLigandDB[selAtomPosition, options]
// local a=Atoms[];
// Select the reference atom from coordinates
//loop over all selected atoms if multiple atoms selected
// for curPos in selAtomPositions loop
// aSetSelected[a[x_min app add tr abs(curPos-aPos Atoms[])],1];
// endloop
// aSetSelected[a[x_min app add tr abs(selAtomPosition-aPos Atoms[])],1];
// XB - ini
// changed this expression for a simpler one (not sure what this $$ligand thing is...)
// local ligand_atoms=_Atoms '$$ligand' | (rName aResidue _Atoms '$$ligand' == 'LIG');
// PS - comment, this is some stuff that can be useful in some cases but not for this application here.
// sqrt(add(pow [(oCenterOfMass s2 - oCenterOfMass s1),2 ]))
// local ligand_atoms = a | rName aResidue a == 'LIG';
// keep only the complementary atoms of the ligand
// local asubset;
// if isdonor==1 then
// asubset = ligand_atoms | ph4_aAcceptor ligand_atoms;
// else
// asubset = ligand_atoms | ph4_aDonor ligand_atoms;
// endif
// if length asubset < 1 then
// print 'This ligand does not have any atom of the right type.';
// endif
// aSetSelected[asubset[x_min aDist [SelectedAtoms[],asubset]],1];
// if add aSelected a <> 2 then
// print 'Number of selected atoms different than 2. Something went wrong. Must end here.';
// exit[];
// endif
//
// // PS not used anymore
// // local dist = aDist [first SelectedAtoms[], second SelectedAtoms[]];
// // if dist > 3.2 then
// // print 'Selected atoms are not within H-bond distance. Must end here.';
// // exit [];
// // endif
// // XB - end
//
//
// endfunction
function startMD;
local function startDB[options,suppFFParams]
pot_Load '$MOE/lib/pfrosst.ff';
local currentDir=cd '.';
local selAtomPosition=aPos SelectedAtoms[];
local tmpName='tmp_receptor.moe';
SaveAs tmpName;
Close[force:1];
//copy some important launch and analysis scripts
JPATH = getenv 'MOE_SVL_LOAD';
SCRIPTSPATH = tok_cat [ JPATH , '/scripts'];
//local rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/duck_template_gpu.sh'], 'duck_template_gpu.sh'];
//rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/duck_template_325K_gpu.sh'], 'duck_template_325K_gpu.sh'];
local rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/getWqbValues.R'], 'getWqbValues.R'];
if options.queue_IN === 'GTI' then
rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/submit_duck_smd_gpu_GTI.sh'], 'submit_duck_smd_gpu_GTI.sh'];
endif
if options.queue_IN === 'Marc' then
rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/submit_duck_smd_gpu_MARC.csh'], 'submit_duck_smd_gpu.csh'];
endif
if options.input_WS == 1 then
rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/launch_duck_gpu_Workstation.sh'], 'launch_duck_gpu_Workstation.sh'];
endif
print 'Opening ligand MDB file';
if ftype options.ligand_db<>'file' then
print 'Opening ligand database not possible. Please check that your path is correctly pointing to a valid mdb file.';
return;
endif
local mdb=db_Open options.ligand_db;
local entries=db_Entries mdb;
local molfield='mol';
local [fields, types] = db_Fields mdb;
local molfieldtype = types | (fields == molfield);
if molfieldtype<>'molecule' then
write ['Warning, field named {} does not exist.',molfield];
molfield=db_FirstFieldType[mdb,'molecule'];
write [' Using field named {} instead.',molfield];
endif
local entry;
//loop over all entries to get the ligand molecule
local molCount=1;
//removed for avoiding writing q files in main folder
////SRC GTI queue in
// //writeAmberLaunchScripts options;
// print options.queue_IN;
// if options.queue_IN === 'GTI' then
// writeAmberLaunchScripts_GTI options;
// endif
// if options.queue_IN === 'Marc' then
// writeAmberLaunchScripts options;
// endif
////SRC GTI queue end
local molCount_mopacError=0; //SRC define for MOPAC error
local fh_MOPAC_created=0; //SRC define for MOPAC
for entry in entries loop
Open tmpName;
local msgKey=Message[0,tok_cat['Preparing simulations for molecule ',totok molCount]];
local protein=cat oAtoms Chains[];
local ligand=mol_Create first db_ReadFields [mdb,entry,molfield];
// local ligandName=first first ligand;
// get rid of minimization
// if options.tethered_min_DB==1 then
// //set thether only on protein atoms
// print 'setting tethers to ligand and receptor';
// local heavyProteinAtoms=protein | ((aAtomicNumber protein)<>1);
// aSetTether[heavyProteinAtoms, aPos heavyProteinAtoms,10,0,0.25];
// local heavyLigandAtoms=cat oAtoms ligand | ((aAtomicNumber cat oAtoms ligand)<>1);
// aSetTether[heavyLigandAtoms, aPos heavyLigandAtoms,1,0,0.25];
// print 'starting minimisation';
// MM[pot_charge:1];
// endif
//rename residues systematically to LIG
local ligResidues=uniq cat aResidue oAtoms ligand;
local el;
for el in ligResidues loop
rSetName[el,'LIG'];
local ligAtoms=cat oAtoms el;
//SRC MOPAC ERROR
local flag_mopacError = 0;
local [result,return_code] = task_call['PartialCharge',[ligAtoms, 'AM1-BCC'],[errmsg:'ignore']];
if return_code == 'error' then
flag_mopacError=1;
else
local q=first result;
aSetCharge [ligAtoms,q];
endif
endloop
if flag_mopacError == 1 then
print 'Error calculating charges, skipping ligand.';
if molCount_mopacError == 0 then
fh_MOPAC_created=1;
local fh_MOPAC;
fh_MOPAC = fopenw twrite['DUCK_charge_errors.txt','./']; //open file handle
molCount_mopacError = 1;
endif;
fwrite [fh_MOPAC,'LIG_target_{}\n',molCount];
molCount = molCount+1;
Close[force:1];
Message[msgKey,[]];
continue;
endif;
//SRC MOPAC ERROR end
local fileList=fbase ftail flist '.';
//create folder name for writing simulation parameters
local ligandDirName=tok_cat['LIG_target_',totok molCount];
if indexof[ligandDirName,fileList]==0 then
fmkdir ligandDirName;
endif
cd ligandDirName;
local receptorSelection=[];
local a=Atoms[];
local curPos;
for curPos in (tr selAtomPosition) loop
print curPos-aPos Atoms[];
receptorSelection=cat [receptorSelection,a[x_min app add tr abs(curPos-aPos Atoms[])]]; //instead of selecting add it to a set
endloop
local ligandSelection=[];
local receptorCOM=oCenterOfMass receptorSelection; //calculate center of mass of receptor selection
local ligand_atoms = a | rName aResidue a == 'LIG';
ligand_atoms=ligand_atoms | aAtomicNumber ligand_atoms <> 1; //get only heavy atoms
local distances=cat sqrt add pow[tr(tr aPos ligand_atoms - [receptorCOM]),2];
// by default now use closest atom on ligand
ligandSelection=ligand_atoms[x_min distances];
// uncomment this if you want to reintroduce the environment options from the moe window
//if options.environment=='Closest Atom on Ligand' then
// ligandSelection=ligand_atoms[x_min distances];
//else
// ligandSelection=ligand_atoms | distances<=options.smd_cutoff;
//endif
//selectAtomsFromReceptorAndLigandDB[selAtomPosition,isdonor]; //TODO check this
startMD[cat oAtoms ligand,options,suppFFParams,ligandSelection,receptorSelection]; // TODO CONTINUE
cd '../';
molCount=molCount+1;
Close[force:1];
Message[msgKey,[]];
endloop
if fh_MOPAC_created == 1 then
fclose[fh_MOPAC];
endif;
db_Close mdb;
endfunction
local function getSelectedAtomIdsFromPDB[path,atomSelection]
local maxANumber = max aNumber Atoms[];
local newChains = ReadAuto [ path, [center:0,select:0], 'pdb' ];
local newAtoms=cat oAtoms newChains;
local curAtom;
local aIndices;
local distances;
local newAtomSelection;
for curAtom in atomSelection loop
distances=aDist [newAtoms,curAtom];
newAtomSelection=cat[newAtomSelection,newAtoms[x_min cat distances]];
endloop;
newAtomSelection=uniq newAtomSelection;
// local selAtom1=first SelectedAtoms[];
// local selAtom2=second SelectedAtoms[];
//
// local diff1=aDist [selAtom1,newAtoms];
// local diff2=aDist [selAtom2,newAtoms];
//
// local firstIndex=aNumber newAtoms[x_pack(diff1<0.01)];
// local secondIndex=aNumber newAtoms[x_pack(diff2<0.01)];
// print firstIndex;
// print secondIndex;
// print aIndices;
local ligand_selection=newAtomSelection | rName aResidue newAtomSelection == 'LIG';
local receptor_selection=newAtomSelection | rName aResidue newAtomSelection <> 'LIG';
local ligand_com=oCenterOfMass ligand_selection;
local receptor_com = oCenterOfMass receptor_selection;
local comdist=sqrt add pow [ligand_com-receptor_com,2];
local ligand_aNumbers=aNumber ligand_selection;
local receptor_aNumbers=aNumber receptor_selection;
oDestroy newChains;
return([ligand_aNumbers-maxANumber,receptor_aNumbers-maxANumber,comdist]);
endfunction
local function startMD[ligand,options,suppFFParams,ligandSelection,receptorSelection]
print 'Using Prm@frosst forcefield';
pot_Load '$MOE/lib/pfrosst.ff';
local currentDir=cd '.';
print cat ['Creating folders in ',currentDir];
makeMDDirs[];
local allAtoms=Atoms[];
local receptor=[];
local ligandAtomNames=aName ligand;
aSetName [ligand, aMMType ligand]; //overwrite ligand names with MMtype names for mol2 export
receptor=diff[allAtoms,ligand]; //from all atoms filter out the ligand atoms to retain only resting atoms
//treat ligand and receptor
print cat['Selected ',length ligand, ' ligand atoms'];
print cat['Selected ',length receptor, ' receptor atoms'];
writeSystemPdb [receptor,'lib/system.pdb'];
writeLigand[ligand,'lib/'];
if length ligand>0 then
aSetName [ligand, ligandAtomNames]; //rewrite original atom names back to atoms
endif
writeDoLeap[ligand,'lib',options,suppFFParams,length receptor,1];
writeDoLeap[ligand,'lib',options,suppFFParams,length receptor,0];
local msgKey=executeLeap['lib','do.leap'];
//check if successful
if fsize 'lib/system_solv.prmtop'== 0 then
Message[msgKey,[]];
msgKey=Message[0, 'Error, tleap did not manage to build the system'];
print 'Error, tleap did not manage to build the system';
sleep 5;
return [];
endif
Message[msgKey,[]];
//rerun tleap to get proper prmtop atom numberings
msgKey=executeLeap['lib','doleaped.leap'];
local selectedAtomIds=getSelectedAtomIdsFromPDB['lib/system_leaped.pdb',cat [ligandSelection,receptorSelection]];
Message[msgKey,[]];
local lenRec = length uniq aResidue oAtoms receptor;
local lenOtherAtoms = app add [ rType uniq aResidue oAtoms receptor == 'none'];
lenRec=lenRec-lenOtherAtoms;
// local selAtomsPositions=tr aPos SelectedAtoms[];
// local distSelected= aDist[first SelectedAtoms[], second SelectedAtoms[]];
local ret=writeAmberInputs['',options,ligand,lenRec,selectedAtomIds];
//SRC COMMENT AS FOLLOWING LOOP DECIDES WHICH LAUNCHAMBER TO CALL
// if ret==0 then
// launchAmber[options];
// else
// sleep 3;
// Message[ret,''];
// endif
/////
//SRC GTI or Marc queues
if options.queue_IN === 'GTI' then
if ret==0 then
launchAmber_GTI options;
else
sleep 3;
Message[ret,''];
endif
endif
if options.queue_IN === 'Marc' then
if ret==0 then
launchAmber options;
else
sleep 3;
Message[ret,''];
endif
endif
//SRC if local workstation also run
//print options.input_WS;
if options.input_WS == 1 then
local rcode = _fcopy [tok_cat [ SCRIPTSPATH,'/launch_duck_gpu_Workstation.sh'], '../launch_duck_gpu_Workstation.sh'];
launchAmber_Workstation options;
endif
//SRC GTI or Marc queues end
endfunction
local function loadSuppFFParams[]
local fh=fopenr[twrite['{}/register.txt',FFPATH]];
local tmpText;
tmpText=fread[fh,'{G w=`\t` r=`\n`}{t:}{t:}'];
local titles=[];
if tmpText[2]>0 then
titles=cat [tmpText[1][1]];
endif
while tmpText[2]>0 loop
tmpText=fread[fh,'{G w=`\t` r=`\n`}{t:}{t:}'];
if tmpText[2]>0 then
titles=cat [titles,tmpText[1][1]];
endif
endloop
fclose fh;
return titles;
endfunction
global function DuckPanel opt
JPATH = getenv 'MOE_SVL_LOAD';
FFPATH = tok_cat [ JPATH , '/tleap'];
if MOE_BATCH then return[]; endif
if second task_fork[] <> 'child' then return; endif
task_settitle[-1,'DUck Configuration'];
//if WindowShow [WINDOW_NAME,1] then return; endif
// create the main panel
local suppFFParams=loadSuppFFParams[];
const PANEL_TEXT_RUN = [ 'Run' , 'Close'];
const PANEL_TEXT_STOP = [ 'Stop', 'Close'];
const PANEL_INSENSITIVE = [0,1];
const PANEL_SENSITIVE = [1,1];
const RUN_IDX = 1;
const CLOSE_IDX = 2;
local atoms,receptor,ligand;
local wkey = WindowCreate [
title : 'Dynamic Undocking',
windowName : WINDOW_NAME,
// name : 'prompt', //panel
name : 'panel',
text : PANEL_TEXT_RUN,
sensitive : PANEL_SENSITIVE,
Pager : [
name : 'systemdescpage',
flushLeft : 1,
margin : 1,
Label : [ text:
'Dialog allowing to create DUck input files and topologies of\n'
'the system using AmberFF and Merck Parm@Frosst parameters'
]
],
Pager : [
name : 'systemFFparamspage',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Listbox : [
name : 'ffParams',
title: 'Load additional params',
text: cat (untag suppFFParams)[1],
multiSelect: 1,
header: '',
len: 3,
width : 30,
bubbleHelp: 'If you need special parameters, check the corresponding item in the list\n'
'If no such an item is available, add the lib and prp file to \n'
'$(MOE_SVL_LOAD)/FF/tleap'
]
], // Pager
//SRC - box start
Pager : [
name : 'queueSEL',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Vbox: [
extendH: 1,
flushLeft : 1,
Label : [ text:
'Choose between queue input for "GTI" (SLURM) or for "Marc" (SGE).\n',
flushLeft : 1
],
Hbox: [
extendH: 1,
Radio :[
name : 'queue_IN',
title : 'Choose where to run the MD jobs:',
text:['GTI', 'Marc'],
bubbleHelp:'Choose where to run the MD jobs.\n'
]
],
Hbox: [
extendH:1,
Checkbox:[
name : 'input_WS',
title : 'Write input files for local execution',
onTrigger: 'return',
bubbleHelp:'Select in case you also need files for local execution or to adapt them to other queueing systems.'
]
]
]
],
//SRC box end
Pager : [
name : 'systemMDparams',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Vbox: [
extendH: 1,
flushLeft : 1,
Label : [ text:
'Modify MD specific parameters here.\n',
flushLeft : 1
],
Hbox: [
extendH: 1,
name : 'md_params_box',
Text : [
name : 'equilibration_length',
len : 5,
title: 'Equilibration Length (ns) :',
emptyText: '1',
allowBlank: 0,
type:'real',
bubbleHelp:
'The length in ns of the equilibration prior to calculations\n'],
Text : [
name : 'md_length',
len : 5,
title: 'MD chunk length (ns) :',
emptyText: '0.5',
allowBlank: 0,
type:'real',
bubbleHelp:
'The length of MD chunks to run in between SMD simulations (ns)\n']
]
]
],//Pager
Pager : [
name : 'systemSMDparams',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Vbox: [
extendH: 1,
flushLeft : 1,
Label : [ text:
'Modify SMD specific parameters here.\n',
flushLeft : 1
],
Hbox: [
extendH: 1,
name : 'md_params_box',
Text : [
name : 'smd_length',
len : 5,
title: 'SMD length (ns) :',
emptyText: '0.5',
allowBlank: 0,
type:'real',
bubbleHelp:
'The length in ns of the SMD simulation\n'],
Text : [
name : 'smd_displ',
len : 5,
title: 'SMD displacement (A) :',
emptyText: '2.5',
allowBlank: 0,
type:'real',
bubbleHelp:
'The amount of displacement during SMD\n']
],
Hbox: [
extendH: 1,
name : 'md_params_box',
Text : [
name : 'smd_fc',
len : 5,
title: 'Force constant :',
emptyText: '50',
allowBlank: 0,
type:'real',
bubbleHelp:
'The force constant used for SMD\n']
//SRC Text : [
//not name : 'smd_cutoff',
//used len : 5,
// title: 'Cutoff :',
// emptyText: '3',
// allowBlank: 0,
// type:'real',
// bubbleHelp:
// 'The cut off for detecting the ligand closest atoms\n']
]
]//Vbox
],
Pager : [
name : 'wqbThresh',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Vbox: [
extendH: 1,
flushLeft : 1,
Label : [ text:
'Early termination definition.\n',
flushLeft : 1
],
Hbox: [
Text : [
name : 'wqb_thresh',
len : 5,
title: 'Wqb Threshold :',
emptyText: '6',
allowBlank: 0,
type:'real',
bubbleHelp: 'Set the cutoff below which no more SMD will be run if at least one SMD simulations result in Wqb values lower than this threshold.\n'],
Text : [
name : 'wqb_maxruns',
len : 5,
title: 'Maximum DUck SMD runs:',
emptyText: '50',
allowBlank: 0,
type:'real',
bubbleHelp: 'Set the maximum number of DUck SMD runs not including the 2 runs after equilibration. Default is set to 50 (for both 300 and 325K).\n']
]
]
],
Pager : [
name : 'systemDB',
flushLeft : 1,
margin : 1,
extendH : 1,
margin : 1,
shadow : 'etched-in',
Vbox: [
extendH: 1,
flushLeft : 1,
Label : [ text:
'Use this section to configure calculations on a MDB of docked ligands.\n',
flushLeft : 1
],
Hbox: [
extendH: 1,
name : 'db_box',
FSBText : [
name : 'ligand_db',
len : 25,
title: 'Ligand database :',
allowBlank: 0,
mode: 'open',
bubbleHelp:
'The name of the database that contains ligands in ready to study binding poses.\n'
],
Button : [ name: 'browse_ligand_db', text: 'Browse...' ]
]
]
]
];
local dvar_prevset = dvar_open[];
local selAtoms;
local btid;
WindowShow wkey;
WindowSetAttr[wkey, ['systemDB' :[sensitive:1]]];
WindowSetData[wkey, ['smd_fc':50]];
WindowSetData[wkey, ['smd_length':0.5]];
WindowSetData[wkey, ['smd_displ':2.5]];
//SRC WindowSetData[wkey, ['smd_cutoff':5.0]];
WindowSetData[wkey, ['equilibration_length':1]];
WindowSetData[wkey, ['md_length':0.5]];
WindowSetData[wkey, ['wqb_thresh':6.0]];
WindowSetData[wkey, ['wqb_maxruns':50]];
// main panel loop
loop
WindowSetAttr[ wkey, [
panel : [ sensitive: PANEL_SENSITIVE ]
]];
local [vals, trig] = WindowWait wkey;
if trig == 'file' then
WindowSetData[wkey,['file':vals.(trig)]];
elseif trig == 'panel' and (vals.(trig) == PANEL_TEXT_RUN(RUN_IDX)) then
//check if the user selected 1 atom
if length SelectedAtoms[]===1 then
WindowSetAttr[wkey, [[trig,[sensitive:PANEL_INSENSITIVE,
text:PANEL_TEXT_RUN]]]];
//[atoms,receptor,ligand] = MacroGetSelection[ GetSetSelections[wkey], 1, 1, 1];
//local md_options=WindowGetData[wkey,['ffParams','ligand_db','queue_IN','input_WS','smd_length','smd_displ','smd_fc','smd_cutoff','equilibration_length','md_length','wqb_thresh']];
local md_options=WindowGetData[wkey,['ffParams','ligand_db','queue_IN','input_WS','smd_length','smd_displ','smd_fc','equilibration_length','md_length','wqb_thresh','wqb_maxruns']];
print md_options;
print md_options.ligand_db;
startDB[md_options,suppFFParams];
//commented this here as duck is always used for a mdb
//if length(md_options.ligand_db) > 0 then
// startDB[md_options,suppFFParams];
//else
// startMD[ligand,md_options,suppFFParams];
//endif
else
Warning 'You did not select the receptor atom used to define the reaction coordinate of DUck. Please click on the atom you want to investigate';
endif
WindowSetAttr[wkey, ['systemDB' :[sensitive:1]]];
elseif trig == 'browse_ligand_db' then
btid = run ['fbrowse.svl', [trig, wkey, 'Select Ligand Database', 'open', '*.mdb', 'ligand_db']];
// if btid then browsetasks = append [browsetasks, btid]; endif
elseif trig == 'panel' and indexof[ vals.(trig),
[PANEL_TEXT_RUN(CLOSE_IDX),PANEL_TEXT_STOP(CLOSE_IDX)]] then
WindowDestroy wkey;
return;
endif
endloop
endfunction
#eof