I am parsing an output report from psiblast. I used COG alignments and searched a gene database for matches (homologues). One thing that I want to do is to find out which genes match to more than one COG. My partial script is below.
I am specifically having problems creating an array that holds all of the COGs for the genes that are assigned to multiple COGs.
I am getting the following error "Can't use string ("COG0003") as an ARRAY ref while "strict refs" in use at parse_POG_reports.pl line 26, line 67.".
I have looked at other posted relating to pushing elements into hashes of arrays. But I think the error might be occurring when one gene has 2 matches to the same COG, and it tries to push the same COG into the array (ie. the last 2 lines of the sample input). Does this make sense? If so, how can I avoid this problem?
use strict;
use warnings;
my %maxBits;my %COGhit_count;
my $Hohits={};my %COGhits;
my $COG_psi_report=$ARGV[0];
open (IN, $COG_psi_report) or die "cannot open $COG_psi_report\n";
while (my $line=<IN>){
next if ($line =~/^#/);
chomp $line;
my @columns = split(/\t/,$line);
my $bits=$columns[11];
my $COG=$columns[0];
my $hit=$columns[1];
my $Eval=$columns[10];
next if ($Eval > 0.00001); # threshold for significant hits set by DK
$COGhit_count{$hit}++; # count how many COGs each gene is homologous to
$COGhits{$hit}=$COG;
if ($COGhit_count{$hit}>1) {
push @{$COGhits{$hit}}, $COG; #
}
## for those that there are multiple hits we need to select top hit ##
if (!exists $maxBits{$hit}){
$maxBits{$hit}=$bits;
}
elsif (exists $maxBits{$hit} && $bits > $maxBits{$hit}){
$maxBits{$hit}=$bits;
}
$Hohits->{$hit}->{$bits}=$COG;
}
close (IN);
example Input:
POG0002 764184357-stool1_revised_scaffold22981_1_gene47608 23.90 159 112 3 1 156 1 153 2e-06 54.2
POG0002 764062976-stool2_revised_C999233_1_gene54902 23.63 182 121 5 3 169 2 180 2e-06 53.9
POG0002 763901136-stool1_revised_scaffold39447_1_gene145241 26.45 155 89 3 3 137 5 154 3e-06 53.9
POG0002 765701615-stool1_revised_C1349270_1_gene168522 23.53 187 115 5 3 169 2 180 5e-06 53.1
POG0002 158802708-stool2_revised_C1077267_1_gene26470 22.69 216 158 5 3 213 5 216 5e-06 52.7
POG0003 160502038-stool1_revised_scaffold47906_2_gene161164 33.00 297 154 6 169 424 334 626 6e-40 157
POG0003 160502038-stool1_revised_scaffold47906_2_gene161164 16.28 172 128 4 23 192 46 203 1e-06 56.6
POG0003 158337416-stool1_revised_C1254444_1_gene13533 30.06 346 184 7 133 424 57 398 6e-40 155
POG0003 158337416-stool1_revised_scaffold29713_1_gene153054 28.61 332 194 8 132 424 272 599 2e-38 152
POG0003 158337416-stool1_revised_scaffold29713_1_gene153054 24.00 200 131 5 1 193 5 190 9e-11 69.3