[Bio] / FigKernelPackages / raelib.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/raelib.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Mon Jan 31 16:58:38 2005 UTC revision 1.3, Wed Feb 2 01:07:44 2005 UTC
# Line 53  Line 53 
53  sub ss_by_id {  sub ss_by_id {
54   my ($self, $peg)=@_;   my ($self, $peg)=@_;
55   my $ssout;   my $ssout;
  print STDERR "RAELIB Looking for ss from $peg\n";  
56   foreach my $ss (sort $fig->subsystems_for_peg($peg))   foreach my $ss (sort $fig->subsystems_for_peg($peg))
57   {   {
58    next if ($$ss[0] =~ /essential/i); # Ignore the Essential B-subtilis subsystems    next if ($$ss[0] =~ /essential/i); # Ignore the Essential B-subtilis subsystems
# Line 63  Line 62 
62   return $ssout;   return $ssout;
63  }  }
64    
65    =head2 ss_by_homol
66    
67     Generate a list of subsystems that homologs of a peg occur in. This is a ; separated list.
68     This is also a wrapper around sims and ss, but makes everything unified
69    
70    =cut
71    
72    sub ss_by_homol {
73     my ($self, $peg)=@_;
74     return unless ($peg);
75     my ($maxN, $maxP)=(50, 1e-20);
76    
77     # find the sims
78     my @sims=$fig->sims($peg, $maxN, $maxP, 'fig');
79    
80     # we are only going to keep the best hit for each peg
81     # in a subsystem
82     my $best_ss_score; my $best_ss_id;
83     foreach my $sim (@sims)
84     {
85      my $simpeg=$$sim[1];
86      my $simscore=$$sim[10];
87      my @subsys=$fig->subsystems_for_peg($simpeg);
88      foreach my $ss (@subsys)
89      {
90       if (! defined $best_ss_score->{$$ss[0]}) {$best_ss_score->{$$ss[0]}=$simscore; $best_ss_id->{$$ss[0]}=$simpeg}
91       elsif ($best_ss_score->{$$ss[0]} > $simscore)
92       {
93        $best_ss_score->{$$ss[0]}=$simscore;
94        $best_ss_id->{$$ss[0]}=$simpeg;
95       }
96      }
97     }
98    
99     my $ssoutput=join "", (map {"$_ (".$best_ss_id->{$_}."), "} keys %$best_ss_id);
100    
101     $ssoutput =~ s/, $//;
102     return $ssoutput;
103    }
104    
105    =head2 tagvalue
106    
107     This will just check for tag value pairs and return either an array of values or a single ; separated list (if called as a scalar)
108    
109     e.g. $values=raelib->tagvalue($peg, "PIRSF"); print join "\n", @$values;
110    
111     Returns an empty array if no tag/value appropriate.
112    
113     Just because I use this a lot I don't want to waste rewriting it.
114    
115    =cut
116    
117    sub tagvalue {
118     my ($self, $peg, $tag)=@_;
119     my @return;
120     my @attr=$fig->feature_attributes($peg);
121     foreach my $attr (@attr) {
122      my ($gottag, $val, $link)=@$attr;
123      push @return, $val if ($gottag eq $tag);
124     }
125     return wantarray ? @return : join "; ", @return;
126    }
127    
128    
129    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3