AWallBuilder has asked for the wisdom of the Perl Monks concerning the following question:
########### subroutine get host and taxid ### sub getDetails { my $proph=@_; my $host;my $taxid;my $genNum_proph; print "$proph\tproph inside sub"; my @proph_columns=split(/\_/,$proph); # get host info if ($proph_columns[0] =~ /^FP92/){ $host=$proph_columns[0]; } else { $host=join("_",$proph_columns[0],$proph_columns[1]); } if ($host =~ /^NZ/){ ## for wgs genomes just match first 7 cha +racters as only NZ_XXXX000000 are in tax2locus my $host=substr $host, 0, 7; } print "$host\t"; #get taxid my ($matching_key)= grep { /^$host/ } keys %tax2loc; $taxid=$tax2loc{$matching_key}; ## get number of proteins in the prophage if (exists $genesPerProphGen{$proph}){ $genNum_proph=$genesPerProphGen{$proph}; } else{ print "$proph doesn't have number of genes\n" } return($host,$taxid,$genNum_proph); } ##### Now make table with numbers ##### my $shared_table="$mci_file.sharedTab"; my $genNum_prophA;my $genNum_prophB;my $host_prophA;my $host_prophB; open (OUTs,">$shared_table"); print OUTs "# This table was generated using $0 on\t".scalar(localtime +(time))."\n"; print OUTs "#".join("\t",qw(Proph_genomeA Proph_genomeB hostA taxidA h +ostB taxidB Jacc Prots_Shared Protsin_prophA Protsin_prophB))."\n"; foreach my $prophA (keys %$overlap){ print "$prophA\tfrom overlap\t"; my($hostA,$taxidA,$genNum_prophA)=&getDetails($prophA); foreach my $prophB (keys %{$overlap->{$prophA}}){ my($hostB,$taxidB,$genNum_prophB)=&getDetails($prophB) +; my $A_notShared=$genNum_prophA-$overlap->{$prophA}{$pr +ophB}; my $B_notShared=$genNum_prophB-$overlap->{$prophA}{$pr +ophB}; my $Jac_denom=$overlap->{$prophA}{$prophB}+$A_notShare +d+$B_notShared; my $Jac=$overlap->{$prophA}{$prophB}/$Jac_denom; print OUTs join("\t",$prophA,$prophB,$host_prophA,$tax +idA,$host_prophB,$taxidB,$Jac,$overlap->{$prophA}{$prophB},$genNum_pr +ophA,$genNum_prophA)."\n"; } } close(OUTs);
FP929058_PFPR05 from overlap 1 proph inside sub1_ 1 does +n't have number of genes
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing variables to a subroutine
by moritz (Cardinal) on Jul 04, 2012 at 09:02 UTC | |
by AWallBuilder (Beadle) on Jul 04, 2012 at 09:11 UTC | |
by AnomalousMonk (Archbishop) on Jul 04, 2012 at 16:23 UTC | |
|
Re: passing variables to a subroutine
by Corion (Patriarch) on Jul 04, 2012 at 09:04 UTC |