Here is the program.
$File_Path="c:\\teja\\2UZT.pdb";
%chain=();
$Total_Seqres=0;
$Total_Helix=0;
open(FH,"$File_Path");
while(
if ( $_ =~ /SEQRES/ ) {
@Seqres=split(" ",$_);
if ( ! exists $chain{$Seqres[2]}) {
$chain{$Seqres[2]}=$Seqres[3];
$Total_Seqres += $Seqres[3];
}
}
if ( $_ =~ /HELIX/ ) {
$Total_Helix+=(split/\s/,$_)[-1];
}
} #while end here
close(FH);
print "\n Helix Value: $Total_Helix \n";
print "\n Total SEQRES: $Total_Seqres \n";
$Per_Value=($Total_Helix*100)/$Total_Seqres;
print "\n The percentage of aminoacids in a protein that are present in helix region is: $Per_Value \n";
Thanks to Amit for sending me the intial solution.
Teja
Same program, but written in better (readable, modern, reliable) Perl:
ReplyDeleteuse strict;use warnings;use diagnostics;use Fatal qw/:void open close/;
my $File_Path="c:\\teja\\2UZT.pdb";
my %chain;
my $Total_Seqres=0;
my $Total_Helix=0;
open(my $fh,'<',$File_Path);
while(my $line=<$fh>) {
if ( $line =~ /SEQRES/ ) {
@Seqres=split(" ",$line);
if ( ! exists $chain{$Seqres[2]}) {
$chain{$Seqres[2]}=$Seqres[3];
$Total_Seqres += $Seqres[3];
}
}
if ( $line =~ /HELIX/ ) {
$Total_Helix+=(split/\s/,$line)[-1];
}
} #while end here
close($fh);
print "\n Helix Value: $Total_Helix \n";
print "\n Total SEQRES: $Total_Seqres \n";
my $Per_Value=($Total_Helix*100)/$Total_Seqres;