annotate tools/rdock/bin/run_rbdock.pl @ 1:30e2440b2173 draft

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