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

Diff of /FigKernelPackages/FIGV.pm

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

revision 1.53, Tue May 6 16:50:14 2008 UTC revision 1.54, Thu May 29 23:00:34 2008 UTC
# Line 1078  Line 1078 
1078      }      }
1079  }  }
1080    
1081    
1082    =pod
1083    
1084    find_features_by_annotation
1085    
1086    Takes a reference to a hash of functions to find and an optional case boolean, and returns a hash with keys are the function and values are a reference to an array of the IDs that have that function.
1087    
1088    If the case boolean is set the search is case insensitive. Otherwise case sensitive.
1089    
1090    =cut
1091    
1092    sub find_features_by_annotation {
1093            my($self,$anno_hash, $case)=@_;
1094            $self->load_functions;
1095    
1096            if ($case) {map {$anno_hash->{uc($_)}=1} keys %$anno_hash}
1097    
1098            my $res={};
1099            foreach my $id (keys %{$self->{_functions}})
1100            {
1101                    my $fn = $self->{_functions}->{$id};
1102                    $case ? $fn = uc($fn) : 1;
1103                    if ($anno_hash->{$fn}) {push @{$res->{$fn}}, $id}
1104            }
1105    
1106            return $res;
1107    }
1108    
1109    
1110    =pod
1111    
1112    search_features_by_annotation
1113    
1114    Takes a string to find and an optional case boolean, and returns a hash with keys are the function and values are a reference to an array of the IDs that have that function.
1115    
1116    If the case boolean is set the search is case insensitive. Otherwise case sensitive.
1117    
1118    Note that this was originally based on the find above, but this uses a regexp for matching. Will likely be a lot slower which is why I only search for a single term. There may be an SQL way of doing this, if so let Rob know how to do it and I'll replace this method.
1119    
1120    
1121    =cut
1122    
1123    sub search_features_by_annotation {
1124            my($self,$term, $case)=@_;
1125            $self->load_functions;
1126    
1127            # to make case insensitive convert everything to uppercase
1128            # alternative is to use two regexps, one for case insens and one for not case insens
1129            # but the bad thing about that approach is that if you have a case insensitive search
1130            # you do two regexps for each failed match
1131    
1132            $case ? $term = uc($term) : 1;
1133    
1134            my $res={};
1135            foreach my $id (keys %{$self->{_functions}})
1136            {
1137                    # we set two variables, one that has case changed for case insensitive searches
1138                    my $fn = my $fnc = $self->{_functions}->{$id};
1139                    $case ? $fn = uc($fn) : 1;
1140                    if ($fn =~ m/$term/) {push @{$res->{$fnc}}, $id}
1141            }
1142    
1143            return $res;
1144    }
1145    
1146    
1147  sub feature_aliases {  sub feature_aliases {
1148      my($self,$fid) = @_;      my($self,$fid) = @_;
1149    

Legend:
Removed from v.1.53  
changed lines
  Added in v.1.54

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3