#!/usr/bin/perl
my $file = $ARGV[0];
my $value = $ARGV[1];
my @grabbed;
open (FILE, $file);
while (<FILE>) {
if (/alignment# residue#/) {
push @grabbed, $_;
while (<FILE>) {
last if /^$/;
push @grabbed, $_;
}
}
}
close (FILE);
my $line= `awk ' {if(\$2==$value)} ' @grabbed`;
print $line;
Problem :
1.First, I don’t know if its possible to do awk on an array or not?
2. I am trying to match a value, existing on the second column of the 2-D array (@grabbed). The @grabbed will look like this :
7 1 M 1.000 6 .VPMLG 66.63
8 2 S 1.000 10 .QINTSARKG 66.63
9 3 V 1.000 13 .KTAVFPRGQMSL 66.63
10 4 L 1.000 7 .SLAKFT 66.63
11 5 L 1.000 14 .ALSVQWIKMRYPF 66.63
12 6 R 1.000 16 .DERSAVGTNQLYMIP 66.63
13 7 S 1.000 18 .GDTHPKRSALFCIQVYN 66.63
14 8 G 1.000 17 .DRFLENGAQPSTYCHM 66.63
15 9 L 1.000 19 .NDHPELASVKRCWFGTQI 66.63
16 10 G 1.000 18 .RLDPEGFTYAVCIKNMH 66.63
I am trying to match and grab the line in which column 2 is of value “9”.
No need to swith to
awkwhen that job can be done withperltoo.