[Bio] / Clearinghouse / utils.pm Repository:
ViewVC logotype

Diff of /Clearinghouse/utils.pm

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

revision 1.2, Tue May 3 17:38:19 2005 UTC revision 1.3, Tue May 3 20:18:57 2005 UTC
# Line 6  Line 6 
6  use strict;  use strict;
7  use base 'Exporter';  use base 'Exporter';
8    
9    use IO::Handle;
10    use IPC::Open3;
11  use HTML;  use HTML;
12  use Clearinghouse::ch_database;  use Clearinghouse::ch_database;
13    use FIG;
14    use FIG_Config;
15    
16    our $fig;
17    
18  our @EXPORT = qw(check_types  our @EXPORT = qw(check_types
19                   get_lock                   get_lock
20                   release_lock                   release_lock
21                   get_page_header                   get_page_header
22                     validate_package
23                  );                  );
24    
25    sub validate_package
26    {
27        my($pkg, $type) = @_;
28    
29        my %meta;
30    
31        my $stdin = new IO::Handle;
32        my $stdout = new IO::Handle;
33        my $stderr = new IO::Handle;
34    
35        my $cmd;
36    
37        if ($type eq "SUBSYSTEM" or $type eq "1-SUBSYSTEM")
38        {
39            $cmd = "$FIG_Config::bin/validate_subsystem";
40        }
41        elsif ($type eq "GENOME")
42        {
43            $cmd = "$FIG_Config::bin/validate_genome_gff";
44        }
45        else
46        {
47            die "validate_package: invalid type $type\n";
48        }
49    
50        my $pid = open3($stdin, $stdout, $stderr, "$cmd $pkg");
51    
52        $pid or die "Cannot run $cmd $pkg: $!";
53    
54        close($stdin);
55    
56        my @out = <$stdout>;
57    
58        my @err = <$stderr>;
59    
60        close($stdout);
61        close($stderr);
62    
63        waitpid($pid, 0);
64    
65        if ($?)
66        {
67            die "Validate failed with exit code $?. Error output:\n@out\n";
68        }
69    
70        foreach $_ (@out)
71        {
72            chomp;
73            my($k, $v) = split(/\t/);
74            $meta{$k} = $v;
75        }
76    
77        return %meta;
78    }
79    
80  sub get_page_header  sub get_page_header
81  {  {
82      my @page_header = &HTML::compute_html_header(undef, undef,      my @page_header = &HTML::compute_html_header(undef, undef,

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3