-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmd_box_dims.sh
executable file
·53 lines (48 loc) · 1.56 KB
/
vmd_box_dims.sh
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
#!/bin/bash
###############################################################################
# NAME
# vmd_box_dims.sh
# AUTHOR
# Benjamin D. Madej
# SYNOPSIS
#
# DESCRIPTION
# Measures the distance between the maximum and minimum coordinates of the
# PDB structure in the X, Y, and Z dimensions
# OPTIONS
# -i
# input_structure.pdb
# PDB format molecular structure to be read by VMD
# -s
# vmd_selection
# Text used for selecting atoms in VMD to measure box dimensions
###############################################################################
while getopts ":i:s:" opt; do
case $opt in
i)
input_structure=$OPTARG
;;
s)
vmd_selection=$OPTARG
;;
esac
done
cat << EOF > water_box_dims.tcl
mol new $input_structure
set sel [ atomselect top "$vmd_selection" ]
set dims [ measure minmax \$sel ]
puts "Dimensions: \$dims"
quit
EOF
/usr/local/bin/vmd -dispdev text -nt -e water_box_dims.tcl > water_box_dims.txt
x_min=`grep Dimensions water_box_dims.txt | awk '{print $2}' | sed 's/{//'`
y_min=`grep Dimensions water_box_dims.txt | awk '{print $3}'`
z_min=`grep Dimensions water_box_dims.txt | awk '{print $4}' | sed 's/}//'`
x_max=`grep Dimensions water_box_dims.txt | awk '{print $5}' | sed 's/{//'`
y_max=`grep Dimensions water_box_dims.txt | awk '{print $6}'`
z_max=`grep Dimensions water_box_dims.txt | awk '{print $7}' | sed 's/}//'`
x_diff=`echo "$x_max - $x_min" | bc`
y_diff=`echo "$y_max - $y_min" | bc`
z_diff=`echo "$z_max - $z_min" | bc`
echo $x_diff, $y_diff, $z_diff
rm water_box_dims.tcl water_box_dims.txt