CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
rmsd calculation

 



kapab07
Novice

Mar 24, 2013, 8:27 AM

Post #1 of 4 (718 views)
rmsd calculation Can't Post

Good morning everyone. I am new to perl and I am writing a script to calculate the rmsd of a pdb file. The script is below and I am having lots od errors I cannot figure out how to fix them.
Here is the script:

#!/usr/bin/perl -W
use strict;
use warnings;

print($ARGV[0]);
open(FILE,$ARGV[0]) || die "$!\n";
my $fn=0;
while(chomp(my $line=<FILE>)){
open('~/pdb_data/00/pdb100d.pdb',$line) || die "$!\n";
#my $cn=0;
while(chomp(my $l=<~/pdb_data/00/pdb100d.pdb>)){
my $resid=substr($l,22,4);
my $resid=~s/ //g;
my $atname=substr($l,12,4);
if($resid>38 && $resid<41 && $l=~/^ATOM/ && !($atname=~/ N / || $atname=~/ CA / || $atname=~/ C / || $atname=~/ O / || $atname=~/ CB /)){
$posX{$fn}{$resid}{$atname}=substr($l,30,8);
$posY{$fn}{$resid}{$atname}=substr($l,30,8);
$posZ{$fn}{$resid}{$atname}=substr($l,30,8);
$cn++;
}

}
close(PDB);
$fn++;
}
print "$fn\n";
close(FILE);
for($i=0;$i<$fn-1;$i++){
for($j=$i+1;$j<$fn;$j++){
$rmsd=0;
$cn=0;
for($resid=156;$resid<160;$resid++){
foreach $k (keys(%{ $posX{$i}{$resid} })){
$rmsd=+ ($posX{$i}{$resid}{$k} - $posX{$j}{$resid}{$k})**2 + ($posY{$i}{$resid}{$k} - $posY{$j}{$resid}{$k})**2 + ($posZ{$i}{$resid}{$k} - $posZ{$j}{$resid}{$k})**2;
$cn++;
}
}
$rmsd= sqrt($rmsd)/$cn;
printf"%d %d %.2f\n",$i,$j,$rmsd;
}
}

Here is the output:
"my" variable $resid masks earlier declaration in same scope at rmsd.pl line 13.
Reversed += operator at rmsd.pl line 34.
Global symbol "%posX" requires explicit package name at rmsd.pl line 16.
Global symbol "%posY" requires explicit package name at rmsd.pl line 17.
Global symbol "%posZ" requires explicit package name at rmsd.pl line 18.
Global symbol "$i" requires explicit package name at rmsd.pl line 28.
Global symbol "$i" requires explicit package name at rmsd.pl line 28.
Global symbol "$i" requires explicit package name at rmsd.pl line 28.
Global symbol "$j" requires explicit package name at rmsd.pl line 29.
Global symbol "$i" requires explicit package name at rmsd.pl line 29.
Global symbol "$j" requires explicit package name at rmsd.pl line 29.
Global symbol "$j" requires explicit package name at rmsd.pl line 29.
Global symbol "$rmsd" requires explicit package name at rmsd.pl line 30.
Global symbol "$cn" requires explicit package name at rmsd.pl line 31.
Global symbol "$resid" requires explicit package name at rmsd.pl line 32.
Global symbol "$resid" requires explicit package name at rmsd.pl line 32.
Global symbol "$resid" requires explicit package name at rmsd.pl line 32.
Global symbol "$k" requires explicit package name at rmsd.pl line 33.
Global symbol "%posX" requires explicit package name at rmsd.pl line 33.
Global symbol "$i" requires explicit package name at rmsd.pl line 33.
Global symbol "$resid" requires explicit package name at rmsd.pl line 33.
Global symbol "$rmsd" requires explicit package name at rmsd.pl line 34.
Global symbol "%posX" requires explicit package name at rmsd.pl line 34.
Global symbol "$i" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "%posX" requires explicit package name at rmsd.pl line 34.
Global symbol "$j" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "%posY" requires explicit package name at rmsd.pl line 34.
Global symbol "$i" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "%posY" requires explicit package name at rmsd.pl line 34.
Global symbol "$j" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "%posZ" requires explicit package name at rmsd.pl line 34.
Global symbol "$i" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "%posZ" requires explicit package name at rmsd.pl line 34.
Global symbol "$j" requires explicit package name at rmsd.pl line 34.
Global symbol "$resid" requires explicit package name at rmsd.pl line 34.
Global symbol "$k" requires explicit package name at rmsd.pl line 34.
Global symbol "$cn" requires explicit package name at rmsd.pl line 35.
Global symbol "$rmsd" requires explicit package name at rmsd.pl line 38.
Global symbol "$rmsd" requires explicit package name at rmsd.pl line 38.
Global symbol "$cn" requires explicit package name at rmsd.pl line 38.
Global symbol "$i" requires explicit package name at rmsd.pl line 39.
Global symbol "$j" requires explicit package name at rmsd.pl line 39.
Global symbol "$rmsd" requires explicit package name at rmsd.pl line 39.
Execution of rmsd.pl aborted due to compilation errors.


What am I doing wrong? Can someone help? Thanks a lot.


Laurent_R
Veteran / Moderator

Mar 24, 2013, 11:48 AM

Post #2 of 4 (712 views)
Re: [kapab07] rmsd calculation [In reply to] Can't Post

This is a bit strange. You asked a similar question on another forum (devshed) with a smaller excerpt of the same script.

I explained your errors, especially that you have to declare your variables (usually with the my function). You obviously read my reply since you incorporated my suggested corrections in the script above (although did not care to reply to my message). But it seems you did not read the explanations, since you still don't do it for the other new variables of your script.

Include the following line:


Code
my (%posX, %posY, %posZ);

near the beginning of your script.

Similarly, declare $i, $j, $resif, $rmsd, etc., where you first use them. This should remove most of the compile errors.


Kenosis
User

Mar 24, 2013, 7:18 PM

Post #3 of 4 (705 views)
Re: [kapab07] rmsd calculation [In reply to] Can't Post

Have you checked whether the module Bio::PDB::Structure provides the rmsd calculation functionality you need? Its documentation shows the following:


Code
$rmsd = $mol2 -> rmsd($mol1);            #compute the rmsd between mol2 and mol1


Hope this helps!


kapab07
Novice

Mar 26, 2013, 2:53 PM

Post #4 of 4 (694 views)
Re: [Laurent_R] rmsd calculation [In reply to] Can't Post

Thanks a lot Laurent_R for all your answers.

In Reply To

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives