Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7605523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:11:21+00:00 2026-05-31T00:11:21+00:00

I have a PDB file. Now it has two parts separated by TER. Before

  • 0

I 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

The code is: In the end it finds the maximum distance and its co ordinates

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 ) is $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";        
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:11:23+00:00Added an answer on May 31, 2026 at 12:11 am

    Not sure I clearly understand what you want, but how about:

    #!/usr/local/bin/perl 
    use strict;
    use warnings;
    
    my (@refer, @points);
    my $part = 0;
    while (my $line = <DATA>) { 
        chomp($line);
        if ($line =~ /^TER/) {
            $part++;
            next;
        }
        my @array = (split (/\s+/, $line))[5, 6, 7]; 
        if ($part == 0) {
            push @refer, [ @array ]; 
        } else {
            push @points, [ @array ]; 
        }
    } 
    my %max = (val=>0, x=>0, y=>0, z=>0);
    foreach my $ref(@refer) {
        my ($x1, $y1, $z1) = @{$ref};
        foreach my $atom(@points) {
            my ($x, $y, $z) = @{$atom};
            my $dist = sqrt( ($x-$x1)**2 + ($y-$y1)**2 + ($z-$z1)**2 );
            if ($dist > $max{val}) {
                $max{val} = $dist;
                $max{x} = $x;
                $max{y} = $y;
                $max{z} = $z;
            }
        }
    }
    print "max is $max{val}; coord: x=$max{x}, y=$max{y}, z=$max{z}\n";
    
    __DATA__
    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
    

    output:

    max is 35.9813670807545; coord: x=30.175, y=4.389, z=5.768
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have a matrix report now that has Position, Hours and Wages for a location
I'm trying to read a PDB file into a C# application. When I call
I have a .dll file and its respective .pdb file. I do not have
I have this post that teaches me about pdb file and StackTrace. This is
I'm trying to call SymLoadModuleEx to load the symbols from a PDB file and
I'm trying to debug my dll and I have the pdb file next to
I have an old DLL file which was built with VC++ 6. Now I
I have private pdb file and I have to convert it to a public
I have a file r . I want to replace the words File and
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.