-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetPNGofXYZ
executable file
·293 lines (269 loc) · 8.4 KB
/
getPNGofXYZ
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
#!/bin/bash
# If VMD was a personalizate installation, please find the library of tachyon_LINUXAMD64 or equivalent
# and put the path and command for using VMD in the next two lines
# Authorship, support, and maintenance of this script is attributed to
# Luis Alfredo Nunez Meneses
path_of_tachyon="/usr/local/lib/vmd/tachyon_LINUXAMD64"
vmd_line_command="vmd"
#####################################################################
#-------------------------------------------------------------- Fdx
#####################################################################
#-------------------------------------------------------------- Fdx
#####################################################################
the_prog_name=$(echo "$0" | sed -e 's;\(.*\)/\(.*\);\2;')
cmdl_argv=($@)
cmdl_argc=${#cmdl_argv[@]}
help_and_syntax()
{
the_prog_name=$1
echo -e "\n Script syntax: \033[1m$the_prog_name\033[0m [\033[0;4moption(s)\033[0m \
[\033[4margument(s)\033[0m]] [\033[4minputname.xyz\033[0m]"
#Here you may put a description of the script. The text between 'END_USAGE_TEXT'
#will be displayed as it is.
cat << END_USAGE_TEXT
This script will create a images in png format from file with format XYZ using VMD program
Tip:
If you want a different view of your molecule, please open the file "name_file.vmd" with VMD like this
vmd -e name_file.vmd
Save the visualization how you like to look your molecule in the same file and run this script again.
Description of options. For instance:
-h Display the help menu.
-b color Color of background. "black" or "white". Default white
-x #### Size wight image. Default 800.
-y #### Size height image. Default 680.
END_USAGE_TEXT
}
#####################################################################
prove_if_exist_tachyon_lib(){
path=$1
if [[ -f $path ]]
then
echo $path
else
echo -e " Error: Missing the tachyon_LINUXAMD64 \n Search where is the lib of vmd"
exit 2
fi
}
#####################################################################
print_vmd_script(){
file_name=$1
backgroud_color=$2
cat << END_VMD_SCRIPT
#!/usr/local/bin/vmd
#VMD script written by save_state \$Revision: 1.47 $
#VMD version: 1.9.3
set viewplist {}
set fixedlist {}
# Display settings
display projection Orthographic
display height 4.000000
display distance -2.000000
display nearclip set 0.000000
display depthcue off
display shadows off
display ambientocclusion off
display aoambient 0.800000
display aodirect 0.300000
display dof off
display dof_fnumber 64.000000
display dof_focaldist 0.700000
mol new $file_name type xyz first 0 last -1 step 1 filebonds 1 autobonds 1 waitfor all
mol delrep 0 top
mol representation CPK 1.000000 0.400000 150.000000 150.000000
mol color Element
mol selection {all}
mol material Opaque
mol addrep top
mol scaleminmax top 0 0.000000 0.000000
mol smoothrep top 0 0
mol drawframes top 0 {now}
mol rename $file_name
# done with molecule 0
proc vmdrestoremycolors {} {
set colorcmds {
{color Display {Background} $backgroud_color}
{color Display {BackgroundTop} black}
{color Display {BackgroundBot} blue2}
{color Display {FPS} black}
{color Element {X} cyan}
{color Element {Ac} ochre}
{color Element {Ag} ochre}
{color Element {Al} ochre}
{color Element {Am} ochre}
{color Element {Ar} ochre}
{color Element {As} ochre}
{color Element {At} ochre}
{color Element {Au} ochre}
{color Element {B} ochre}
{color Element {Ba} ochre}
{color Element {Be} ochre}
{color Element {Bh} ochre}
{color Element {Bi} ochre}
{color Element {Bk} ochre}
{color Element {Br} ochre}
{color Element {Ca} ochre}
{color Element {Cd} ochre}
{color Element {Ce} ochre}
{color Element {Cf} ochre}
{color Element {Cl} green}
{color Element {Cm} ochre}
{color Element {Co} ochre}
{color Element {Cr} ochre}
{color Element {Cs} ochre}
{color Element {Cu} ochre}
{color Element {Db} ochre}
{color Element {Ds} ochre}
{color Element {Dy} ochre}
{color Element {Er} ochre}
{color Element {Es} ochre}
{color Element {Eu} ochre}
{color Element {F} ochre}
{color Element {Fe} ochre}
{color Element {Fm} ochre}
{color Element {Fr} ochre}
{color Element {Ga} ochre}
{color Element {Gd} ochre}
{color Element {Ge} ochre}
{color Element {He} ochre}
{color Element {Hf} ochre}
{color Element {Hg} ochre}
{color Element {Ho} ochre}
{color Element {Hs} ochre}
{color Element {I} ochre}
{color Element {In} ochre}
{color Element {Ir} ochre}
{color Element {K} ochre}
{color Element {Kr} ochre}
{color Element {La} ochre}
{color Element {Li} ochre}
{color Element {Lr} ochre}
{color Element {Lu} ochre}
{color Element {Md} ochre}
{color Element {Mg} ochre}
{color Element {Mn} ochre}
{color Element {Mo} ochre}
{color Element {Mt} ochre}
{color Element {Na} ochre}
{color Element {Nb} ochre}
{color Element {Nd} ochre}
{color Element {Ne} ochre}
{color Element {Ni} ochre}
{color Element {No} ochre}
{color Element {Np} ochre}
{color Element {Os} ochre}
{color Element {Pa} ochre}
{color Element {Pb} ochre}
{color Element {Pd} ochre}
{color Element {Pm} ochre}
{color Element {Po} ochre}
{color Element {Pr} ochre}
{color Element {Pt} ochre}
{color Element {Pu} ochre}
{color Element {Ra} ochre}
{color Element {Rb} ochre}
{color Element {Re} ochre}
{color Element {Rf} ochre}
{color Element {Rg} ochre}
{color Element {Rh} ochre}
{color Element {Rn} ochre}
{color Element {Ru} ochre}
{color Element {Sb} ochre}
{color Element {Sc} ochre}
{color Element {Se} ochre}
{color Element {Sg} ochre}
{color Element {Si} ochre}
{color Element {Sm} ochre}
{color Element {Sn} ochre}
{color Element {Sr} ochre}
{color Element {Ta} ochre}
{color Element {Tb} ochre}
{color Element {Tc} ochre}
{color Element {Te} ochre}
{color Element {Th} ochre}
{color Element {Ti} ochre}
{color Element {Tl} ochre}
{color Element {Tm} ochre}
{color Element {U} ochre}
{color Element {V} ochre}
{color Element {W} ochre}
{color Element {Xe} ochre}
{color Element {Y} ochre}
{color Element {Yb} ochre}
{color Element {Zr} ochre}
}
foreach colcmd \$colorcmds {
set val [catch {eval \$colcmd}]
}
}
vmdrestoremycolors
END_VMD_SCRIPT
}
#####################################################################
generate_png_from_vmd(){
file_name=$1
res_x=$2
res_y=$3
backgroud_color=$4
base_file_name=${file_name%.*}
file_name_vmd_view="$base_file_name.vmd"
file_name_for_render="$base_file_name.render"
file_name_png="$base_file_name.png"
file_name_tga="$base_file_name.tga"
if [[ -f $file_name_vmd_view ]]
then
echo " The file $file_name_vmd_view for viewing in VMD already exist"
else
print_vmd_script $file_name $backgroud_color > $file_name_vmd_view
fi
tachyon=$(prove_if_exist_tachyon_lib $path_of_tachyon)
vmd_commands="axes location off \n render Tachyon $file_name_for_render"
echo -e $vmd_commands | $vmd_line_command -e $file_name_vmd_view -size $res_x $res_y -dispdev text -eofexit
$tachyon -V -aasamples 12 -trans_max_surfaces 1 -rescale_lights 2.0 -add_skylight 0.0 $file_name_for_render -o $file_name_tga
convert $file_name_tga $file_name_png
rm $file_name_for_render
rm $file_name_tga
}
#####################################################################
# Corpus of the Script
#####################################################################
file_name_xyz="${@: -1}"
size_in_x=800
size_in_y=800
backgroud_color="white"
#Checks the consistency of the argument list
if [ $# -lt 1 ]; then
echo "Error: input filename missing (Try -h for more information.)."
exit 2
fi
while getopts ":hb:x:y:" opt; do
case $opt in
b)
backgroud_color="$OPTARG"
;;
x)
size_in_x=$OPTARG
;;
y)
size_in_y=$OPTARG
;;
h)
help_and_syntax $prog_name
exit 0
;;
\?)
echo "Invalid option: -$OPTARG" >&2
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
if [ ! -f $file_name_xyz ]; then
echo "Error: input filename missing (Try -h for more information.)."
exit 2
fi
echo " Create image in png of $file_name_xyz"
generate_png_from_vmd $file_name_xyz $size_in_x $size_in_y $backgroud_color
echo