[Bio] / Sprout / NewStuffCheck.pl Repository:
ViewVC logotype

Annotation of /Sprout/NewStuffCheck.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl -w
2 :    
3 :     =head1 New Stuff Checker
4 :    
5 :     This script compares the genomes, features, and annotations in
6 :     the old and new sprouts and lists the differences.
7 :    
8 : parrello 1.11 The currently-supported command-line options for NewStuffCheck are as follows.
9 : parrello 1.1
10 :     =over 4
11 :    
12 : parrello 1.2 =item summary
13 :    
14 :     Do not display details, only difference summaries.
15 :    
16 : parrello 1.8 =item nofeats
17 :    
18 :     Do not process features.
19 :    
20 : parrello 1.1 =item user
21 :    
22 :     Name suffix to be used for log files. If omitted, the PID is used.
23 :    
24 :     =item trace
25 :    
26 :     Numeric trace level. A higher trace level causes more messages to appear. The
27 :     default trace level is 2. Tracing will be directly to the standard output
28 :     as well as to a C<trace>I<User>C<.log> file in the FIG temporary directory,
29 :     where I<User> is the value of the B<user> option above.
30 :    
31 :     =item sql
32 :    
33 :     If specified, turns on tracing of SQL activity.
34 :    
35 :     =item background
36 :    
37 :     Save the standard and error output to files. The files will be created
38 :     in the FIG temporary directory and will be named C<err>I<User>C<.log> and
39 :     C<out>I<User>C<.log>, respectively, where I<User> is the value of the
40 :     B<user> option above.
41 :    
42 :     =item h
43 :    
44 :     Display this command's parameters and options.
45 :    
46 :     =item phone
47 :    
48 :     Phone number to message when the script is complete.
49 :    
50 : parrello 1.11 =item groupFile
51 :    
52 :     Name of the group file (described below). The default is C<groups.tbl>
53 :     in the Sprout data directory.
54 :    
55 :     =back
56 :    
57 :     =head2 The Group File
58 :    
59 :     A key data file for this process is C<groups.tbl>. This file is kept in the
60 :     Sprout Data directory, and contains the following columns:
61 :    
62 :     =over 4
63 :    
64 :     =item name
65 :    
66 :     Name of the group.
67 :    
68 :     =item page
69 :    
70 :     Name of the group's page on the web site (e.g. C<campy.php> for
71 :     Campylobacter)
72 :    
73 :     =item genus
74 :    
75 :     Genus of the group
76 :    
77 :     =item species
78 :    
79 :     Species of the group, or an empty string if the group is for an entire
80 : parrello 1.13 genus. If the group contains more than one species, the species names
81 :     should be separated by commas.
82 : parrello 1.11
83 : parrello 1.1 =back
84 :    
85 :     =cut
86 :    
87 :     use strict;
88 :     use Tracer;
89 :     use DocUtils;
90 :     use TestUtils;
91 :     use Cwd;
92 :     use File::Copy;
93 :     use File::Path;
94 :     use FIG;
95 :     use SFXlate;
96 :     use Sprout;
97 :    
98 :     # Get the command-line options and parameters.
99 :     my ($options, @parameters) = StandardSetup([qw(Sprout) ],
100 :     {
101 : parrello 1.11 groupFile => ["$FIG_Config::sproutData/groups.tbl", "location of the NMPDR group description file"],
102 : parrello 1.8 nofeats => ["", "if specified, only genome changes will be displayed; otherwise, genome features will be compared and differences shown"],
103 : parrello 1.5 trace => ["2-", "tracing level; use a minus to prevent tracing to standard output"],
104 : parrello 1.2 summary => ["", "if specified, detailed lists of the different items will not be displayed"],
105 : parrello 1.1 phone => ["", "phone number (international format) to call when load finishes"],
106 :     },
107 :     "",
108 :     @ARGV);
109 :     # Set a variable to contain return type information.
110 :     my $rtype;
111 :     # Insure we catch errors.
112 :     eval {
113 : parrello 1.11 # Get the group file.
114 :     my $groupFileName = $options->{groupFile};
115 :     Trace("Reading group file $groupFileName.") if T(2);
116 :     # Well put each group's data into a hash, keyed by group
117 :     # name, each entry being a 3-tuple of page name, genus,
118 :     # and species
119 : parrello 1.13 my %groups = Sprout::ReadGroupFile($groupFileName);
120 : parrello 1.2 Trace("Processing genomes.") if T(2);
121 : parrello 1.8 # Get the current SEED.
122 :     my $fig = FIG->new();
123 : parrello 1.1 # Get the old Sprout.
124 :     my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB);
125 :     # Get its genomes in alphabetical order.
126 : parrello 1.8 my @oldGenomes = GetGenomes($oldSprout);
127 : parrello 1.1 # Get the new Sprout.
128 :     my $newSprout = SFXlate->new_sprout_only();
129 :     # Get its genomes in alphabetical order.
130 : parrello 1.8 my @newGenomes = GetGenomes($newSprout);
131 : parrello 1.7 # Compare the two genomes lists.
132 : parrello 1.1 my ($insertedGenomes, $deletedGenomes) = Tracer::CompareLists(\@newGenomes, \@oldGenomes);
133 : parrello 1.7 # Add feature counts to the new genomes.
134 :     for my $insertedGenome (@{$insertedGenomes}) {
135 :     my $genomeID = $insertedGenome->[0];
136 :     # For a new genome, display the feature count.
137 :     my $count = $newSprout->GetCount(['HasFeature'], "HasFeature(from-link) = ?",
138 :     [$genomeID]);
139 :     my $suffix = ($count == 1 ? " one feature" : "$count features");
140 :     $insertedGenome->[1] .= "($suffix)";
141 :     }
142 : parrello 1.8 # Add information about SEED status to the deleted genomes.
143 :     for my $deletedGenome (@{$deletedGenomes}) {
144 :     my $genomeID = $deletedGenome->[0];
145 :     if ($fig->is_genome($genomeID)) {
146 :     my $complete = ($fig->is_complete($genomeID) ? "complete" : "incomplete");
147 : parrello 1.9 $deletedGenome->[1] .= "(still in SEED, $complete)";
148 : parrello 1.8 }
149 :     }
150 : parrello 1.1 # Display the lists.
151 : parrello 1.2 ShowLists(! $options->{summary},
152 :     'New Genomes' => $insertedGenomes,
153 :     'Deleted Genomes' => $deletedGenomes);
154 : parrello 1.8 # Now the groups.
155 :     Trace("Comparing groups.") if T(2);
156 :     my %oldGroups = $oldSprout->GetGroups();
157 :     my %newGroups = $newSprout->GetGroups();
158 :     # Loop through the new groups.
159 :     for my $newGroup (sort keys %newGroups) {
160 :     Trace("Processing group $newGroup.") if T(3);
161 :     # Find out if this group is new to this version.
162 :     if (! exists $oldGroups{$newGroup}) {
163 :     # Construct a list of this group's genes.
164 :     my @groupGenomes = NameGenomes($newSprout, $newGroups{$newGroup});
165 :     ShowLists(! $options->{summary}, "Genomes in new group $newGroup" => \@groupGenomes);
166 :     } else {
167 :     # Here the group is in both versions. Fix the lists and compare them.
168 :     my @newGroupList = NameGenomes($newSprout, $newGroups{$newGroup});
169 :     my @oldGroupList = NameGenomes($oldSprout, $oldGroups{$newGroup});
170 : parrello 1.10 Trace("Comparing lists for $newGroup.") if T(4);
171 : parrello 1.8 my ($insertedGroupGenomes, $deletedGroupGenomes) = Tracer::CompareLists(\@newGroupList, \@oldGroupList);
172 : parrello 1.10 Trace("Comparison complete.") if T(4);
173 : parrello 1.8 # Delete the old group data. When we're done, this means we'll have a list of the deleted
174 :     # groups.
175 :     delete $oldGroups{$newGroup};
176 :     # Show the lists. Empty lists will not be shown.
177 : parrello 1.10 Trace("Displaying group lists.") if T(4);
178 : parrello 1.8 ShowLists(! $options->{summary},
179 :     "Genomes new to $newGroup" => $insertedGroupGenomes,
180 :     "Genomes no longer in $newGroup" => $deletedGroupGenomes);
181 :     }
182 :     }
183 : parrello 1.10 Trace("Processing deleted groups.") if T(4);
184 : parrello 1.8 # Now list the deleted groups.
185 :     for my $oldGroup (sort keys %oldGroups) {
186 :     Trace("Processing deleted group $oldGroup.") if T(3);
187 :     my @groupGenomes = NameGenomes($oldSprout, $oldGroups{$oldGroup});
188 :     ShowLists(! $options->{summary}, "Genomes in deleted group $oldGroup" => \@groupGenomes);
189 :     }
190 : parrello 1.1 # Next, we get the subsystems.
191 : parrello 1.2 Trace("Processing subsystems.") if T(2);
192 : parrello 1.1 my @oldSubsystems = GetSubsystems($oldSprout);
193 :     my @newSubsystems = GetSubsystems($newSprout);
194 :     # Compare and display the subsystem lists.
195 :     my ($insertedSubs, $deletedSubs) = Tracer::CompareLists(\@newSubsystems, \@oldSubsystems);
196 : parrello 1.8 # Check the deleted subsystems to see if they're in SEED.
197 :     if (scalar @{$deletedSubs} > 0) {
198 :     my %subChecker = map { $_ => 1 } $fig->all_subsystems();
199 :     for my $deletedSub (@{$deletedSubs}) {
200 :     my $subID = $deletedSub->[0];
201 :     if ($subChecker{$subID}) {
202 :     my $trusted = ($fig->usable_subsystem($subID) ? "usable" : "not usable");
203 : parrello 1.9 $deletedSub->[1] .= " (still in SEED, $trusted)";
204 : parrello 1.8 }
205 :     }
206 :     }
207 : parrello 1.2 ShowLists(! $options->{summary},
208 :     'New Subsystems' => $insertedSubs,
209 :     'Deleted Subsystems' => $deletedSubs);
210 : parrello 1.11 # Next, we show some basic counts.
211 :     print "\nStatistics for old Sprout\n\n";
212 :     ShowCounts($oldSprout);
213 :     print "\nStatistics for new Sprout\n\n";
214 :     ShowCounts($newSprout);
215 :     # Now we show the genomes that are not in groups but could be. First, we convert
216 :     # our group hash from the new Sprout into the form used on the web site.
217 :     Trace("Examining possible missing genomes in groups.") if T(2);
218 :     my %fixedGroups = Sprout::Fix(%newGroups);
219 :     for my $group (sort keys %groups) {
220 :     Trace("Checking group $group.");
221 :     # Get this group's genus and species.
222 :     my $genus = $groups{$group}->[1];
223 :     my $species = $groups{$group}->[2];
224 :     # Get a hash of the genomes already in it.
225 :     my %inGroup = map { $_ => 1 } @{$fixedGroups{$group}};
226 :     # Get a list of its possible genomes.
227 :     my $filter = 'Genome(genus) = ?';
228 :     my @parms = ($genus);
229 : parrello 1.13 # The species list is tricky because a given group may involve more than
230 :     # one target species. The species names will be comma-separated, and
231 :     # we use some PERL trickiness to generate an OR filter for them.
232 : parrello 1.11 if ($species) {
233 : parrello 1.13 # Get the individual species.
234 :     my @speciesList = split /\s*,\s*/, $species;
235 :     # Create one species filter per species.
236 :     my @filterClauses = map { 'Genome(species) = ?' } @speciesList;
237 :     # OR the filter clauses together to get a real filter.
238 :     $filter .= " AND (" . (join " OR ", @filterClauses) . ")";
239 :     # Add the specieis names to the SQL parameter list.
240 :     push @parms, @speciesList;
241 : parrello 1.11 }
242 :     my @possibles = $newSprout->GetFlat(['Genome'], $filter, \@parms, 'Genome(id)');
243 :     # Get the possibles that aren't in the group and add identifying information.
244 : parrello 1.12 my @leftOut = NameGenomes($newSprout, [ grep { ! exists $inGroup{$_} } @possibles ]);
245 : parrello 1.11 # If anything survived, show the list.
246 :     if (@leftOut) {
247 :     ShowLists(! $options->{summary}, "Candidates for $group" => \@leftOut);
248 :     }
249 :     }
250 :     # Compare the property tables.
251 :     Trace("Comparing properties.") if T(2);
252 :     # Set up lists of all the properties in each sprout.
253 :     my @oldProps = GetProperties($oldSprout);
254 :     my @newProps = GetProperties($newSprout);
255 :     # Compare the lists.
256 :     my ($insertedProps, $deletedProps) = Tracer::CompareLists(\@oldProps, \@newProps);
257 :     # Now get all the properties in the new Sprout without any features.
258 :     my @emptyProps = grep { $_->[1] == 0 } @newProps;
259 :     # Show what we've found.
260 :     ShowLists(! $options->{summary}, 'New Properties' => $insertedProps,
261 :     'Deleted Properties' => $deletedProps,
262 :     'Empty Properties' => \@emptyProps);
263 : parrello 1.8 # Now we process the features of the common genes.
264 :     if (! $options->{nofeats}) {
265 :     # First we need a hash of the inserted stuff so we know to skip it.
266 :     my %skipGenomes = map { $_->[0] => 1 } @{$insertedGenomes};
267 :     # Loop through the genomees.
268 :     for my $genome (@newGenomes) {
269 :     # Get the ID and name.
270 :     my ($genomeID, $genomeName) = @{$genome};
271 :     Trace("Processing $genomeID.") if T(3);
272 :     # Only process the common genes.
273 :     if (! $skipGenomes{$genomeID}) {
274 :     # Compare the genome group information.
275 :     # Get the new and old features. This will be very stressful to the machine,
276 :     # because there are lots of features.
277 :     my @oldFeatures = GetFeatures($oldSprout, $genomeID);
278 :     my @newFeatures = GetFeatures($newSprout, $genomeID);
279 :     Trace("Comparing features for $genomeID.") if T(3);
280 :     # Compare the lists.
281 :     my ($insertedFeatures, $deletedFeatures) = Tracer::CompareLists(\@newFeatures, \@oldFeatures);
282 :     # Display the lists. Only nonempty lists are displayed; however, we do a check
283 :     # first anyway so the trace tells us what's happening.
284 :     if (scalar @{$insertedFeatures} + scalar @{$deletedFeatures} > 0) {
285 :     Trace("Displaying feature differences.") if T(3);
286 :     ShowLists(! $options->{summary},
287 :     "New Features for $genomeID" => $insertedFeatures,
288 :     "Features Deleted from $genomeID" => $deletedFeatures);
289 :     }
290 : parrello 1.1 }
291 :     }
292 :     }
293 :     };
294 :     if ($@) {
295 :     Trace("Script failed with error: $@") if T(0);
296 :     $rtype = "error";
297 :     } else {
298 :     Trace("Script complete.") if T(2);
299 :     $rtype = "no error";
300 :     }
301 :     if ($options->{phone}) {
302 : parrello 1.11 my $msgID = Tracer::SendSMS($options->{phone}, "New Stuff Checker terminated with $rtype.");
303 : parrello 1.1 if ($msgID) {
304 :     Trace("Phone message sent with ID $msgID.") if T(2);
305 :     } else {
306 :     Trace("Phone message not sent.") if T(2);
307 :     }
308 :     }
309 :    
310 : parrello 1.8 =head3 GetGenomes
311 : parrello 1.1
312 : parrello 1.8 C<< my @geneList = GetGenomes($sprout); >>
313 : parrello 1.1
314 :     Return a list of the genomes in the specified Sprout instance. The genomes
315 :     are returned in alphabetical order by genome ID.
316 :    
317 :     =over 4
318 :    
319 :     =item sprout
320 :    
321 :     Sprout instance whose gene list is desired.
322 :    
323 :     =item RETURN
324 :    
325 :     Returns a list of two-tuples. The first element in each tuple is the genome ID,
326 :     and the second is the genome name (genus, species, strain).
327 :    
328 :     =back
329 :    
330 :     =cut
331 :    
332 : parrello 1.8 sub GetGenomes {
333 : parrello 1.1 # Get the parameters.
334 :     my ($sprout) = @_;
335 :     # Get the desired data.
336 :     my @genomes = $sprout->GetAll(['Genome'], "ORDER BY Genome(id)", [], ['Genome(id)',
337 :     'Genome(genus)',
338 :     'Genome(species)',
339 :     'Genome(unique-characterization)']);
340 :     # Create the genome names from the three pieces of the name.
341 :     my @retVal = map { [$_->[0], join(" ", @{$_}[1..3])] } @genomes;
342 :     # Return the result.
343 :     return @retVal;
344 :     }
345 :    
346 : parrello 1.8 =head3 NameGenomes
347 :    
348 : parrello 1.11 C<< my @newList = NameGenomes($sprout, \@genomes); >>
349 : parrello 1.8
350 :     Convert a list of genome IDs to a list of genome IDs with names.
351 :    
352 :     =over 4
353 :    
354 :     =item sprout
355 :    
356 :     The relevant sprout instance.
357 :    
358 :     =item genomes
359 :    
360 :     Reference to a list of genome IDs
361 :    
362 :     =item RETURN
363 :    
364 :     Returns a list of 2-tuples, each tuple consisting of a genome ID followed by a
365 :     genome name.
366 :    
367 :     =back
368 :    
369 :     =cut
370 :    
371 :     sub NameGenomes {
372 :     # Get the parameters.
373 :     my ($sprout, $genomes) = @_;
374 :     # Attach the names.
375 :     my @retVal = map { [$_, $sprout->GenusSpecies($_) ] } @{$genomes};
376 :     # Return the result.
377 :     return @retVal;
378 :     }
379 :    
380 : parrello 1.1 =head3 GetSubsystems
381 :    
382 :     C<< my @subsystems = GetSubsystems($sprout); >>
383 :    
384 :     Get a list of the subsystems in the specified Sprout instance.
385 :    
386 :     =over 4
387 :    
388 :     =item sprout
389 :    
390 :     Sprout instance whose subsystems are desired.
391 :    
392 :     =item RETURN
393 :    
394 :     Returns a list of 2-tuples, each consisting of the subsystem name followed by
395 :     the name of the curator.
396 :    
397 :     =back
398 :    
399 :     =cut
400 :    
401 :     sub GetSubsystems {
402 :     # Get the parameters.
403 :     my ($sprout) = @_;
404 :     # Declare the return variable.
405 :     my @retVal = $sprout->GetAll(['Subsystem'], "ORDER BY Subsystem(id)",
406 :     [], ['Subsystem(id)', 'Subsystem(curator)']);
407 :     # Return the result.
408 :     return @retVal;
409 :     }
410 :    
411 : parrello 1.11 =head3 GetProperties
412 :    
413 :     C<< my @propertyList = GetProperties($sprout); >>
414 :    
415 :     Return a list of properties. Each element in the list will be a 2-tuple containing
416 :     the property name and value in the first column and its ID in the second column.
417 :    
418 :     =over 4
419 :    
420 :     =item sprout
421 :    
422 :     Sprout instance to be used to retrieve the properties.
423 :    
424 :     =item RETURN
425 :    
426 :     Returns a list of 2-tuples. The first element in each 2-tuple will be a string
427 :     in the form of an assignment of the property value to the property name. The second
428 :     element will be the number of features possessing the property. The list will be
429 :     sorted in ascending alphabetical order.
430 :    
431 :     =back
432 :    
433 :     =cut
434 :    
435 :     sub GetProperties {
436 :     # Get the parameters.
437 :     my ($sprout) = @_;
438 :     # Get the properties.
439 :     my @props = $sprout->GetAll(['Property'],
440 :     "ORDER BY Property(property-name), Property(property-value)", [],
441 :     ['Property(property-name)', 'Property(property-value)', 'Property(id)']);
442 :     # Combine the property names and values and replace each property ID by a feature count.
443 :     my @retVal;
444 :     for my $propItem (@props) {
445 :     my $label = $propItem->[0] . " = " . $propItem->[1];
446 :     my $count = $sprout->GetCount(['Feature', 'HasProperty'], "HasProperty(to-link) = ?",
447 :     [$propItem->[2]]);
448 :     push @retVal, [$label, $count];
449 :     }
450 :     # Return the result.
451 :     return @retVal;
452 :     }
453 :    
454 : parrello 1.1 =head3 GetFeatures
455 :    
456 :     C<< my @features = GetFeatures($sprout, $genomeID); >>
457 :    
458 :     Return the features of the specified genome in the specified Sprout instance.
459 :    
460 :     =over 4
461 :    
462 :     =item sprout
463 :    
464 :     Sprout instance to use to get the features.
465 :    
466 :     =item genomeID
467 :    
468 :     ID of the genome in question.
469 :    
470 :     =item RETURN
471 :    
472 :     Returns a list of 2-tuples, the first element being the feature ID and the second its
473 :     functional assignment (if any).
474 :    
475 :     =back
476 :    
477 :     =cut
478 :    
479 :     sub GetFeatures {
480 :     # Get the parameters.
481 :     my ($sprout, $genomeID) = @_;
482 :     # Get a list of the feature IDs and map them to their functional assignments.
483 :     my @retVal = map { [$_, $sprout->FunctionOf($_)] } $sprout->GetFlat(['HasFeature'],
484 :     "HasFeature(from-link) = ? ORDER BY HasFeature(to-link)",
485 :     [$genomeID], 'HasFeature(to-link)');
486 :     # Return the result.
487 :     return @retVal;
488 :     }
489 :    
490 :     =head3 ShowLists
491 :    
492 : parrello 1.2 C<< ShowLists($all, %lists); >>
493 : parrello 1.1
494 : parrello 1.2 Display a set of lists. Each list should consist of 2-tuples.
495 : parrello 1.1
496 :     =over 4
497 :    
498 : parrello 1.2 =item all
499 :    
500 :     TRUE if details should be displayed; FALSE if only summaries should be displayed.
501 :    
502 : parrello 1.1 =item lists
503 :    
504 :     A hash mapping list names to list references.
505 :    
506 :     =cut
507 :    
508 :     sub ShowLists {
509 :     # Get the parameters.
510 : parrello 1.2 my $all = shift @_;
511 : parrello 1.1 my %lists = @_;
512 :     # Loop through the lists in alphabetical order by list name.
513 : parrello 1.6 for my $listName (sort keys %lists) {
514 : parrello 1.1 # Get the list itself.
515 :     my $list = $lists{$listName};
516 :     # Get the number of list items.
517 :     my $listSize = scalar @{$list};
518 : parrello 1.6 # Only proceed if the list is nonempty.
519 :     if ($listSize > 0) {
520 : parrello 1.7 my $header = ShowHeader($listName, $listSize);
521 : parrello 1.6 print "$header\n";
522 :     Trace($header) if T(3);
523 :     # If we're at trace level 3, display the list.
524 :     if ($all) {
525 :     # Put a spacer under the title.
526 :     print "\n";
527 :     # Get the width of the name column.
528 :     my $width = 0;
529 :     for my $entryLen (map { length $_->[0] } @{$list}) {
530 :     $width = $entryLen if $entryLen > $width;
531 :     }
532 :     # Now display the list.
533 :     for my $entry (@{$list}) {
534 :     my ($name, $data) = @{$entry};
535 :     print " $name" . (" " x ($width - length $name)) . " $data\n";
536 :     }
537 :     print "\n\n";
538 : parrello 1.1 }
539 :     }
540 :     }
541 :     }
542 :    
543 : parrello 1.7 =head3 ShowHeader
544 :    
545 :     C<< my $header = ShowHeader($name, $count); >>
546 :    
547 :     Return a list header for a list of the specified length.
548 :    
549 :     =over 4
550 :    
551 :     =item name
552 :    
553 :     Name of the list.
554 :    
555 :     =item count
556 :    
557 :     Number of entries in the list.
558 :    
559 :     =item RETURN
560 :    
561 :     Returns a list header that shows the name of the list and the number of entries.
562 :    
563 :     =back
564 :    
565 :     =cut
566 :    
567 :     sub ShowHeader {
568 :     # Get the parameters.
569 :     my ($name, $count) = @_;
570 :     # Declare the return variable.
571 :     my $retVal;
572 :     if ($count == 0) {
573 :     $retVal = "*** $name: none";
574 :     } elsif ($count == 1) {
575 :     $retVal = "*** $name: one";
576 :     } else {
577 :     $retVal = "*** $name: $count";
578 :     }
579 :     # Return the result.
580 :     return $retVal;
581 :     }
582 :    
583 : parrello 1.11 =head3 ShowCounts
584 :    
585 :     C<< ShowCounts($sprout); >>
586 :    
587 :     Display general counts for the specified sprout instance. These counts are
588 :     used in progress reports.
589 :    
590 :     =over 4
591 :    
592 :     =item sprout
593 :    
594 :     Sprout instance for which counts are to be produced.
595 :    
596 :     =back
597 :    
598 :     =cut
599 :    
600 :     sub ShowCounts {
601 :     # Get the parameters.
602 :     my ($sprout) = @_;
603 :     # Count genomes and subsystems.
604 :     my $genomes = $sprout->GetCount(['Genome']);
605 :     my $subsystems = $sprout->GetCount(['Subsystem']);
606 :     # Count roles, external functional assignments, and functional couplings.
607 :     my $roles = $sprout->GetCount(['OccursInSubsystem']);
608 :     my $funcs = $sprout->GetCount(['ExternalAliasFunc']);
609 :     my $couples = $sprout->GetCount(['Coupling']);
610 :     # Count features and BBHs.
611 :     my $bbhs = int ($sprout->GetCount(['IsBidirectionalBestHitOf']) / 2);
612 :     my $features = $sprout->GetCount(['Feature']);
613 :     # Display the counts.
614 :     print "Genomes = $genomes.\n";
615 :     print "Subsystems = $subsystems.\n";
616 :     print "Roles = $roles.\n";
617 :     print "External function assignments = $funcs.\n";
618 :     print "Features = $features.\n";
619 :     print "Bidirectional Best Hits = $bbhs.\n";
620 :     print "Functional couplings = $couples.\n";
621 :     print "\n";
622 :     }
623 : parrello 1.1 1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3