kanika has asked for the wisdom of the Perl Monks concerning the following question:
have a PDB file. Now it has two parts separated by TER. Before TER I call it part 1. I want to take x,y,z of ATOM 1 of first part i.e before TER and find distance to all x,y,z co ordinates after TER and then second ATOM of part one to all ATOMS of part second. This has to be repeated for all ATOMS of first part= to all ATOMS of second part. I have to automate it for 20 files. names of my files begin like 1_0.pdb,2_0.pdb....20_0.pdb. This is a distance calculation. I have tried something in PERL but its very rough. Can someone help a bit. The File looks like:
----long file (I truncated it)----ATOM 1279 C ALA 81 -1.925 -11.270 1.404 ATOM 1280 O ALA 81 -0.279 9.355 15.557 ATOM 1281 OXT ALA 81 -2.188 10.341 15.346 TER ATOM 1282 N THR 82 29.632 5.205 5.525 ATOM 1283 H1 THR 82 30.175 4.389 5.768 ATOM 1284 H2 THR 82 28.816 4.910 5.008 <code> The code is: In the end it finds the maximum distance and its co ordin +ates <code> my @points = (); open(IN, @ARGV[0]) or die "$!"; while (my $line = <IN>) { chomp($line); my @array = (split (/\s+/, $line))[5, 6, 7]; print "@array\n"; push @points, [ @array ]; } close(IN); $max=0; for my $i1 ( 0 .. $#points ) { my ( $x1, $y1, $z1 ) = @{ $points[$i1] }; my $dist = sqrt( ($x1+1.925)**2 + ($y1+11.270)**2 + ($z1-1.404)**2 + ); print "distance from (-1.925 -11.270 1.404) to ( $x1, $y1, $z1 ) i +s $dist\n"; if ( $dist > $max ) { $max = $dist; $x=$x1; $y=$y1; $z=$z1; }} print "maximum value is : $max\n"; print "co ordinates are : $x $y $z\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Distance between points in a PDB file
by choroba (Cardinal) on Mar 06, 2012 at 12:11 UTC | |
by JavaFan (Canon) on Mar 06, 2012 at 12:24 UTC | |
|
Re: Distance between points in a PDB file
by jethro (Monsignor) on Mar 06, 2012 at 12:58 UTC | |
|
Re: Distance between points in a PDB file
by erix (Prior) on Mar 06, 2012 at 19:57 UTC |