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

Annotation of /FigKernelScripts/load_atomic_regulons.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1 # -*- perl -*-
2 :     #
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #
18 :    
19 :    
20 :     ###########################################
21 :     use strict;
22 :    
23 :     use FIG;
24 :     my $fig = new FIG;
25 :    
26 :     # usage: load_atomic_regulons genome-id ar-file
27 :    
28 :     #
29 :     # Load a file of atomic regulons as created by compute_atomic_regulons_for_dir.
30 :     #
31 :     # We just keep a cache from peg => (genome, regulon-number)
32 :     # so we can do fast lookups from the seed pages to determine the regulon.
33 :     #
34 :    
35 :     @ARGV == 2 or die "Usage: load_atomic_regulons genome-id atomic-regulon-file\n";
36 :     my $genome = shift;
37 :     my $ar_file = shift;
38 :    
39 :     open(AR, "<", $ar_file) or die "Cannot open $ar_file: $!";
40 :    
41 :     my $dbf = $fig->{_dbf};
42 :    
43 :     if (!$dbf->table_exists("atomic_regulon"))
44 :     {
45 :     $dbf->create_table( tbl => 'atomic_regulon',
46 :     flds => qq(fid varchar(64),
47 :     genome varchar(32),
48 :     regulon int,
49 :     size int),
50 :     );
51 :    
52 :     $dbf->create_index( idx => "atomic_regulon_ix",
53 :     tbl => "atomic_regulon",
54 :     type => "btree",
55 :     flds => "fid" );
56 :     $dbf->create_index( idx => "atomic_regulon_genome_ix",
57 :     tbl => "atomic_regulon",
58 :     type => "btree",
59 :     flds => "genome" );
60 :     }
61 :    
62 :     my $n = $dbf->{_dbh}->do(qq(DELETE FROM atomic_regulon
63 :     WHERE genome = ?), undef, $genome);
64 :     print "Deleted $n old values\n";
65 :    
66 :     my $sth = $dbf->{_dbh}->prepare(qq(INSERT INTO atomic_regulon (fid, genome, regulon, size)
67 :     VALUES(?, ?, ?, ?)));
68 :     my @ents;
69 :     my %sizes;
70 :     while (<AR>)
71 :     {
72 :     chomp;
73 :     my($reg, $fid, $fn) = split(/\t/);
74 :     $sizes{$reg}++;
75 :     push(@ents, [$reg, $fid]);
76 :     }
77 :     if (@ents == 0)
78 :     {
79 :     die "No entries found in $ar_file\n";
80 :     }
81 :    
82 :     for my $ent (@ents)
83 :     {
84 :     my($reg, $fid) = @$ent;
85 :     $sth->execute($fid, $genome, $reg, $sizes{$reg});
86 :     }
87 :     close(AR);

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3