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

Annotation of /Sprout/AnnotationSproutLoader.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 AnnotationSproutLoader;
21 :    
22 :     use strict;
23 :     use Tracer;
24 :     use ERDB;
25 :     use base 'BaseSproutLoader';
26 :    
27 :     =head1 Sprout Annotation Load Group Class
28 :    
29 :     =head2 Introduction
30 :    
31 :     The Load Group includes all of the major annotation data tables.
32 :    
33 :     =head3 new
34 :    
35 :     my $sl = SproutLoader->new($erdb, $source, $options, @tables);
36 :    
37 :     Construct a new SproutLoader 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 :     my @tables = sort qw(Annotation IsTargetOfAnnotation SproutUser MadeAnnotation);
62 :     # 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 annotation data 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 :     # Check for global mode.
86 :     if ($self->global()) {
87 :     # In global mode, we create the built-in users.
88 :     Trace("Creating default users.") if T(3);
89 :     $self->PutE(SproutUser => "FIG", description => "Fellowship for Interpretation of Genomes");
90 :     $self->PutE(SproutUser => "FIG", description => "Fellowship for Interpretation of Genomes");
91 :     } else {
92 :     # Get the section ID, which is the relevant genome.
93 :     my $genomeID = $self->section();
94 :     # Process the annotations for the specified genome.
95 :     # Get the current time.
96 :     my $time = time();
97 :     # Create a hash of timestamps. We use this to prevent duplicate time stamps
98 :     # from showing up for a single PEG's annotations.
99 :     my %seenTimestamps = ();
100 :     # Get the genome's annotations.
101 :     my @annotations = $fig->read_all_annotations($genomeID);
102 :     Trace("Processing annotations.") if T(2);
103 :     for my $tuple (@annotations) {
104 :     # Get the annotation tuple.
105 :     my ($peg, $timestamp, $user, $text) = @{$tuple};
106 :     # Change assignments by the master user to FIG assignments.
107 :     $text =~ s/Set master function/Set FIG function/s;
108 :     # Insure the time stamp is valid.
109 :     if ($timestamp =~ /^\d+$/) {
110 :     # Here it's a number. We need to insure the one we use to form
111 :     # the key is unique.
112 :     my $keyStamp = $timestamp;
113 :     while ($seenTimestamps{"$peg:$keyStamp"}) {
114 :     $keyStamp++;
115 :     }
116 :     my $annotationID = "$peg:$keyStamp";
117 :     $seenTimestamps{$annotationID} = 1;
118 :     # Insure the user exists.
119 : parrello 1.2 $self->PutE(SproutUser => $user, description => "SEED user");
120 : parrello 1.1 # Generate the annotation.
121 : parrello 1.2 $self->PutE(Annotation => $annotationID, time => $timestamp,
122 : parrello 1.1 annotation => $text);
123 :     $self->PutR(IsTargetOfAnnotation => $peg, $annotationID);
124 :     $self->PutR(MadeAnnotation => $user, $annotationID);
125 :     } else {
126 :     # Here we have an invalid time stamp.
127 :     Trace("Invalid time stamp \"$timestamp\" in annotations for $peg.") if T(1);
128 :     }
129 :     }
130 :     }
131 :     }
132 :    
133 :    
134 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3