in reply to Re: initialize all values in a hash
in thread initialize all values in a hash
Thank you for the suggestion of the other way. I now check and if it is the first time it sees this query it will assign the current bit_score as the max, and then check all subsequent ones to see if they are bigger.
and maybe I'll re-read the llama book. It was a while ago and I left Perl for a few years, and seem to have a selective memory.
my $in_blast_tab=$ARGV[0]; open(IN,$in_blast_tab) or die "cannot open $in_blast_tab\n"; my $HoFlg1={}; my $HoFlg2={}; my %maxBits; while (my $line=<IN>) { next if ($line =~ /^#/); next unless ($line =~ /\S/); chomp $line; my ($Query_id,$strand,$Subj_id,$Perc_iden,$align_len,$num_mm,$ +gap,$q_start,$q_end,$s_start,$s_end,$e_value,$bit_score)=split("\t",$ +line); # extra field of strand next if ($bit_score <60); if (!exists $maxBits{$Query_id}){ $maxBits{$Query_id}=$bit_score; } elsif (exists $maxBits{$Query_id} && $bit_score > $maxBits{$Qu +ery_id}){ $maxBits{$Query_id}=$bit_score; } my ($Flag1, $Flag2 ) = &Flag( $Subj_id, \%proph_prots, \%euk_p +rots, \%vir_prots ); $HoFlg1->{$Query_id}->{$Flag1}->{$bit_score}++; $HoFlg2->{$Query_id}->{$Flag2}->{$bit_score}++; print join("\t",$Query_id,$Subj_id,"bit",$bit_score,"F1",$Flag +1,"F2",$Flag2,"maxBits{Query}",$maxBits{$Query_id})."\n"; }
|
|---|