-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateDatasetRunScript4multimericComplexes.pl
More file actions
executable file
·190 lines (156 loc) · 5.69 KB
/
createDatasetRunScript4multimericComplexes.pl
File metadata and controls
executable file
·190 lines (156 loc) · 5.69 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
#!/usr/bin/perl -w
# Author: Abdullah Kahraman
# Date: 10.12.2009
###############################################################################
###############################################################################
### Creates a dataset_run.sh script for a PDB file with enumarating all ###
### combinatorics of the chains. ###
###############################################################################
###############################################################################
use strict;
use Getopt::Long;
use lib "/cluster/home/biol/akahrama/libs/Math-Combinatorics-0.09/lib";
use Math::Combinatorics;
my (
# variable for parameters which are read in from commandline
$help,
$in,
$dockingFlag,
$combineFlag,
$clusterFlag,
);
##############################################################################
### read all needed parameters from commandline ##############################
&GetOptions(
"help!" => \$help, # print this help
"in=s" => \$in, # infile
"dock=s" => \$dockingFlag, # path to docking_flags
"combine=s" => \$combineFlag, # path to combineSilent_flags
"cluster=s" => \$clusterFlag, # path to cluster_flags
) or die "\nTry \"$0 -h\" for a complete list of options\n\n";
##############################################################################
# help
if ($help) {printHelp(); exit}
##############################################################################
### SETTINGS #################################################################
##############################################################################
# Get Author Information
my $author;
my $sg= "finger " . `whoami`;
my @authorName = `$sg`;
@authorName = grep /life/, @authorName;
foreach (@authorName){
if (/life:\s+(\S+\s+\S+)/){
$author = $1;
last;
}
}
my $dbsubmitter = $author;
# Get Date
my @submitDate = split(" ", `date`);
my $dbsubmitDate = $submitDate[2] . "-" . $submitDate[1] . "-" .
$submitDate[5];
##############################################################################
### SUBROUTINES ##############################################################
##############################################################################
##############################################################################
sub printHelp {
##############################################################################
# prints a help about the using and parameters of this scripts
# (execute if user types commandline parameter -h)
# param: no paramaters
# return: no return value
my (
$usage,
$sourceCode,
@rows,
$row,
$option,
$scriptInfo,
$example,
);
$usage = "$0 -in=<path> -field=[string] -stop=[integer] " .
"-output [stdout|database] -help -list -verbose\n";
print "\nUsage: " . $usage . "\n";
print "Valid options are:\n\n";
open(MYSELF, "$0") or
die "Cannot read source code file $0: $!\n";
$sourceCode .= join "", <MYSELF>;
close MYSELF;
$sourceCode =~ s/^.+?\&GetOptions\(\n//s;
$sourceCode =~ s/\n\).+$//s;
@rows = split /\n/, $sourceCode;
foreach $row (@rows){
$option = $row;
$option =~ s/\s+\"//g;
$option =~ s/\"\s.+\#/\t\#/g;
$option =~ s/=./\t<value> [required]/;
$option =~ s/:./\t<value> [optional]/;
$option =~ s/!/\t<non value> [optional]/;
$row =~ s/^.*//;
print "\t";
printf("%-1s%-30s%-30s%-20s\n", "-",$option,$row);
} # end of foreach $row (@rows)
print "\n";
print "Options may be abreviated, e.g. -h for --help\n\n";
$example = "$0 -in=../../databases/locuslink/locuslink_031007.txt ";
}
##############################################################################
### END OF SUBROUTINES########################################################
##############################################################################
############
### MAIN ###
############
###################
die "\nTry \"$0 -h\" for a complete list of options\n\n" if(!defined $in);
die "\nFile \"$in\" NOT found\n\n" if (!-f $in);
my $dir = $in;
$dir=~s/.pdb$//;
open(F, $in) or die "Can't open file $in\n";
my %pdb;
while(my $l=<F>){
$pdb{substr($l, 21, 1)}.=$l if($l=~/^ATOM/)
}
my $noChains = keys(%pdb);
my @chainIds;
my $chainIds="";
foreach my $c(sort keys %pdb){push(@chainIds,$c);$chainIds.=$c;};
#combinatorics: n!/r!(n-r)!
my %h;
for(my $i=1; $i<=$noChains; $i++){
my @comb = combine($i,@chainIds);
for(my $r=0; $r<=$#comb; $r++){
my @elem = @{$comb[$r]};
my $chainIdsNotListed = $chainIds;
my $chainIdsListed = "";
for(my $j=0; $j<=$#elem; $j++){
$chainIdsListed .= $elem[$j];
$chainIdsNotListed =~ s/$elem[$j]//;
}
for(my $k=0; $k<length($chainIdsNotListed); $k++){
my $forward = $chainIdsListed."-".substr($chainIdsNotListed,$k,1);
my $reverse = substr($chainIdsNotListed,$k,1)."-".$chainIdsListed;
if(!exists $h{$forward} && !exists $h{$reverse}){
$h{$forward}="";
}
}
}
}
foreach my $h(sort {length($a)<=>length($b)} keys %h){
mkdir($dir.$h);
(my $p1, my $p2) = split(/-/,$h);
open(O,">".$dir.$h.".pdb") or die "Can't create file $dir$h.pdb\n";
for(my $i=0; $i<length($p1); $i++){
print O $pdb{substr($p1,$i,1)}
}
print O "TER\n".$pdb{$p2};
print "while [ \$(bjobs 2>&1 | wc -l) -gt 500 ];do echo \"Waiting 300 for jobs to finished\";sleep 300;done\n";
print "cd $dir$h\n";
print "/cluster/home/biol/akahrama/src/scripts/run_dockingSim.sh ../".$dir.$h.".pdb ../".$dir.$h.".pdb 40 250 1 ../$dockingFlag ../$combineFlag ../$clusterFlag 0 &\n";
print "sleep 300\n";
print "cd ..\n";
}
################
### end of main
### end of script
#