30 |
$stats->Accumulate($spl->LoadFeatureData()); |
$stats->Accumulate($spl->LoadFeatureData()); |
31 |
print $stats->Show(); |
print $stats->Show(); |
32 |
|
|
|
This module makes use of the internal Sprout property C<_erdb>. |
|
|
|
|
33 |
It is worth noting that the FIG object does not need to be a real one. Any object |
It is worth noting that the FIG object does not need to be a real one. Any object |
34 |
that implements the FIG methods for data retrieval could be used. So, for example, |
that implements the FIG methods for data retrieval could be used. So, for example, |
35 |
this object could be used to copy data from one Sprout database to another, or |
this object could be used to copy data from one Sprout database to another, or |
93 |
sub new { |
sub new { |
94 |
# Get the parameters. |
# Get the parameters. |
95 |
my ($class, $sprout, $fig, $genomeFile, $subsysFile, $options) = @_; |
my ($class, $sprout, $fig, $genomeFile, $subsysFile, $options) = @_; |
96 |
# Load the list of genomes into a hash. |
# Create the genome hash. |
97 |
my %genomes; |
my %genomes = (); |
98 |
|
# We only need it if load-only is NOT specified. |
99 |
|
if (! $options->{loadOnly}) { |
100 |
if (! defined($genomeFile) || $genomeFile eq '') { |
if (! defined($genomeFile) || $genomeFile eq '') { |
101 |
# Here we want all the complete genomes and an access code of 1. |
# Here we want all the complete genomes and an access code of 1. |
102 |
my @genomeList = $fig->genomes(1); |
my @genomeList = $fig->genomes(1); |
130 |
Confess("Invalid genome parameter ($type) in SproutLoad constructor."); |
Confess("Invalid genome parameter ($type) in SproutLoad constructor."); |
131 |
} |
} |
132 |
} |
} |
133 |
|
} |
134 |
# Load the list of trusted subsystems. |
# Load the list of trusted subsystems. |
135 |
my %subsystems = (); |
my %subsystems = (); |
136 |
|
# We only need it if load-only is NOT specified. |
137 |
|
if (! $options->{loadOnly}) { |
138 |
if (! defined $subsysFile || $subsysFile eq '') { |
if (! defined $subsysFile || $subsysFile eq '') { |
139 |
# Here we want all the NMPDR subsystems. First we get the whole list. |
# Here we want all the NMPDR subsystems. First we get the whole list. |
140 |
my @subs = $fig->all_subsystems(); |
my @subs = $fig->all_subsystems(); |
163 |
Confess("Invalid subsystem parameter in SproutLoad constructor."); |
Confess("Invalid subsystem parameter in SproutLoad constructor."); |
164 |
} |
} |
165 |
} |
} |
166 |
|
} |
167 |
# Get the data directory from the Sprout object. |
# Get the data directory from the Sprout object. |
168 |
my ($directory) = $sprout->LoadInfo(); |
my ($directory) = $sprout->LoadInfo(); |
169 |
# Create the Sprout load object. |
# Create the Sprout load object. |
173 |
subsystems => \%subsystems, |
subsystems => \%subsystems, |
174 |
sprout => $sprout, |
sprout => $sprout, |
175 |
loadDirectory => $directory, |
loadDirectory => $directory, |
176 |
erdb => $sprout->{_erdb}, |
erdb => $sprout, |
177 |
loaders => [], |
loaders => [], |
178 |
options => $options |
options => $options |
179 |
}; |
}; |
764 |
# part of the spreadsheet cell ID. |
# part of the spreadsheet cell ID. |
765 |
for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) { |
for (my $col = 0; defined($roleID = $sub->get_role($col)); $col++) { |
766 |
# Get the features in the spreadsheet cell for this genome and role. |
# Get the features in the spreadsheet cell for this genome and role. |
767 |
my @pegs = $sub->get_pegs_from_cell($row, $col); |
my @pegs = grep { !$fig->is_deleted_fid($_) } $sub->get_pegs_from_cell($row, $col); |
768 |
# Only proceed if features exist. |
# Only proceed if features exist. |
769 |
if (@pegs > 0) { |
if (@pegs > 0) { |
770 |
# Create the spreadsheet cell. |
# Create the spreadsheet cell. |
1032 |
# Loop through the genomes. |
# Loop through the genomes. |
1033 |
for my $genomeID (sort keys %{$genomeHash}) { |
for my $genomeID (sort keys %{$genomeHash}) { |
1034 |
Trace("Processing $genomeID.") if T(3); |
Trace("Processing $genomeID.") if T(3); |
|
# Get the genome's PEGs. |
|
|
my @pegs = $fig->pegs_of($genomeID); |
|
|
for my $peg (@pegs) { |
|
|
Trace("Processing $peg.") if T(4); |
|
1035 |
# Create a hash of timestamps. We use this to prevent duplicate time stamps |
# Create a hash of timestamps. We use this to prevent duplicate time stamps |
1036 |
# from showing up for a single PEG's annotations. |
# from showing up for a single PEG's annotations. |
1037 |
my %seenTimestamps = (); |
my %seenTimestamps = (); |
1038 |
# Loop through the annotations. |
# Get the genome's annotations. |
1039 |
for my $tuple ($fig->feature_annotations($peg, "raw")) { |
my @annotations = $fig->read_all_annotations($genomeID); |
1040 |
my ($fid, $timestamp, $user, $text) = @{$tuple}; |
Trace("Processing annotations.") if T(2); |
1041 |
|
for my $tuple (@annotations) { |
1042 |
|
# Get the annotation tuple. |
1043 |
|
my ($peg, $timestamp, $user, $text) = @{$tuple}; |
1044 |
# Here we fix up the annotation text. "\r" is removed, |
# Here we fix up the annotation text. "\r" is removed, |
1045 |
# and "\t" and "\n" are escaped. Note we use the "s" |
# and "\t" and "\n" are escaped. Note we use the "s" |
1046 |
# modifier so that new-lines inside the text do not |
# modifier so that new-lines inside the text do not |
1055 |
# Here it's a number. We need to insure the one we use to form |
# Here it's a number. We need to insure the one we use to form |
1056 |
# the key is unique. |
# the key is unique. |
1057 |
my $keyStamp = $timestamp; |
my $keyStamp = $timestamp; |
1058 |
while ($seenTimestamps{$keyStamp}) { |
while ($seenTimestamps{"$peg:$keyStamp"}) { |
1059 |
$keyStamp++; |
$keyStamp++; |
1060 |
} |
} |
|
$seenTimestamps{$keyStamp} = 1; |
|
1061 |
my $annotationID = "$peg:$keyStamp"; |
my $annotationID = "$peg:$keyStamp"; |
1062 |
|
$seenTimestamps{$annotationID} = 1; |
1063 |
# Insure the user exists. |
# Insure the user exists. |
1064 |
if (! $users{$user}) { |
if (! $users{$user}) { |
1065 |
$loadSproutUser->Put($user, "SEED user"); |
$loadSproutUser->Put($user, "SEED user"); |
1077 |
} |
} |
1078 |
} |
} |
1079 |
} |
} |
|
} |
|
1080 |
# Finish the load. |
# Finish the load. |
1081 |
my $retVal = $self->_FinishAll(); |
my $retVal = $self->_FinishAll(); |
1082 |
return $retVal; |
return $retVal; |