#!/usr/bin/perl ($#ARGV >= 0) || die "usage: ./cmap.pl \n"; while(<>){ chomp; @_ = split; $tag = $_[0]; $atom = $_[2]; $pos = $_[4]; $x = $_[5]; $y = $_[6]; $z = $_[7]; if ($tag =~ /ATOM/ && $atom =~ /CA/){ my @T = ($x, $y, $z); $X[$pos] = \@T; $lastpos = $pos; print "$pos: @{$X[$pos]}\n"; } } for ($i=1; $i <= $lastpos; ++$i){ for ($j = 1; $j < $i; ++$j){ print " "; } for ($j=$i; $j <= $lastpos; ++$j){ $dx = ${$X[$i]}[0] - ${$X[$j]}[0]; $dy = ${$X[$i]}[1] - ${$X[$j]}[1]; $dz = ${$X[$i]}[2] - ${$X[$j]}[2]; $dist = sqrt ($dx*$dx + $dy*$dy + $dz*$dz); if ($dist <= 7){ print "1"; } else{ print "0"; } } print "\n"; }