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

Annotation of /Sprout/SaplingPerformer.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : parrello 1.1 #!/usr/bin/perl
2 :     use strict;
3 :    
4 :     # Script for testing ERDB performance.
5 :    
6 :     use Sapling;
7 :     use SeedUtils;
8 :     use Tracer;
9 :     use Time::HiRes;
10 :     use Stats;
11 :    
12 :     # Set up tracing and backgrounding.
13 :     my ($options, $mode) = StandardSetup([qw(ERDB)], {}, "", @ARGV);
14 :     # Get a statistics object.
15 :     my $stats = Stats->new();
16 :     # Get the Sapling DB.
17 :     my $sap = Sapling->new();
18 :     if ($mode eq 'stream') {
19 :     ## METADATA STORAGE TEST
20 :     require FreezeThaw;
21 :     require XML::Simple;
22 :     require YAML;
23 :     # Get the metadata.
24 :     my $metaData = $sap->{_metaData};
25 :     # Freeze it.
26 :     my $frozen = FreezeThaw::freeze($metaData);
27 :     # Thaw it 50 times.
28 :     my $count = 50;
29 :     Trace("FreezeThaw test.") if T(2);
30 :     my $start = time();
31 :     while ($count-- > 0) {
32 :     my $thawed = FreezeThaw::thaw($frozen);
33 :     }
34 :     $stats->Add(ThawTime => time() - $start);
35 :     $stats->Add(FrozenLen => length($frozen));
36 :     # Unparse it.
37 :     my $xml = XML::Simple::XMLout($metaData);
38 :     # Parse it 50 times.
39 :     $count = 50;
40 :     Trace("XMLin test.") if T(2);
41 :     $start = time();
42 :     while ($count-- > 0) {
43 :     my $parsed = XML::Simple::XMLin($xml);
44 :     }
45 :     $stats->Add(ParseTime => time() - $start);
46 :     $stats->Add(XmlLen => length($xml));
47 :     # Dump it.
48 :     my $yaml = YAML::Dump($metaData);
49 :     # Load it 50 times.
50 :     $count = 50;
51 :     Trace("YAML test.") if T(2);
52 :     $start = time();
53 :     while ($count-- > 0) {
54 :     my $loaded = YAML::Load($yaml);
55 :     }
56 :     $stats->Add(LoadTime => time() - $start);
57 :     $stats->Add(YamlLen => length($yaml));
58 :     # Display the results.
59 :     Trace("Statistics for test:\n" . $stats->Show()) if T(2);
60 :     } else {
61 :     ## NORMAL DATABASE TEST
62 :     # Get all protein features of the Campy genome.
63 :     Trace("Reading genome features.") if T(2);
64 :     my @feats = $sap->GetAll('Genome IsOwnerOf Feature Produces ProteinSequence',
65 :     'Genome(id) = ?', [360108.3], [qw(Feature(id)
66 :     Feature(function)
67 :     Feature(sequence-length)
68 :     ProteinSequence(sequence))]);
69 :     # Loop through the features, getting the locations of the hypotheticals.
70 :     Trace("Processing hypotheticals.") if T(2);
71 :     for my $featData (@feats) {
72 :     my ($fid, $function) = @$featData;
73 :     if (hypo($function)) {
74 :     my @locs = $sap->GetLocations($fid);
75 :     my $loc = join(", ", @locs);
76 :     print join("\t", $fid, $function, $loc->String()) . "\n";
77 :     }
78 :     }
79 :     }
80 :     # All Done.
81 :     Trace("All Done.") if T(2);
82 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3