Few months ago, I posted a blog article that I try to use MOLMOL + shell script to get the distance table I want. However, I always forgot how to use the syntax of MOLMOL, therefore, I wrote a shell script to carry out this purpose.
The shell script can calculate any distances between an assigned proton (e.g HB) and other protons, then gives you an output. The output is sorting by the distances or the residue numbers.
The current script DOES NOT deal with the multiple-chain PDB.
Here are the outputs (using 2GB1.pdb as an example):
1. sorting by distance:
~:>./cal-HH-distance.sh 2GB1.pdb 34 HA 3.6 yes
Res_atom <—> Res AA ATOM DIST
=================================
34-ALA-HA <—> 34 ALA 3HB 2.25
34-ALA-HA <—> 33 TYR HD1 2.48
34-ALA-HA <—> 34 ALA H 2.78
34-ALA-HA <—> 37 ASN 1HB 2.79
34-ALA-HA <—> 34 ALA 2HB 2.80
34-ALA-HA <—> 34 ALA 1HB 2.91
34-ALA-HA <—> 37 ASN 2HD2 2.95
34-ALA-HA <—> 7 LEU 2HD2 3.21
34-ALA-HA <—> 7 LEU 3HD2 3.30
34-ALA-HA <—> 39 VAL HB 3.31
34-ALA-HA <—> 35 ASN H 3.53
2. sorting by residues:
~:>./cal-HH-distance.sh 2GB1.pdb 34 HA 3.6 no
Res_atom <—> Res AA ATOM DIST
=================================
34-ALA-HA <—> 7 LEU 2HD2 3.21
34-ALA-HA <—> 7 LEU 3HD2 3.30
34-ALA-HA <—> 33 TYR HD1 2.48
34-ALA-HA <—> 34 ALA H 2.78
34-ALA-HA <—> 34 ALA 1HB 2.91
34-ALA-HA <—> 34 ALA 2HB 2.80
34-ALA-HA <—> 34 ALA 3HB 2.25
34-ALA-HA <—> 35 ASN H 3.53
34-ALA-HA <—> 37 ASN 1HB 2.79
34-ALA-HA <—> 37 ASN 2HD2 2.95
34-ALA-HA <—> 39 VAL HB 3.31
Here is the shell script. If this script is helpful to you, please give me a response. Thanks.
Any comments are also welcome.
#!/bin/sh
## A program to calculate the distance of an assigned atom
## and other intramolecular atoms
## see USAGE to know how to run it
## USAGE : ./this_script [PDB] [residue_number] [proton_name] [cutoff] [yes|no]
## e.g. ./cal-HH-distance.sh 2GB1.pdb 53 H 6 no
## this will calculate all distances for resdiesu_53_NH
## and other atoms of 2GB1.pdb
## distances within 6 Ang will be output and sort by the distance
##
## VERSON 0.3 Aug. 7th, 2007
## Kuen-Phon Wu
## See update: https://kpwu.wordpress.com/
usage=”Usage: cal-HH-distance.sh [inputfile] [res_number] [proton] [cutoff] [yes|no]”
eg=”Example: ./cal-HH-distance.sh 2GB1.pdb 53 HA 6.0 yes”
if [ $# -lt 5 ] ; then
echo “$usage”
echo “$eg”
exit 1
fi
FILE=”$1″
RES=”$2″
ATOM=”$3″
cutoff=$4
## find x, y, z coordinate of the assigned atom
x=`cat $1 |grep ” $2 ” |grep “$3 ” |awk ‘/^ATOM/{print $7}’`
y=`cat $1 |grep ” $2 ” |grep “$3 ” |awk ‘/^ATOM/{print $8}’`
z=`cat $1 |grep ” $2 ” |grep “$3 ” |awk ‘/^ATOM/{print $9}’`
Res_type=`cat $1 |grep ” $2 ” |grep “$3 ” |awk ‘/^ATOM/{print $4}’`
## caluclate all distances related to the assigned atom
## filter out non H,HB,HD,HG atoms by grep
cat $1 |grep -v ” O.” | grep -v “C[ .A-Z]” |grep -v ” N ” | \
awk ‘/^ATOM/{printf “%5s%6s%6s%8.2f\n”, \
$6,$4,$3,sqrt((x1-$7)^2+(y1-$8)^2+(z1-$9)^2)}’\
x1=$x y1=$y z1=$z >_temp1
## post-editing do sorting or not sorting, control by case
##
echo “Res_atom <—> Res AA ATOM DIST”
echo “=============================================”
case “$5” in
yes)
cat _temp1 |sort -k 4 |awk ‘$4 < cut {printf “%s-%s-%s <—> %s\n”,res,aa,atom,$0;}’ \
aa=$Res_type cut=$cutoff res=$RES atom=$ATOM |grep -v 0.00
;;
no)
cat _temp1 |awk ‘$4 < cut {printf “%s-%s-%s <—> %s\n”,res,aa,atom,$0;}’ \
aa=$Res_type cut=$cutoff res=$RES atom=$ATOM |grep -v 0.00
;;
*) echo “$usage”
exit 0
;;
esac
rm -f _temp*