[Bio] / Sprout / SynonymSproutLoader.pm Repository:
ViewVC logotype

Annotation of /Sprout/SynonymSproutLoader.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     #
4 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
5 :     # for Interpretations of Genomes. All Rights Reserved.
6 :     #
7 :     # This file is part of the SEED Toolkit.
8 :     #
9 :     # The SEED Toolkit is free software. You can redistribute
10 :     # it and/or modify it under the terms of the SEED Toolkit
11 :     # Public License.
12 :     #
13 :     # You should have received a copy of the SEED Toolkit Public License
14 :     # along with this program; if not write to the University of Chicago
15 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
16 :     # Genomes at veronika@thefig.info or download a copy from
17 :     # http://www.theseed.org/LICENSE.TXT.
18 :     #
19 :    
20 :     package SynonymSproutLoader;
21 :    
22 :     use strict;
23 :     use Tracer;
24 :     use ERDB;
25 :     use base 'BaseSproutLoader';
26 :    
27 :     =head1 Sprout Synonym Load Group Class
28 :    
29 :     =head2 Introduction
30 :    
31 :     The Synonym Load Group includes all of the major non-redundancy tables.
32 :    
33 :     =head3 new
34 :    
35 : parrello 1.2 my $sl = SynonymSproutLoader->new($erdb, $options, @tables);
36 : parrello 1.1
37 :     Construct a new SynonymSproutLoader object.
38 :    
39 :     =over 4
40 :    
41 :     =item erdb
42 :    
43 :     [[SproutPm]] object for the database being loaded.
44 :    
45 :     =item options
46 :    
47 :     Reference to a hash of command-line options.
48 :    
49 :     =item tables
50 :    
51 :     List of tables in this load group.
52 :    
53 :     =back
54 :    
55 :     =cut
56 :    
57 :     sub new {
58 :     # Get the parameters.
59 : parrello 1.2 my ($class, $erdb, $options) = @_;
60 : parrello 1.1 # Create the table list.
61 : parrello 1.2 my @tables = sort qw(SynonymGroup IsSynonymGroupFor);
62 : parrello 1.1 # Create the BaseSproutLoader object.
63 : parrello 1.2 my $retVal = BaseSproutLoader::new($class, $erdb, $options, @tables);
64 : parrello 1.1 # Return it.
65 :     return $retVal;
66 :     }
67 :    
68 :     =head2 Public Methods
69 :    
70 :     =head3 Generate
71 :    
72 :     $sl->Generate();
73 :    
74 :     Generate the data for the non-redundancy files.
75 :    
76 :     =cut
77 :    
78 :     sub Generate {
79 :     # Get the parameters.
80 :     my ($self) = @_;
81 :     # Get the sprout object.
82 :     my $sprout = $self->db();
83 :     # Get the FIG object.
84 :     my $fig = $self->source();
85 :     # Is this the global section?
86 :     if (! $self->global()) {
87 :     # No, then get the section ID.
88 :     my $genomeID = $self->section();
89 :     # Get the database handle.
90 :     my $dbh = $fig->db_handle();
91 :     # Ask for the synonyms. Note that "maps_to" is a group name, and "syn_id" is a PEG ID or alias.
92 :     my $sth = $dbh->prepare_command("SELECT maps_to, syn_id FROM peg_synonyms WHERE syn_id LIKE ?");
93 : parrello 1.2 my $result = $sth->execute("fig|$genomeID%");
94 : parrello 1.1 if (! defined($result)) {
95 :     Confess("Database error in Synonym load: " . $sth->errstr());
96 :     } else {
97 :     Trace("Processing synonym results for $genomeID.") if T(2);
98 :     # Loop through the synonym/peg pairs.
99 :     while (my @row = $sth->fetchrow()) {
100 :     # Get the synonym group ID and feature ID.
101 :     my ($syn_id, $peg) = @row;
102 :     # Count this row.
103 :     $self->Add('synonyms-read' => 1);
104 :     # Insure it's not deleted.
105 : parrello 1.2 if ($fig->is_deleted_fid($peg)) {
106 : parrello 1.1 $self->Add('synonyms-skipped' => 1);
107 :     } else {
108 :     # Create the group record.
109 :     $self->PutE(SynonymGroup => $syn_id);
110 :     # Connect the synonym to the peg.
111 : parrello 1.2 $self->PutR(IsSynonymGroupFor => $syn_id, $peg);
112 : parrello 1.1 }
113 :     }
114 :     }
115 :     }
116 :     }
117 :    
118 :    
119 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3