[Bio] / FigKernelScripts / validate_subsystem.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/validate_subsystem.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1 #
2 :     # Validate a subsystem package, printing a tab-delimited list of metadata if it is valid.
3 :     #
4 :     # Otherwise return a nonzero exit code and print errors to stdout.
5 :     #
6 :    
7 :     use strict;
8 :     use FIG;
9 :     use P2Pupdate;
10 :    
11 :     my $usage = "validate_subsystem subsystem-package";
12 :    
13 :     @ARGV == 1 or die $usage;
14 :    
15 :     my $package = shift;
16 :    
17 :     my @output;
18 :    
19 :     my $sub;
20 :    
21 :     my $fig;
22 :    
23 :     eval {
24 :     $sub = new SubsystemFile($FIG_Config::temp, $package, $fig);
25 :     $sub->load();
26 :     };
27 :    
28 :     if ($@)
29 :     {
30 :     print "Subsystem package file did not parse:\n$@\n";
31 :     exit 1;
32 :     }
33 :    
34 :     warn sprintf("Parsed subsystem file. Subsystem name %s, version %s, curator %s\n",
35 :     $sub->name, $sub->version, $sub->curator);
36 :    
37 :     push(@output,
38 :     [name => $sub->name],
39 :     [version => $sub->version],
40 :     [curator => $sub->curator]);
41 :    
42 :     #
43 :     # Perform some initial validation.
44 :     #
45 :    
46 :     my @errors;
47 :    
48 :     $sub->name ne '' or push @errors, "Name not specified";
49 :     $sub->curator ne '' or push @errors, "Curator not specified";
50 :     $sub->version =~ /^\d+/ or push @errors, "Invalid version " . $sub->version;
51 :     (ref($sub->{roles}) and @{$sub->{roles}} > 0) or push @errors, "Subsystem has no roles";
52 :     (ref($sub->{genomes}) and @{$sub->{genomes}} > 0) or push @errors, "Subsystem has no genomes";
53 :    
54 :     if (@errors)
55 :     {
56 :     print join("\n", @errors), "\n";
57 :     exit(1);
58 :     }
59 :    
60 :     for my $elt (@output)
61 :     {
62 :     print join("\t", @$elt), "\n";
63 :     }
64 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3