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

Annotation of /FigKernelScripts/validate_subsystem.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1 #
2 : olson 1.2 # Copyright (c) 2003-2006 University of Chicago and Fellowship
3 :     # for Interpretations of Genomes. All Rights Reserved.
4 :     #
5 :     # This file is part of the SEED Toolkit.
6 :     #
7 :     # The SEED Toolkit is free software. You can redistribute
8 :     # it and/or modify it under the terms of the SEED Toolkit
9 :     # Public License.
10 :     #
11 :     # You should have received a copy of the SEED Toolkit Public License
12 :     # along with this program; if not write to the University of Chicago
13 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
14 :     # Genomes at veronika@thefig.info or download a copy from
15 :     # http://www.theseed.org/LICENSE.TXT.
16 :     #
17 :    
18 :     #
19 : olson 1.1 # Validate a subsystem package, printing a tab-delimited list of metadata if it is valid.
20 :     #
21 :     # Otherwise return a nonzero exit code and print errors to stdout.
22 :     #
23 :    
24 :     use strict;
25 :     use FIG;
26 :     use P2Pupdate;
27 :    
28 :     my $usage = "validate_subsystem subsystem-package";
29 :    
30 :     @ARGV == 1 or die $usage;
31 :    
32 :     my $package = shift;
33 :    
34 :     my @output;
35 :    
36 :     my $sub;
37 :    
38 :     my $fig;
39 :    
40 :     eval {
41 :     $sub = new SubsystemFile($FIG_Config::temp, $package, $fig);
42 :     $sub->load();
43 :     };
44 :    
45 :     if ($@)
46 :     {
47 :     print "Subsystem package file did not parse:\n$@\n";
48 :     exit 1;
49 :     }
50 :    
51 :     warn sprintf("Parsed subsystem file. Subsystem name %s, version %s, curator %s\n",
52 :     $sub->name, $sub->version, $sub->curator);
53 :    
54 :     push(@output,
55 :     [name => $sub->name],
56 :     [version => $sub->version],
57 :     [curator => $sub->curator]);
58 :    
59 :     #
60 :     # Perform some initial validation.
61 :     #
62 :    
63 :     my @errors;
64 :    
65 :     $sub->name ne '' or push @errors, "Name not specified";
66 :     $sub->curator ne '' or push @errors, "Curator not specified";
67 :     $sub->version =~ /^\d+/ or push @errors, "Invalid version " . $sub->version;
68 :     (ref($sub->{roles}) and @{$sub->{roles}} > 0) or push @errors, "Subsystem has no roles";
69 :     (ref($sub->{genomes}) and @{$sub->{genomes}} > 0) or push @errors, "Subsystem has no genomes";
70 :    
71 :     if (@errors)
72 :     {
73 :     print join("\n", @errors), "\n";
74 :     exit(1);
75 :     }
76 :    
77 :     for my $elt (@output)
78 :     {
79 :     print join("\t", @$elt), "\n";
80 :     }
81 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3