annotate galaxy-tools/tools/rdock/bin/run_rbdock.pl @ 0:4eb3f9cb2a51 draft

Uploaded
author dzesikah
date Fri, 26 Aug 2016 09:53:37 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
1 #!/usr/bin/perl
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
2 use lib "$ENV{'RBT_ROOT'}/lib";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
3 require "run_rbfuncs.pl";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
4
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
5 my $rbtroot = $ENV{'RBT_ROOT'};
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
6 my $rbthome = $ENV{'RBT_HOME'};
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
7 my $recepDir = "$rbtroot/data/receptors";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
8 my $scriptDir = "$rbtroot/data/scripts";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
9 my $libraryDir = "$rbtroot/data/libraries";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
10 my $binDir = "$rbtroot/bin";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
11
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
12 #override default directories
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
13 #Parse command line arguments
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
14 my $nArgs = scalar(@ARGV);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
15
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
16 while (scalar(@ARGV)) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
17 my $arg = shift @ARGV;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
18 if (index($arg,'-r')==0) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
19 $recepDir = substr($arg,2);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
20 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
21 elsif (index($arg,'-s')==0) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
22 $scriptDir = substr($arg,2);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
23 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
24 elsif (index($arg,'-l')==0) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
25 $libraryDir = substr($arg,2);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
26 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
27 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
28
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
29
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
30 # Get the receptor, library and script tables
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
31 my %receptor_table = get_prm_table($recepDir);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
32 my %script_table = get_prm_table($scriptDir);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
33 my %library_table = get_prm_table($libraryDir);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
34
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
35 #GET ALL THE INPUTS
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
36 my $defFiles = "*.{sd,sdf,mol,mdl}";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
37 print join("\n",glob $defFiles);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
38 my $libFiles = get_input("\n\nEnter expression for SD files to dock",$defFiles);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
39 my $receptor = get_selection(\%receptor_table,"receptor");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
40 my $script = get_selection(\%script_table,"docking script");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
41 my $flags = get_input("Enter optional rbdock flags","-ap -an");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
42 my $runs = get_input("Enter number of runs/ligand",20);
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
43
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
44 my $runRoot = get_input("Enter run name","rbdock");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
45 my $queueSys = get_input("Enter queuing system (NQS,CODINE,CONDOR,NONE)","CONDOR");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
46 my $queueName;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
47 $queueName = get_input("Enter NQS queue","QRBD") if ($queueSys eq "NQS");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
48
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
49 $pwd = `pwd`;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
50 chomp $pwd;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
51
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
52 #WRITE THE NQS SCRIPTS
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
53
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
54 #GET THE LIST OF SD FILES TO DOCK
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
55 my @libList = glob "${libFiles}";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
56
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
57 my $subFile = "submit_$runRoot.csh";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
58 open SUBHANDLE,">$subFile";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
59 print SUBHANDLE "#!/bin/csh -ef\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
60
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
61 my $iFile=0;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
62 foreach $libFile (@libList) {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
63 $iFile++;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
64 #Write the NQS script file
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
65 $runName = "${runRoot}_$iFile";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
66 $nqsFile = "run_${runName}.csh";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
67 my $logFile = "${runName}.log";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
68
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
69 print "Writing $nqsFile...\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
70
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
71 open NQSHANDLE,">$nqsFile";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
72 print NQSHANDLE "#!/bin/csh -ef\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
73 print NQSHANDLE "setenv RBT_ROOT $rbtroot\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
74 print NQSHANDLE "setenv RBT_HOME $rbthome\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
75 print NQSHANDLE "source \$RBT_ROOT/bin/setlibrbt.com\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
76 print NQSHANDLE "cd $pwd\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
77 print NQSHANDLE "if (-e $logFile) rm -f $logFile\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
78 print NQSHANDLE "\$RBT_ROOT/bin/rbdock -i$libFile -o${runName} -r$receptor -p$script -n$runs $flags > $logFile\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
79 close NQSHANDLE;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
80
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
81 chmod 0755,$nqsFile;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
82 print SUBHANDLE "qsub -q $queueName $nqsFile\n" if ($queueSys eq "NQS");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
83 print SUBHANDLE "qsub -e $pwd/$runRoot/tmp/ -o $pwd/$runRoot/tmp/ $nqsFile\n" if ($queueSys eq "CODINE");
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
84 if ($queueSys eq "CONDOR") {
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
85 my $condorFile = "run_${runName}.cmd";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
86 open CMDHANDLE,">$condorFile";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
87 print CMDHANDLE "#CONDOR FILE WRITTEN BY run_rbscreen.pl\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
88 print CMDHANDLE "universe = vanilla\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
89 print CMDHANDLE "executable = ${nqsFile}\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
90 print CMDHANDLE "Requirements = CATALYST_NODE =!= True\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
91 print CMDHANDLE "output = ${nqsFile}.out\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
92 print CMDHANDLE "error = ${nqsFile}.err\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
93 print CMDHANDLE "log = ${nqsFile}.log\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
94 print CMDHANDLE "queue\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
95 close NQSHANDLE;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
96 print SUBHANDLE "condor_submit $condorFile\n";
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
97 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
98 }
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
99 close SUBHANDLE;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
100 chmod 0755,$subFile;
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
101
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
102
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
103
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
104
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
105
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
106
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
107
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
108
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
109
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
110
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
111
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
112
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
113
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
114
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
115
4eb3f9cb2a51 Uploaded
dzesikah
parents:
diff changeset
116