#!/usr/bin/perl -W #subroutines for calculations use strict; sub distanceAB($$$$$$) { my ($x1,$y1,$z1,$x2,$y2,$z2) = @_; $distance = sqrt (($x2-$x1)**2 + ($y2 -$y1)**2 + ($z2-$z1)**2); return sprintf("%4.2f", $distance); } #open files for calculations and modify distance cutoff for target residues $input=$ARGV[0]; open(IN, "$input"); $num = 0; $count = 0; my $xyz_fmt = '@30a8 @38a8 @46a8'; while ($pdbline = ) { if ($pdbline =~ m/ZN1 LG1 X/) { @ZN = unpack $xyz_fmt, $pdbline; next; } #find xyz coordinates for other atoms and store in array if ($pdbline =~ /^ATOM.*(OD2 ASP|NE2 HIS)/) { push $Atoms[$num], [unpack $xyz_fmt, $pdbline]; $resname[$num] = substr($pdbline, 16, 3); $resnumber[$num] = substr($pdbline, 22, 3); ++$num; } } #count number of potential coordinating atoms if ($pdbline =~ /OD2 ASP/ or $pdbline =~ /NE2 HIS/) { ++$count; } #calculate Zn to each atom distance foreach $i (0..$count) { $Zndistance=distanceAB($x1[$ZN[0]],$y1[$ZN[1]],$z1[$ZN[2]],$x2[$Atoms[$i][0]],$y2[$Atoms[$i][1]],$z2[$Atoms[$i][2]]); if ($Zndistance < 2.5) { $distanceAB=$Zndistance; print "$distanceAB \n"; print "$resname[$i] $resnumber[$i] \n"; } }