[Bio] / Sprout / FixSubFile.pl Repository:
ViewVC logotype

Annotation of /Sprout/FixSubFile.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 Fix Subsystem Files
4 :    
5 :     This is a simple script that adds role abbreviations to the role list in a Shrub
6 :     subsystem load file.
7 :    
8 :     The two positional parameters are the subsystem load file directory and the FIG subsystem directory.
9 :    
10 :     =cut
11 :    
12 :     use strict;
13 :     $| = 1; ## Prevent buffering on STDOUT.
14 :    
15 :     my $subDir = $ARGV[0] || "/homes/disz/AnnotationDataSite/NewSeed1-29.old/SubSystemData";
16 :     my $figDir = $ARGV[1] || "/vol/core-seed/FIGdisk/FIG/Data/Subsystems";
17 :     my $logFile = "/homes/parrello/missing_subs.log";
18 :     open(my $eh, ">$logFile") || die "Could not open log file $logFile.";
19 :     # Loop through the directories in the source folder.
20 :     print "Subsystems being fixed in $subDir.\n";
21 :     print "Source directory is $figDir.\n";
22 :     opendir(my $dh, $subDir) || die "Could not open $subDir: $!";
23 :     while (my $dir = readdir $dh) {
24 :     if (substr($dir, 0, 1) ne '.' && -f "$subDir/$dir/Roles") {
25 :     # Here we have a subsystem directory. We must replace its role file.
26 :     if (open(my $ih, "<$figDir/$dir/spreadsheet")) {
27 :     open(my $oh, ">$subDir/$dir/Roles") || die "Could not open role file for $dir: $!";
28 :     # Copy the roles.
29 :     my $line = <$ih>;
30 :     my $done;
31 :     my $count = 0;
32 :     while (! $done) {
33 :     if (! defined $line || $line =~ m#^//#) {
34 :     $done = 1;
35 :     } else {
36 :     print $oh $line;
37 :     $count++;
38 :     $line = <$ih>;
39 :     }
40 :     }
41 :     print "$count roles copied for $dir\n";
42 :     close $oh;
43 :     close $ih;
44 :     } else {
45 :     print $eh "$dir\n";
46 :     }
47 :     }
48 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3