in reply to Re: help with hash or arrays or hash references
in thread help with hash or arrays or hash references
Great Thanks. I had just realized the that I had to move the declaration to outside of the if else loop. I also like the idea of a subroutine. Subroutine is now working. Here working code for any following this thread
new code
############### read in blast table and parse ####### my $in_blast_tab=$ARGV[0]; open(IN,$in_blast_tab) or die "cannot open $in_blast_tab\n"; my %HoFlg1; my %HoFlg2; #my $Flag1; my $Flag2; while (my $line=<IN>) { 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); my ($Flag1, $Flag2 ) = &Flag( $Subj_id, \%proph_prots, \%euk_p +rots, \%vir_prots ); $HoFlg1{$Query_id}{$Subj_id}{$bit_score}=$Flag1; $HoFlg2{$Query_id}{$Subj_id}{$bit_score}=$Flag2; print join("\t",$Query_id,$Subj_id,$bit_score,$Flag1,$Flag2)." +\n"; } sub Flag { my $Subj_id=$_[0]; my $proph_prots=$_[1]; my $euk_prots=$_[2]; my $vir_prots=$_[3]; my $Flag1; my $Flag2; if (exists $proph_prots{$Subj_id}){ $Flag1="Proph"; $Flag2="Phage"; } elsif (exists $euk_prots{$Subj_id}){ $Flag1="Euk"; $Flag2="Euk" } elsif(exists $vir_prots{$Subj_id}){ $Flag1="Vir"; $Flag2="Phage"; } else { $Flag1="Bact"; $Flag2="Bact"; } return($Flag1,$Flag2); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: help with hash or arrays or hash references
by Cristoforo (Curate) on May 08, 2012 at 18:12 UTC | |
|
Re^3: help with hash or arrays or hash references
by hbm (Hermit) on May 08, 2012 at 15:17 UTC | |
|
Re^3: help with hash or arrays or hash references
by Anonymous Monk on May 08, 2012 at 15:34 UTC | |
by AWallBuilder (Beadle) on May 09, 2012 at 12:54 UTC |