-
Notifications
You must be signed in to change notification settings - Fork 0
/
ICM_PDB.pl
154 lines (137 loc) · 4.5 KB
/
ICM_PDB.pl
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
#!/usr/bin/env perl
$fileinfo = "\nICM_PDB.pl created on 01-25-18\n";
# Define I/O && initialize #
$info = "\nICM_PDB.pl opens all files within a given folder into ICM and produces PDB files. It will need the full directory path. \n\t(IE: ./ICM_PDB.pl -d /home/server/OBfiles_Folder/)";
$input = "\nUsage\: ICM_PDB.pl Path/To/.ob/Files\n\t* Path must be from current directory";
# Set default values that can be overwritten #
$directory = $ENV{'PWD'};
$icm_home = "/home/server/icm-3.7-2b/";
$icmInhibit = "BcheTemplate.icb";
# Get flags #
if((@ARGV))
{
$flag = $ARGV[0];
chomp $flag;
if($flag eq "-h")
{
$help = 1;
}
else
{
$directory=$flag;
}
}
else
{
print "$input\n"; exit();
}
if($help==1)
{
print "$fileinfo";
print "$info";
print "$input\n"; exit();
}
# Validing user's directory #
if (-e $ENV{'PWD'}."/".$directory)
{
$directory = $ENV{'PWD'}."/".$directory;
chomp $directory;
if((substr $directory, -1) ne "/")
{
$directory = $directory."/";
}
}
else
{
print "\nThe directory:$ENV{'PWD'}"."/"."$directory does not exist!!!\n\n";
exit;
}
#chdir $icm_home;
# Checking if Server's project file exist
if(-e $icm_home.$icmInhibit)
{
# This section is used to set up the working directory for loadICM.icm to be made #
chdir $directory;
system("cp $icm_home"."$icmInhibit $directory"."BChEInhibit.icb");
$icmInhibit = "BChEInhibit.icb";
if (-e $icmInhibit)
{
print "success";
$icm_home = "~/icm-3.7-2b/";
}
else
{
exit;
}
}
else
{
print "\nThe file: $icmInhibit does not exist in $icm_home!!! Please contact your system Admin.\n\n";
exit;
}
# Reading the files in the directory and putting the files name into array DIR #
opendir(DIR,$directory);
my @obFiles;
$obFilesCount = 0;
while ( my $file = readdir(DIR) )
{
# Ignoring all the non files in the directory, IE: "." & ".."
next unless ( -f "$directory/$file" );
# Finding files with .ob extension
next unless ( $file =~ /\.ob$/ );
$obFiles[$obFilesCount] = $file;
$obFilesCount++;
}
closedir(DIR);
########################################### Create ICM script ###########################################
open(ICM,'>',"pdbICM.icm") || die "Please give me output filename $!"; #adjust the ICMscript
# This print portion is used to Hack ICM into loading its Library -Aingty Eung :) #
print ICM "l_commands = no \n";
print ICM "l_info=no \n";
print ICM "if((Version()~\"*WIN*\" & Version() !~ \"*WINCONSOLE*\" ) | Version()~\"*MacOSX-IL*\") set directory s_projectsDir \n";
print ICM "read table s_icmhome + \"WEBLINK.tab\" system \n";
print ICM "set property WEBLINK show delete edit off \n";
print ICM "set property WEBAUTOLINK show delete edit off \n";
print ICM "set property DATABASE show delete edit off \n";
print ICM "print \"Startup> Loading libraries..\" \n";
print ICM "read libraries \n";
print ICM "read libraries mute \n";
print ICM "l_info=yes \n";
print ICM "call _aliases \n";
print ICM "call _macro \n";
print ICM "loadResources \n";
print ICM "call _bioinfo test \n";
print ICM "call _rebel test \n";
print ICM "call _ligedit test \n";
print ICM "call _docking test \n";
print ICM "l_info=yes \n";
print ICM "if (l_info) printf \"\\n\" \n";
print ICM "if (Index(Version(),\"NoGraphics\")==0 & !Exist(gui)) then \n";
print ICM " print \" Hint> Run program with -g switch to start graphical user interface\" \n";
print ICM "endif \n";
print ICM "movie_init \n";
print ICM "print \"...ICM startup file executed...\" \n";
print ICM "l_info=yes \n";
print ICM "l_commands=yes \n";
# End of Hacked Print section #
$obFilesCount = 0;
print ICM "openFile '$directory$icmInhibit' 0 yes no no no ' append'\n";
for($i=0; $i<=$#obFiles; $i++)
{
chomp $obFiles[$i];
# $tempFile is now the file name without the extension, IE: dock2.ob ---> dock2
$tempFile = substr $obFiles[$i], 0, length($obFiles[$i])-3;
$obFilesCount++;
print ICM "openFile '$directory$obFiles[$i]' 0 yes no no no ' append'\n";
print ICM "move a_ a_1P0I_HumanBChE_ICM.\n";
print ICM "write pdb a_1P0I_HumanBChE_ICM. '$directory$tempFile.ent'\n";
print ICM "delete a_1P0I_HumanBChE_ICM.m\n";
}
print ICM "quit\n";
close(ICM)||die $!;
########################################### End of ICM script ###########################################
# Running the command to load in files
system("$icm_home"."icm64 -g pdbICM.icm");
system("rm pdbICM.icm && rename 's/\.ent/\.pdb/' *.ent && rm -f "."$icmInhibit");
# End running the command
#########################################################################################################