0

Hello,

I have a file with the data as shown below:

ATOM 2 CA ARG A 1 6.324 32.707 50.379
ATOM 13 CA THR A 2 5.197 32.618 46.826
ATOM 20 CA ASP A 3 4.020 36.132 46.259
ATOM 28 CA CYS A 4 7.131 38.210 45.919

I am a beginner in perl and i wrote a program to retrieve the last three columns and putting them in an array in order to calculate the distance

open (IN, "out.pl");
my $file = ' ';
while (<IN>) {
chomp($file);
my @array = /\d+\.\d+\s+\d+\.\d+\s+\d+\.\d+/
.....
am stuck.
for(#calculate distance){

}
}
close (IN);


I would like to know the script to match the three columns and putting them in an array and writng a for loop to calculate the distance between the four atoms given in the file.

Thank you,

2
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by KevinADC
0
open (IN, "filename.pdb") or die "$!";
while (my $line = <IN>) {
   chomp($line);
   my @array = (split(/\s+/,$line))[6,7,8];
   print "@array\n";
}
close (IN);

Look into perls math operators for the distance calculations. The above just shows an example of how to get the last three columns from a line with 9 columns of varying length data seperated by spaces.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.