Hi everyone,
I would like to parse this text file
PREVIT:nmrValidate_166w.pdb
atoms "A -750 -GLU -CG " and "B -54 -GLN -CG " 3.8759 A apart
atoms "A -750 -GLU -CD " and "B -54 -GLN -CG " 3.8447 A apart
atoms "A -750 -GLU -C " and "B -51 -LYS -CE " 3.8431 A apart
atoms "A -751 -PRO -CB " and "B -52 -ARG -CB " 3.7116 A apart
atoms "A -751 -PRO -CB " and "B -52 -ARG -CD " 3.3998 A apart
atoms "A -751 -PRO -CG " and "B -52 -ARG -CB " 3.4295 A apart
atoms "A -751 -PRO -C " and "B -51 -LYS -CE " 3.5360 A apart
atoms "A -752 -VAL -CA " and "B -51 -LYS -CB " 3.8923 A apart
atoms "A -753 -LYS -CG " and "B -52 -ARG -CG " 3.3236 A apart
atoms "A -753 -LYS -CG " and "B -52 -ARG -CD " 3.8331 A apart
atoms "A -758 -PRO -CD " and "B -48 -GLY -CA " 3.6687 A apart
atoms "A -809 -TYR -CE2 " and "B -49 -ARG -CG " 3.8926 A apart
atoms "A -809 -TYR -CE2 " and "B -49 -ARG -CD " 3.7719 A apart
atoms "A -809 -TYR -CE2 " and "B -49 -ARG -CZ " 3.7362 A apart
PREVIT:nmrValidate_192w.pdb
atoms "A -748 -PHE -CA " and "B -50 -ALY -CD " 3.4090 A apart
atoms "A -748 -PHE -CA " and "B -50 -ALY -CE " 3.8186 A apart
atoms "A -748 -PHE -CD1 " and "B -50 -ALY -CG " 3.6835 A apart
atoms "A -748 -PHE -C " and "B -50 -ALY -CD " 3.8035 A apart
atoms "A -751 -PRO -CD " and "B -52 -ARG -CB " 3.8566 A apart
atoms "A -809 -TYR -CZ " and "B -48 -GLY -CA " 3.5344 A apart
PREVIT:nmrValidate_251w.pdb
atoms "A -748 -PHE -CA " and "B -50 -ALY -CZ " 3.8672 A apart
atoms "A -748 -PHE -CD1 " and "B -50 -ALY -CZ " 3.6054 A apart
atoms "A -748 -PHE -CD1 " and "B -50 -ALY -CM " 3.8393 A apart
atoms "A -750 -GLU -CB " and "B -51 -LYS -CA " 3.7115 A apart
to extract every group which has line begins with PREVIT, then count the line has "-50 -ALY" and choose the group which have the most "-50 -ALY"
This is my code, it doesn't work for my purpose. COuld you please correct it
#!/usr/bin/perl -w
use strict;
use FileHandle;
sub extractALY($)
{
my $count = 0;
my $fileHandle = $_[0];
while (<$fileHandle>)
{
my $line = $_;
chomp($line);
$line_number++;
if ($line =~ m/^[PREVIT]/)
{
next;
print "$line\n";
if ($line =~ m/[-50 -ALY]/)
{
$count++;
push (@array,$line);
}
}
}
}
my $fh = new FileHandle;
$fh->open("<test.txt") or die "Could not open file\n";
extractALY($fh);
$fh->close(); # automatically closes file
Many thanks