Contact:
sales@biotechnologyforums.com to feature here

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PERL Program - BINC 2017 question
#1
Question:

Intra Molecular Distance Matrix calculation (50 marks) : ATOM lines (155) of a pdb file are provided in input file (only C@ residues). Calculate intra molecular distance between each C@ residue. If distance >= 6, print 1 in distance matrix of output file, else print 0 in distance matrix.


Solution:

#!/usr/bin/perl -w
# Perl program to calculate intra molecular distance
use strict;
my ($file,$line,@array_x,@array_y,@array_z,$dist,$j,$i,$element);
my $k=0;
print "Enter the PDB filename: ";
$file = <STDIN>;
chomp $file;
open (FILE, $file) or die "Cannot open file $file \n\n" ;

while ($line = <FILE>) 
{
if ($line =~ /^ATOM/)
{  
$array_x[$k] = (split (/\s+/, $line))[6];
$array_y[$k] = (split (/\s+/, $line))[7];
$array_z[$k] = (split (/\s+/, $line))[8];
$k++;
}
}
close FILE;
#print "K=$k \n";
#print "@array_x \n @array_y \n @array_z \n";
print "\n Intramolecular Distance Matrix is : \n\n";
print "ATOMi \t ATOMj \t Euclidean Distance \t Element \n";
for($i = 0; $i < $k ; $i++)
{
for($j = 0; $j < $k ; $j++)
{
#Euclidean Distance Calculation
$dist = sqrt(
                ($array_x[$i] - $array_x[$j])**2 +
                ($array_y[$i] - $array_y[$j])**2 +
                ($array_z[$i] - $array_z[$j])**2
            );
if ($dist >= 6)

$element = 1;
print "$i \t $j \t $dist \t $element \n"; 
}
else

$element = 0;
print "$i \t $j \t $dist \t $element \n"; 
}
}
}
Like Post Reply
  

Possibly Related Threads…
Thread
Author
  /  
Last Post
Replies: 0
Views: 6,929
10-24-2018, 04:30 AM
Last Postsj26
Replies: 0
Views: 7,686
07-01-2018, 05:08 PM
Last Postbinu
Replies: 2
Views: 14,858
06-19-2018, 06:21 PM
Last Postrakeshojha
Replies: 0
Views: 7,895
04-25-2017, 03:13 PM
Last Postbinu
Replies: 0
Views: 8,169
04-25-2017, 03:05 PM
Last Postbinu



Users browsing this thread:
1 Guest(s)

PERL Program - BINC 2017 question00