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

Diff of /FigKernelPackages/Subsystem.pm

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

revision 1.135, Mon Jul 28 15:28:05 2008 UTC revision 1.136, Sat Sep 6 20:34:52 2008 UTC
# Line 1273  Line 1273 
1273          close(LOG);          close(LOG);
1274          if ($last) { $self->{last_updated} = $last; }          if ($last) { $self->{last_updated} = $last; }
1275      }      }
1276    
1277        #
1278        # If a file OWNER exists in the subsys dir, use that instead.
1279        #
1280  }  }
1281    
1282  sub load_version  sub load_version
# Line 3214  Line 3218 
3218      $self->{role_index}->{$newrole} = $oldindex;      $self->{role_index}->{$newrole} = $oldindex;
3219      $self->{abbr}->{$abbr} = $newrole;      $self->{abbr}->{$abbr} = $newrole;
3220    
3221        for my $key (qw(reactions hope_reactions hope_reaction_notes hope_reaction_links))
3222        {
3223            my $val = delete $self->{$key}->{$oldrole};
3224            if ($val)
3225            {
3226                $self->{$key}->{$newrole} = $val;
3227            }
3228        }
3229    
3230      return ( 1 );      return ( 1 );
3231  }  }
3232    
3233    =head3 change_role_in_column_of_file($oldrole, $newrole, $colnum, $file, $backup_file)
3234    
3235    Copy $file to $backup_file, then rewrite $file mapping any occurences of $oldrole with $newrole
3236    in column $colnum. Assume file is tab-separated.
3237    
3238    Used for remapping the various reactions files.
3239    
3240    $file and $backup_file are paths relative to the subsystem directory.
3241    
3242    =cut
3243    
3244    sub change_role_in_column_of_file
3245    {
3246        my($self, $oldrole, $newrole, $colnum, $file, $backup_file) = @_;
3247    
3248        my $dir = $self->{dir};
3249    
3250        if ($file !~ m,^/,)
3251        {
3252            $file = "$dir/$file";
3253        }
3254    
3255        if ($backup_file !~ m,^/,)
3256        {
3257            $backup_file = "$dir/$backup_file";
3258        }
3259    
3260        my $rc = system("cp", $file, $backup_file);
3261        if ($rc != 0)
3262        {
3263            die "Subsystem::change_role_in_column_of_file: cp $file $backup_file failed with rc $rc";
3264        }
3265    
3266        my($from, $to);
3267        open($from, "<", $backup_file) or die "cannot open $backup_file for reading: $!";
3268        open($to, ">", $file) or die "cannot open $file for writing: $!";
3269    
3270        while (<$from>)
3271        {
3272            chomp;
3273            my @a = split(/\t/);
3274            if ($colnum < @a and $a[$colnum] eq $oldrole)
3275            {
3276                $a[$colnum] = $newrole;
3277            }
3278            print $to join("\t", @a), "\n";
3279        }
3280    
3281        close($from);
3282        close($to);
3283    }
3284    
3285  =head3 remove_role  =head3 remove_role
3286    
3287  Remove the role from the spreadsheet.  Remove the role from the spreadsheet.

Legend:
Removed from v.1.135  
changed lines
  Added in v.1.136

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3