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

View of /Sprout/FixSubFile.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (download) (as text) (annotate)
Sun Feb 22 03:28:31 2015 UTC (4 years, 5 months ago) by parrello
Branch: MAIN
CVS Tags: HEAD
Removed Shrub stuff. Updated ERDB for compatibility with Shrub DBD.

#!/usr/bin/perl -w

=head1 Fix Subsystem Files

This is a simple script that adds role abbreviations to the role list in a Shrub
subsystem load file.

The two positional parameters are the subsystem load file directory and the FIG subsystem directory.

=cut

use strict;
$| = 1;	## Prevent buffering on STDOUT.

my $subDir = $ARGV[0] || "/homes/disz/AnnotationDataSite/NewSeed1-29.old/SubSystemData";
my $figDir = $ARGV[1] || "/vol/core-seed/FIGdisk/FIG/Data/Subsystems";
my $logFile = "/homes/parrello/missing_subs.log";
open(my $eh, ">$logFile") || die "Could not open log file $logFile.";
# Loop through the directories in the source folder.
print "Subsystems being fixed in $subDir.\n";
print "Source directory is $figDir.\n";
opendir(my $dh, $subDir) || die "Could not open $subDir: $!";
while (my $dir = readdir $dh) {
	if (substr($dir, 0, 1) ne '.' && -f "$subDir/$dir/Roles") {
		# Here we have a subsystem directory. We must replace its role file.
		if (open(my $ih, "<$figDir/$dir/spreadsheet")) {
			open(my $oh, ">$subDir/$dir/Roles") || die "Could not open role file for $dir: $!";
			# Copy the roles.
			my $line = <$ih>;
			my $done;
			my $count = 0;
			while (! $done) {
				if (! defined $line || $line =~ m#^//#) {
					$done = 1;
				} else {
					print $oh $line;
					$count++;
					$line = <$ih>;
				}
			}
			print "$count roles copied for $dir\n";
			close $oh;
			close $ih;
		} else {
			print $eh "$dir\n";
		}
	}
}

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3