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";

In reply to Distance between points in a PDB file by kanika

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.