13 |
|
|
14 |
Do not display details, only difference summaries. |
Do not display details, only difference summaries. |
15 |
|
|
16 |
|
=item nofeats |
17 |
|
|
18 |
|
Do not process features. |
19 |
|
|
20 |
=item user |
=item user |
21 |
|
|
22 |
Name suffix to be used for log files. If omitted, the PID is used. |
Name suffix to be used for log files. If omitted, the PID is used. |
65 |
# Get the command-line options and parameters. |
# Get the command-line options and parameters. |
66 |
my ($options, @parameters) = StandardSetup([qw(Sprout) ], |
my ($options, @parameters) = StandardSetup([qw(Sprout) ], |
67 |
{ |
{ |
68 |
|
nofeats => ["", "if specified, only genome changes will be displayed; otherwise, genome features will be compared and differences shown"], |
69 |
trace => ["2-", "tracing level; use a minus to prevent tracing to standard output"], |
trace => ["2-", "tracing level; use a minus to prevent tracing to standard output"], |
70 |
summary => ["", "if specified, detailed lists of the different items will not be displayed"], |
summary => ["", "if specified, detailed lists of the different items will not be displayed"], |
71 |
phone => ["", "phone number (international format) to call when load finishes"], |
phone => ["", "phone number (international format) to call when load finishes"], |
77 |
# Insure we catch errors. |
# Insure we catch errors. |
78 |
eval { |
eval { |
79 |
Trace("Processing genomes.") if T(2); |
Trace("Processing genomes.") if T(2); |
80 |
|
# Get the current SEED. |
81 |
|
my $fig = FIG->new(); |
82 |
# Get the old Sprout. |
# Get the old Sprout. |
83 |
my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB); |
my $oldSprout = SFXlate->new_sprout_only($FIG_Config::oldSproutDB); |
84 |
# Get its genomes in alphabetical order. |
# Get its genomes in alphabetical order. |
85 |
my @oldGenomes = GetGenes($oldSprout); |
my @oldGenomes = GetGenomes($oldSprout); |
86 |
# Get the new Sprout. |
# Get the new Sprout. |
87 |
my $newSprout = SFXlate->new_sprout_only(); |
my $newSprout = SFXlate->new_sprout_only(); |
88 |
# Get its genomes in alphabetical order. |
# Get its genomes in alphabetical order. |
89 |
my @newGenomes = GetGenes($newSprout); |
my @newGenomes = GetGenomes($newSprout); |
90 |
# Compare the two genomes lists. |
# Compare the two genomes lists. |
91 |
my ($insertedGenomes, $deletedGenomes) = Tracer::CompareLists(\@newGenomes, \@oldGenomes); |
my ($insertedGenomes, $deletedGenomes) = Tracer::CompareLists(\@newGenomes, \@oldGenomes); |
92 |
# Add feature counts to the new genomes. |
# Add feature counts to the new genomes. |
98 |
my $suffix = ($count == 1 ? " one feature" : "$count features"); |
my $suffix = ($count == 1 ? " one feature" : "$count features"); |
99 |
$insertedGenome->[1] .= "($suffix)"; |
$insertedGenome->[1] .= "($suffix)"; |
100 |
} |
} |
101 |
|
# Add information about SEED status to the deleted genomes. |
102 |
|
for my $deletedGenome (@{$deletedGenomes}) { |
103 |
|
my $genomeID = $deletedGenome->[0]; |
104 |
|
if ($fig->is_genome($genomeID)) { |
105 |
|
my $complete = ($fig->is_complete($genomeID) ? "complete" : "incomplete"); |
106 |
|
$deletedGenome->[1] .= " still in SEED, $complete"; |
107 |
|
} |
108 |
|
} |
109 |
# Display the lists. |
# Display the lists. |
110 |
ShowLists(! $options->{summary}, |
ShowLists(! $options->{summary}, |
111 |
'New Genomes' => $insertedGenomes, |
'New Genomes' => $insertedGenomes, |
112 |
'Deleted Genomes' => $deletedGenomes); |
'Deleted Genomes' => $deletedGenomes); |
113 |
|
# Now the groups. |
114 |
|
Trace("Comparing groups.") if T(2); |
115 |
|
my %oldGroups = $oldSprout->GetGroups(); |
116 |
|
my %newGroups = $newSprout->GetGroups(); |
117 |
|
# Loop through the new groups. |
118 |
|
for my $newGroup (sort keys %newGroups) { |
119 |
|
Trace("Processing group $newGroup.") if T(3); |
120 |
|
# Find out if this group is new to this version. |
121 |
|
if (! exists $oldGroups{$newGroup}) { |
122 |
|
# Construct a list of this group's genes. |
123 |
|
my @groupGenomes = NameGenomes($newSprout, $newGroups{$newGroup}); |
124 |
|
ShowLists(! $options->{summary}, "Genomes in new group $newGroup" => \@groupGenomes); |
125 |
|
} else { |
126 |
|
# Here the group is in both versions. Fix the lists and compare them. |
127 |
|
my @newGroupList = NameGenomes($newSprout, $newGroups{$newGroup}); |
128 |
|
my @oldGroupList = NameGenomes($oldSprout, $oldGroups{$newGroup}); |
129 |
|
my ($insertedGroupGenomes, $deletedGroupGenomes) = Tracer::CompareLists(\@newGroupList, \@oldGroupList); |
130 |
|
# Delete the old group data. When we're done, this means we'll have a list of the deleted |
131 |
|
# groups. |
132 |
|
delete $oldGroups{$newGroup}; |
133 |
|
# Show the lists. Empty lists will not be shown. |
134 |
|
ShowLists(! $options->{summary}, |
135 |
|
"Genomes new to $newGroup" => $insertedGroupGenomes, |
136 |
|
"Genomes no longer in $newGroup" => $deletedGroupGenomes); |
137 |
|
} |
138 |
|
} |
139 |
|
# Now list the deleted groups. |
140 |
|
for my $oldGroup (sort keys %oldGroups) { |
141 |
|
Trace("Processing deleted group $oldGroup.") if T(3); |
142 |
|
my @groupGenomes = NameGenomes($oldSprout, $oldGroups{$oldGroup}); |
143 |
|
ShowLists(! $options->{summary}, "Genomes in deleted group $oldGroup" => \@groupGenomes); |
144 |
|
} |
145 |
# Next, we get the subsystems. |
# Next, we get the subsystems. |
146 |
Trace("Processing subsystems.") if T(2); |
Trace("Processing subsystems.") if T(2); |
147 |
my @oldSubsystems = GetSubsystems($oldSprout); |
my @oldSubsystems = GetSubsystems($oldSprout); |
148 |
my @newSubsystems = GetSubsystems($newSprout); |
my @newSubsystems = GetSubsystems($newSprout); |
149 |
# Compare and display the subsystem lists. |
# Compare and display the subsystem lists. |
150 |
my ($insertedSubs, $deletedSubs) = Tracer::CompareLists(\@newSubsystems, \@oldSubsystems); |
my ($insertedSubs, $deletedSubs) = Tracer::CompareLists(\@newSubsystems, \@oldSubsystems); |
151 |
|
# Check the deleted subsystems to see if they're in SEED. |
152 |
|
if (scalar @{$deletedSubs} > 0) { |
153 |
|
my %subChecker = map { $_ => 1 } $fig->all_subsystems(); |
154 |
|
for my $deletedSub (@{$deletedSubs}) { |
155 |
|
my $subID = $deletedSub->[0]; |
156 |
|
if ($subChecker{$subID}) { |
157 |
|
my $trusted = ($fig->usable_subsystem($subID) ? "usable" : "not usable"); |
158 |
|
$deletedSub->[1] .= ", still in SEED, $trusted"; |
159 |
|
} |
160 |
|
} |
161 |
|
} |
162 |
ShowLists(! $options->{summary}, |
ShowLists(! $options->{summary}, |
163 |
'New Subsystems' => $insertedSubs, |
'New Subsystems' => $insertedSubs, |
164 |
'Deleted Subsystems' => $deletedSubs); |
'Deleted Subsystems' => $deletedSubs); |
165 |
# Now we process the features of the common genes. First we need a hash |
# Now we process the features of the common genes. |
166 |
# of the inserted stuff so we know to skip it. |
if (! $options->{nofeats}) { |
167 |
my %skipGenes = map { $_->[0] => 1 } @{$insertedGenomes}; |
# First we need a hash of the inserted stuff so we know to skip it. |
168 |
|
my %skipGenomes = map { $_->[0] => 1 } @{$insertedGenomes}; |
169 |
# Loop through the genomees. |
# Loop through the genomees. |
170 |
for my $genome (@newGenomes) { |
for my $genome (@newGenomes) { |
171 |
# Get the ID and name. |
# Get the ID and name. |
172 |
my ($genomeID, $genomeName) = @{$genome}; |
my ($genomeID, $genomeName) = @{$genome}; |
173 |
Trace("Processing $genomeID.") if T(3); |
Trace("Processing $genomeID.") if T(3); |
174 |
# Only process the common genes. |
# Only process the common genes. |
175 |
if (! $skipGenes{$genomeID}) { |
if (! $skipGenomes{$genomeID}) { |
176 |
|
# Compare the genome group information. |
177 |
# Get the new and old features. This will be very stressful to the machine, |
# Get the new and old features. This will be very stressful to the machine, |
178 |
# because there are lots of features. |
# because there are lots of features. |
179 |
my @oldFeatures = GetFeatures($oldSprout, $genomeID); |
my @oldFeatures = GetFeatures($oldSprout, $genomeID); |
181 |
Trace("Comparing features for $genomeID.") if T(3); |
Trace("Comparing features for $genomeID.") if T(3); |
182 |
# Compare the lists. |
# Compare the lists. |
183 |
my ($insertedFeatures, $deletedFeatures) = Tracer::CompareLists(\@newFeatures, \@oldFeatures); |
my ($insertedFeatures, $deletedFeatures) = Tracer::CompareLists(\@newFeatures, \@oldFeatures); |
184 |
# If either list has data, we want to display it. |
# Display the lists. Only nonempty lists are displayed; however, we do a check |
185 |
|
# first anyway so the trace tells us what's happening. |
186 |
if (scalar @{$insertedFeatures} + scalar @{$deletedFeatures} > 0) { |
if (scalar @{$insertedFeatures} + scalar @{$deletedFeatures} > 0) { |
187 |
Trace("Displaying feature differences.") if T(3); |
Trace("Displaying feature differences.") if T(3); |
188 |
ShowLists(! $options->{summary}, |
ShowLists(! $options->{summary}, |
191 |
} |
} |
192 |
} |
} |
193 |
} |
} |
194 |
|
} |
195 |
}; |
}; |
196 |
if ($@) { |
if ($@) { |
197 |
Trace("Script failed with error: $@") if T(0); |
Trace("Script failed with error: $@") if T(0); |
209 |
} |
} |
210 |
} |
} |
211 |
|
|
212 |
=head3 GetGenes |
=head3 GetGenomes |
213 |
|
|
214 |
C<< my @geneList = GetGenes($sprout); >> |
C<< my @geneList = GetGenomes($sprout); >> |
215 |
|
|
216 |
Return a list of the genomes in the specified Sprout instance. The genomes |
Return a list of the genomes in the specified Sprout instance. The genomes |
217 |
are returned in alphabetical order by genome ID. |
are returned in alphabetical order by genome ID. |
231 |
|
|
232 |
=cut |
=cut |
233 |
|
|
234 |
sub GetGenes { |
sub GetGenomes { |
235 |
# Get the parameters. |
# Get the parameters. |
236 |
my ($sprout) = @_; |
my ($sprout) = @_; |
237 |
# Get the desired data. |
# Get the desired data. |
245 |
return @retVal; |
return @retVal; |
246 |
} |
} |
247 |
|
|
248 |
|
=head3 NameGenomes |
249 |
|
|
250 |
|
C<< my $newList = NameGenomes($sprout, \@genomes); >> |
251 |
|
|
252 |
|
Convert a list of genome IDs to a list of genome IDs with names. |
253 |
|
|
254 |
|
=over 4 |
255 |
|
|
256 |
|
=item sprout |
257 |
|
|
258 |
|
The relevant sprout instance. |
259 |
|
|
260 |
|
=item genomes |
261 |
|
|
262 |
|
Reference to a list of genome IDs |
263 |
|
|
264 |
|
=item RETURN |
265 |
|
|
266 |
|
Returns a list of 2-tuples, each tuple consisting of a genome ID followed by a |
267 |
|
genome name. |
268 |
|
|
269 |
|
=back |
270 |
|
|
271 |
|
=cut |
272 |
|
|
273 |
|
sub NameGenomes { |
274 |
|
# Get the parameters. |
275 |
|
my ($sprout, $genomes) = @_; |
276 |
|
# Attach the names. |
277 |
|
my @retVal = map { [$_, $sprout->GenusSpecies($_) ] } @{$genomes}; |
278 |
|
# Return the result. |
279 |
|
return @retVal; |
280 |
|
} |
281 |
|
|
282 |
=head3 GetSubsystems |
=head3 GetSubsystems |
283 |
|
|
284 |
C<< my @subsystems = GetSubsystems($sprout); >> |
C<< my @subsystems = GetSubsystems($sprout); >> |