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

Annotation of /Sprout/BaseSaplingLoader.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 BaseSaplingLoader;
21 :    
22 :     use strict;
23 :     use Tracer;
24 :     use ERDB;
25 :     use FIG;
26 :     use Time::HiRes;
27 :     use base 'ERDBLoadGroup';
28 :    
29 :     # Name of the global section
30 :     use constant GLOBAL => 'Globals';
31 :    
32 :     =head1 Sapling Load Group Base Class
33 :    
34 :     =head2 Introduction
35 :    
36 :     This is the base class for all the Sapling loaders. It performs common tasks
37 :     required by multiple load groups.
38 :    
39 :     =head3 new
40 :    
41 :     my $sl = BaseSaplingLoader->new($erdb, $options, @tables);
42 :    
43 :     Construct a new BaseSaplingLoader object.
44 :    
45 :     =over 4
46 :    
47 :     =item erdb
48 :    
49 :     [[SaplingPm]] object for the database being loaded.
50 :    
51 :     =item source
52 :    
53 :     [[FigPm]] object used to access the source data.
54 :    
55 :     =item options
56 :    
57 :     Reference to a hash of command-line options.
58 :    
59 :     =item tables
60 :    
61 :     List of tables in this load group.
62 :    
63 :     =back
64 :    
65 :     =cut
66 :    
67 :     sub new {
68 :     # Get the parameters.
69 :     my ($class, $erdb, $options, @tables) = @_;
70 :     # Create the base load group object.
71 :     my $retVal = ERDBLoadGroup::new($class, $erdb, $options, @tables);
72 :     # Return it.
73 :     return $retVal;
74 :     }
75 :    
76 :    
77 :     =head2 Public Methods
78 :    
79 :     =head3 global
80 :    
81 :     my $flag = $sl->global();
82 :    
83 :     Return TRUE if the current section is the global section.
84 :    
85 :     =cut
86 :    
87 :     sub global {
88 :     my ($self) = @_;
89 :     # Get the database.
90 :     my $sapling = $self->db();
91 :     # Get the section ID.
92 :     my $section = $self->section();
93 :     # Ask the DB object if this is the global section.
94 :     return $sapling->GlobalSection($section);
95 :     }
96 :    
97 :     =head3 Starless
98 :    
99 : parrello 1.2 my $adjusted = BaseSaplingLoader::Starless($codeString);
100 : parrello 1.1
101 :     Remove any spaces and leading or trailing asterisks from the incoming string and
102 :     return the result.
103 :    
104 :     =over 4
105 :    
106 :     =item codeString
107 :    
108 :     Input string that needs to have the asterisks trimmed.
109 :    
110 :     =item RETURN
111 :    
112 :     Returns the incoming string with spaces and leading and trailing asterisks
113 :     removed.
114 :    
115 :     =back
116 :    
117 :     =cut
118 :    
119 :     sub Starless {
120 :     # Get the parameters.
121 : parrello 1.2 my ($codeString) = @_;
122 : parrello 1.1 # Declare the return variable.
123 :     my $retVal = $codeString;
124 :     # Remove the spaces.
125 : parrello 1.2 $retVal =~ s/\s+//g;
126 : parrello 1.1 # Trim the asterisks.
127 :     $retVal =~ s/^\*+//;
128 :     $retVal =~ s/\*+$//;
129 :     # Return the result.
130 :     return $retVal;
131 :     }
132 :    
133 :     =head3 AnalyzeSubsystemName
134 :    
135 :     my ($subsystemName, $subsystemID) = $sl->AnalyzeSubsystemName($rawSubsystemName);
136 :    
137 :     This method will analyze the name of a subsystem, computing from it the
138 :     display name and its ID for use in the database. The display name has
139 :     underscores converted to spaces, and the ID is an MD5 digest.
140 :    
141 :     =over 4
142 :    
143 :     =item rawSubsystemName
144 :    
145 :     The raw name of the subsystem.
146 :    
147 :     =item RETURN
148 :    
149 :     Returns a two-element list, the first element being the subsystem's display
150 :     name, and the second its ID.
151 :    
152 :     =back
153 :    
154 :     =cut
155 :    
156 :     sub AnalyzeSubsystemName {
157 :     # Get the parameters.
158 :     my ($self, $rawSubsystemName) = @_;
159 :     # Compute the subsystem's display name.
160 :     my $subsystemName = $rawSubsystemName;
161 :     $subsystemName =~ tr/_/ /;
162 :     # Compute the ID.
163 :     my $subsystemID = $self->db()->SubsystemID($rawSubsystemName);
164 :     # Return the results.
165 :     return ($subsystemName, $subsystemID);
166 :     }
167 :    
168 :    
169 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3