[Bio] / Sprout / FidCheck.pm Repository:
ViewVC logotype

Diff of /Sprout/FidCheck.pm

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

revision 1.1, Sun Jun 25 00:00:18 2006 UTC revision 1.2, Tue Apr 10 05:59:07 2007 UTC
# Line 15  Line 15 
15  =head2 Introduction  =head2 Introduction
16    
17  This object supports the C<is_deleted_fid> method to determine whether or not  This object supports the C<is_deleted_fid> method to determine whether or not
18  a feature exists in a Sprout or FIG data store.  a feature exists in a Sprout or FIG data store. If a FIG data store is used, then
19    the the C<$fig> object is returned unmodified. In the Sprout case, it will check
20    to see if the incoming ID is for an existing feature or synonym group. In addition,
21    it will cache the identified IDs so they don't need to be checked against the
22    database if the method is called again.
23    
24  =head2 Public Methods  =head2 Public Methods
25    
# Line 44  Line 48 
48      # Check the object type.      # Check the object type.
49      if (ref($sprout_or_fig) eq 'Sprout') {      if (ref($sprout_or_fig) eq 'Sprout') {
50          # Here we have a Sprout object.          # Here we have a Sprout object.
51          $retVal = { db => $sprout_or_fig };          $retVal = { db => $sprout_or_fig,
52                        cache => { } };
53            bless $retVal, $class;
54        } elsif (ref($sprout_or_fig) eq 'SFXlate') {
55            # Here we have an SFXlate object. We need its internal Sprout object.
56            $retVal = { db => $sprout_or_fig->{sprout},
57                        cache => { } };
58          bless $retVal, $class;          bless $retVal, $class;
59      } else {      } else {
60          # Return the object unmodified. It already has the required method.          # Return the object unmodified. It already has the required method.
# Line 58  Line 68 
68    
69  C<< my $flag = $fidCheck->is_deleted_fid($fid); >>  C<< my $flag = $fidCheck->is_deleted_fid($fid); >>
70    
71  Return TRUE if the specified feature does not exist, else FALSE.  Return TRUE if the specified feature does not exist, else FALSE. A feature exists if it is
72    in the B<Feature> table or the B<SynonymGroup> table. The synonym groups are not real features,
73    but they do have similarities, so it's important to
74    
75  =over 4  =over 4
76    
# Line 77  Line 89 
89  sub is_deleted_fid {  sub is_deleted_fid {
90      # Get the parameters.      # Get the parameters.
91      my ($self, $fid) = @_;      my ($self, $fid) = @_;
92      # Test for existence of the feature.      # Declare the return flag.
93      my $flag = $self->{db}->Exists('Feature', $fid);      my $flag;
94        # Check the cache.
95        my $cache = $self->{cache};
96        if (exists $cache->{$fid}) {
97            $flag = $cache->{$fid};
98            Trace("$flag pulled from cache for $fid.") if T(4);
99        } else {
100            # Check the incoming ID type.
101            if ($fid =~ /^fig\|/i) {
102                # Here we have a feature ID. Test for existence of the feature.
103                $flag = $self->{db}->Exists('Feature', $fid);
104                Trace("$flag pulled from feature table for $fid.") if T(4);
105            } else {
106                # Here we have a synonym group ID. Test for its existence.
107                $flag = $self->{db}->Exists('SynonymGroup', $fid);
108                Trace("$flag pulled from synonym grup table for $fid.") if T(4);
109            }
110            # Cache the result.
111            $cache->{$fid} = $flag;
112        }
113      # Return the result.      # Return the result.
114      return ! $flag;      return ! $flag;
115  }  }

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3