[Bio] / FigKernelPackages / PinnedRegions.pm Repository:
ViewVC logotype

Annotation of /FigKernelPackages/PinnedRegions.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : dsouza 1.1 # -*- perl -*-
2 :     ########################################################################
3 :     # Copyright (c) 2003-2006 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     ########################################################################
18 :    
19 :     package PinnedRegions;
20 :    
21 :     use strict;
22 :     use warnings;
23 :    
24 :     use FIG;
25 : dsouza 1.5 use FigFams;
26 : dsouza 1.1 use FIG_Config;
27 : parrello 1.9 use Tracer;
28 : paczian 1.27 use BasicLocation;
29 : dsouza 1.1
30 : parrello 1.9 use Time::HiRes qw( usleep gettimeofday tv_interval );
31 : dsouza 1.1
32 :     sub pinned_regions {
33 : paczian 1.16 my($fig, $pin_desc, $fast_color, $sims_from, $map_sz, $add_features, $extended) = @_;
34 : parrello 1.11 Trace("Pinned regions method called.") if T(3);
35 : dsouza 1.1 # Get list of pegs required by the description in $pin_desc
36 : dsouza 1.25 my $pinned_pegs = &expand_peg_list($fig, $pin_desc);
37 : parrello 1.9 Trace("Pinned pegs are " . join(", ", @$pinned_pegs) . ".") if T(3);
38 : parrello 1.11 # Filter out the pegs that don't exist.
39 : dsouza 1.1 # Get regions around pinned pegs -- boundaries, features, etc.
40 :     my $regions = &define_regions($fig, $map_sz, $pinned_pegs);
41 :     # Filter out overlapping regions caused by gene fusions, frame shifts etc. where multiple PEGs
42 :     # are pinned (by similarity or PCH) to the input PEG
43 :     $regions = &filter_regions_1($pin_desc, $regions);
44 :    
45 : dsouza 1.4 # Get information for each feature -- location, strand, function etc.
46 : paczian 1.16 my $feature_data = &feature_data($fig, $regions, $extended);
47 : dsouza 1.1
48 : dsouza 1.3 &add_functional_coupling($fig, $pin_desc, $regions, $feature_data);
49 : paczian 1.16
50 : bartels 1.8 # &add_figfams($fig, $feature_data);
51 : paczian 1.17 &add_subsystem_data($fig, $pin_desc, $feature_data, $extended);
52 : paczian 1.16
53 : parrello 1.9 Trace("Coloring pegs.") if T(3);
54 : dsouza 1.4 # Assign a set number to some PEGs through transitive closure based on similarity, from blast scores
55 : dsouza 1.25 &color_pegs($fig, $pin_desc, $pinned_pegs, $regions, $feature_data, $fast_color, $sims_from);
56 : dsouza 1.1
57 :     # Filter out regions which have only a single PEG (the pinned one) colored.
58 : dsouza 1.14 # $regions = &filter_regions_2($pin_desc, $regions, $feature_data);
59 : dsouza 1.1
60 : bartels 1.8 if ( defined( $add_features ) ) {
61 : parrello 1.11 &add_features_to_fdata( $fig, $feature_data, $add_features, $regions );
62 : bartels 1.8 }
63 :    
64 : dsouza 1.1 # Add feature data to the regions to make the final maps
65 :     my $maps = &make_maps($fig, $regions, $feature_data);
66 : paczian 1.16
67 : dsouza 1.1 return $maps;
68 :     }
69 :    
70 :     sub expand_peg_list {
71 : dsouza 1.25 my($fig, $pin_desc) = @_;
72 : dsouza 1.1 my @pegs = ();
73 :    
74 :     # Filter for legitimate genome IDS -- should handle deleted organisms and (in NMPDR) non-NMPDR orgs
75 :     my %ok_genome_id = map {$_ => 1} $fig->genomes;
76 :    
77 : dsouza 1.5 # If the user has selected the genomes to be displayed, filter out all other genomes
78 :     if ( @{ $pin_desc->{'show_genomes'} } )
79 :     {
80 : parrello 1.11 # create new %ok_genome_id hash from intersection of selected genomes and legitimate genome IDs
81 :     %ok_genome_id = map {$_ => 1} grep {$ok_genome_id{$_}} @{ $pin_desc->{'show_genomes'} };
82 : dsouza 1.5 }
83 :    
84 : dsouza 1.1 if ( @{ $pin_desc->{'pegs'} } > 1 )
85 :     {
86 : parrello 1.11 # Input already contains list of pegs, no need for expansion
87 :     @pegs = grep {$ok_genome_id{$fig->genome_of($_)}} @{ $pin_desc->{'pegs'} };
88 : dsouza 1.1 }
89 :     else
90 :     {
91 : parrello 1.11 # Get PCH pinned pegs
92 :     my $pch_pinned_pegs = &pch_pinned_pegs($fig, $pin_desc, \%ok_genome_id);
93 : dsouza 1.1
94 : parrello 1.11 $pch_pinned_pegs = &select_pegs($fig, $pin_desc, $pin_desc->{'n_pch_pins'}, $pch_pinned_pegs);
95 : dsouza 1.1
96 : dsouza 1.14 # Get similarity pinned pegs
97 :     my $sim_pegs = &sim_pegs($fig, $pin_desc, \%ok_genome_id);
98 : dsouza 1.1
99 : parrello 1.11 # Remove PCH PEGs (if any) from similarity pinned PEG list
100 :     my %seen = map {$_ => 1} @$pch_pinned_pegs;
101 :     $sim_pegs = [grep {! $seen{$_}} @$sim_pegs];
102 :    
103 :     $sim_pegs = &select_pegs($fig, $pin_desc, $pin_desc->{'n_sims'}, $sim_pegs);
104 :    
105 :     @pegs = ();
106 :    
107 :     # Get input peg
108 :     my $peg = $pin_desc->{'pegs'}[0];
109 :     if ( $pin_desc->{'sort_by'} eq 'phylogeny' )
110 :     {
111 :     # First add input peg, then sort by phylogeny
112 :     @pegs = $fig->sort_fids_by_taxonomy($peg, @$sim_pegs, @$pch_pinned_pegs);
113 :     }
114 : dsouza 1.21 elsif ( $pin_desc->{'sort_by'} eq 'phylogenetic_distance' )
115 : parrello 1.11 {
116 :     # Sort by phylogenetic distance or organism name
117 :     my $g1 = $fig->genome_of($peg);
118 :     @pegs = map {$_->[0] }
119 :     sort {$a->[1] <=> $b->[1] or $a->[2] cmp $b->[2]}
120 :     map {[$_, $fig->crude_estimate_of_distance($g1,$fig->genome_of($_)), $fig->org_of($_)]} @$sim_pegs, @$pch_pinned_pegs;
121 :     # Add input peg at front of list
122 :     unshift @pegs, $peg;
123 :     }
124 : dsouza 1.21 elsif ( $pin_desc->{'sort_by'} eq 'similarity' )
125 :     {
126 :     # Sort by similarity to input peg (first peg in list of arguments)
127 : dsouza 1.25 @pegs = &sort_pegs_by_similarity($fig, $peg, @$sim_pegs, @$pch_pinned_pegs);
128 : dsouza 1.21 }
129 : dsouza 1.1 }
130 : dsouza 1.21
131 : dsouza 1.1 return \@pegs
132 :     }
133 :    
134 :     sub pch_pinned_pegs {
135 :     my($fig, $pin_desc, $ok_genome_id) = @_;
136 :    
137 :     my @pegs = ();
138 :    
139 :     if ( $pin_desc->{'n_pch_pins'} > 0 )
140 :     {
141 : parrello 1.11 # Get input peg
142 :     my $peg = $pin_desc->{'pegs'}[0];
143 : dsouza 1.1
144 : parrello 1.11 # Get pegs in pch pin with input peg, and filter out deleted or non-NMPDR organisms
145 :     @pegs = grep {$ok_genome_id->{$fig->genome_of($_)}}
146 :     grep {$_ ne $peg}
147 : dsouza 1.1 map {$_->[0]} $fig->in_pch_pin_with_and_evidence($peg);
148 :     }
149 :    
150 :     return \@pegs;
151 :     }
152 :    
153 :     sub sim_pegs {
154 :     my($fig, $pin_desc, $ok_genome_id) = @_;
155 :    
156 :     # Return a list of PEGS similar to the input PEG, with evalue less than or equal to
157 :     # the user defined similarity cutoff.
158 :     # If the number of sims requested is 0, return the empty list
159 :    
160 :     my $n_sims = $pin_desc->{'n_sims'};
161 :     my $sim_cutoff = $pin_desc->{'sim_cutoff'};
162 :     my @pegs = ();
163 :    
164 :     if ( $n_sims > 0 )
165 :     {
166 : parrello 1.11 my $peg = $pin_desc->{'pegs'}[0];
167 :     my %seen;
168 : paczian 1.15
169 : parrello 1.11 @pegs = grep {$ok_genome_id->{$fig->genome_of($_)}}
170 :     grep {! $seen{$_}++}
171 :     map {$_->[1]} $fig->sims($peg, 10000, $sim_cutoff, "fig");
172 : dsouza 1.1
173 : parrello 1.11 my $n_pegs = @pegs;
174 : dsouza 1.1 }
175 :    
176 :     return \@pegs;
177 :     }
178 :    
179 :     sub select_pegs {
180 :     my($fig, $pin_desc, $n_pegs, $pegs) = @_;
181 :    
182 :     if ( $n_pegs == 0 )
183 :     {
184 : parrello 1.11 return [];
185 : dsouza 1.1 }
186 :    
187 : dsouza 1.3 if ( $pin_desc->{'collapse_close_genomes'} == 1 )
188 : dsouza 1.1 {
189 : parrello 1.11 # The ordering of the PEGs done here is in order to =select= the correct set, the ordering for the
190 :     # display is done later.
191 : dsouza 1.2
192 : parrello 1.11 # To collapse the PEG list, we want to:
193 :     # a. Return at most $n_pegs PEGs,
194 :     # b. include a representative PEG from every genus, subject to a, and
195 :     # c. include a representative PEG from each genus-species, subject to a and b.
196 :     # Individual strains will get represented by a single PEG, chosen arbitrarily.
197 :    
198 :     # The PEG selection is defined by the order of the PEGs. This could be done beter.
199 :    
200 :     my(%seen, @unique_genus, @unique_genus_species);
201 :    
202 :     foreach my $peg ( @$pegs )
203 :     {
204 :     my $org = $fig->org_of($peg);
205 :     # 'org_of' returns undef for deleted PEGs, these need to be omitted from the peg list returned
206 :    
207 :     if ( $org )
208 :     {
209 :     # Use only genus+species to drop strain information
210 :     my($genus, $species) = split(/\s+/, $org);
211 :     my $gs = "$genus $species";
212 :    
213 :     if ( not $seen{$genus}++ )
214 :     {
215 :     # First PEG from this genus, add it to @unique_genus.
216 :     # Mark the genus+species as seen.
217 :     # A subsequent PEG with the same genus and species will be dropped.
218 :     # A subsequent PEG with the same genus but different species will be added to @unique_genus_species.
219 :     $seen{$gs}++;
220 :     push @unique_genus, $peg;
221 :     }
222 :     elsif ( not $seen{$gs}++ )
223 :     {
224 :     # First PEG from this genus+species, add it to @unique_genus_species.
225 :     push @unique_genus_species, $peg;
226 :     }
227 :     }
228 :     }
229 : dsouza 1.1
230 : parrello 1.11 # Keep the unique_genus PEGS at the top, followed by the unique_genus_species
231 :     $pegs = [@unique_genus, @unique_genus_species];
232 : dsouza 1.1 }
233 :    
234 :     # Truncate list if necessary
235 : dsouza 1.3 if ( $n_pegs < @$pegs )
236 : dsouza 1.1 {
237 : parrello 1.11 $#{ $pegs } = $n_pegs - 1;
238 : dsouza 1.1 }
239 :    
240 :     return $pegs;
241 :     }
242 :    
243 : dsouza 1.21 sub sort_pegs_by_similarity {
244 : dsouza 1.25 my($fig, $input_peg, @other_pegs) = @_;
245 :    
246 :     # Set blast environment variables
247 :     $ENV{"BLASTMAT"} ||= "$FIG_Config::blastmat";
248 :     if ($ENV{"PATH"} !~ /fig\/bin/) { $ENV{"PATH"} = "$FIG_Config::bin:" . $ENV{"PATH"}; }
249 : dsouza 1.21
250 :     # Get amino acid sequences
251 : dsouza 1.25 my $sequences = &get_peg_sequences($fig, [$input_peg, @other_pegs]);
252 : dsouza 1.21
253 :     # Write the input peg sequence to a fasta file
254 :     my $input_seq = {$input_peg => $sequences->{$input_peg}};
255 :     my $input_seq_file = "$FIG_Config::temp/input_seq.$$.tmp.fasta";
256 :     &write_seqs_to_file($input_seq, $input_seq_file);
257 :    
258 :     # Write the other peg sequences to a fasta file
259 :     delete $sequences->{$input_peg};
260 :     my $other_seq_file = "$FIG_Config::temp/other_seq.$$.tmp.fasta";
261 :     &write_seqs_to_file($sequences, $other_seq_file);
262 :    
263 : dsouza 1.25 # Run formatdb
264 :     &formatdb_file($fig, $other_seq_file);
265 :    
266 :     # BLAST input peg sequence against other peg sequences
267 :     # set high evalue cutoff so all hits get reported
268 : dsouza 1.24 my $cutoff = 10;
269 : dsouza 1.25 my $hits = &blast_files($fig, $input_seq_file, $other_seq_file, $cutoff);
270 : dsouza 1.21
271 :     my @sorted = ($input_peg);
272 :     foreach my $hit ( @$hits )
273 :     {
274 : dsouza 1.25 # BLAST output is already sorted by similarity
275 : dsouza 1.21 my($peg2) = (split(/\s+/, $hit))[1];
276 : dsouza 1.25 push @sorted, $peg2;
277 : dsouza 1.21 }
278 :    
279 :     return @sorted;
280 :     }
281 :    
282 : dsouza 1.1 sub filter_regions_1 {
283 :     my($pin_desc, $regions) = @_;
284 :     my $new_regions;
285 :    
286 :     # Filter out some overlapping regions caused by gene fusions, frame shifts etc. where multiple PEGs
287 :     # are pinned (by similarity or PCH) to the input PEG
288 :     # Note that all overlaps are NOT eliminated
289 :    
290 :     if ( @{ $pin_desc->{'pegs'} } == 1 )
291 :     {
292 : parrello 1.11 # Input pin description is for a single input peg
293 :     my %seen;
294 :    
295 :     foreach my $region ( @$regions )
296 :     {
297 :     my $pinned_peg = $region->{'pinned_peg'};
298 :    
299 :     # If the pinned peg from a region has already been 'seen', don't
300 :     # add the region into the @$new_regions array
301 :    
302 :     if ( not $seen{$pinned_peg} )
303 :     {
304 :     push @$new_regions, $region;
305 :    
306 :     my $fids = $region->{'features'};
307 :     foreach my $fid ( @$fids )
308 :     {
309 :     $seen{$fid} = 1;
310 :     }
311 :     }
312 :     }
313 : dsouza 1.1 }
314 :     else
315 :     {
316 : parrello 1.11 # input PEGs is a list -- keep all of them
317 :     $new_regions = $regions;
318 : dsouza 1.1 }
319 :    
320 :     return $new_regions;
321 :     }
322 :    
323 :     sub filter_regions_2 {
324 :     my($pin_desc, $regions, $feature_data) = @_;
325 :     my $new_regions;
326 :    
327 :     if ( @{ $pin_desc->{'pegs'} } == 1 )
328 :     {
329 : parrello 1.11 # Input is single peg
330 :     my $input_peg = $pin_desc->{'pegs'}[0];
331 : dsouza 1.1
332 : parrello 1.11 foreach my $region ( @$regions )
333 :     {
334 :     my $fids = $region->{'features'};
335 :     my $n_in_sets = grep {$feature_data->{$_}{'set_number'}} @$fids;
336 :    
337 :     if ( $n_in_sets > 1 or $region->{'pinned_peg'} eq $input_peg )
338 :     {
339 :     # Regions should be displayed only if:
340 :     # a. more than one PEG is in a 'colored set' OR
341 :     # b. the pinned PEG is the input PEG
342 :     push @$new_regions, $region;
343 :     }
344 :     }
345 : dsouza 1.1 }
346 :     else
347 :     {
348 : parrello 1.11 # Input is a list of pegs -- keep all of the regions
349 :     $new_regions = $regions
350 : dsouza 1.1 }
351 :    
352 :     return $new_regions;
353 :     }
354 :    
355 :     sub make_maps {
356 :     my($fig, $regions, $feature_data) = @_;
357 :    
358 :     foreach my $region ( @$regions )
359 :     {
360 : parrello 1.11 my $features = [];
361 :     my $fids = $region->{'features'};
362 : dsouza 1.1
363 : parrello 1.11 foreach my $fid ( @$fids )
364 :     {
365 :     push @$features, $feature_data->{$fid};
366 :     # if ( !( $fid =~ /fig/ ) ) {
367 :     # print STDERR $fid." FIDMAKEMAPS\n";
368 :     # }
369 :     }
370 : dsouza 1.1
371 : parrello 1.11 $region->{'features'} = $features;
372 : dsouza 1.1 }
373 :    
374 :     return $regions;
375 :     }
376 :    
377 :     sub define_regions {
378 :     my($fig, $map_sz, $pinned_pegs) = @_;
379 :    
380 :     # Define the 'region' around the pinned peg, get features, and store some region information
381 :     my $regions = [];
382 :     my $half_map_sz = int($map_sz/2);
383 :    
384 :     foreach my $peg ( @$pinned_pegs )
385 :     {
386 : parrello 1.11 my $genome = $fig->genome_of($peg);
387 :     my $loc = $fig->feature_location($peg);
388 :     # We only proceed if a location was found. Failure to find a location indicates
389 :     # that the feature is deleted.
390 :     if ($loc) {
391 :     my($contig, $beg, $end) = $fig->boundaries_of($loc);
392 :    
393 :     my $region_mid = int(($beg + $end)/2);
394 :     my $region_beg = $region_mid - $half_map_sz;
395 :     my $region_end = $region_mid + $half_map_sz;
396 :    
397 :     my($fids) = $fig->genes_in_region($genome, $contig, $region_beg, $region_end);
398 :    
399 :     my $region = {};
400 :     $region->{'genome_id'} = $fig->genome_of($peg);
401 :     $region->{'org_name'} = $fig->genus_species($region->{'genome_id'});
402 :     $region->{'contig'} = $contig;
403 :     $region->{'beg'} = $region_beg;
404 :     $region->{'mid'} = $region_mid;
405 :     $region->{'end'} = $region_end;
406 :     $region->{'features'} = $fids;
407 :     $region->{'pinned_peg_strand'} = ($beg <= $end)? '+' : '-';
408 :     $region->{'pinned_peg'} = $peg;
409 :    
410 :     push @$regions, $region;
411 :     }
412 : dsouza 1.1 }
413 :    
414 :     return $regions;
415 :     }
416 :    
417 : bartels 1.8 sub add_features_to_fdata {
418 :     my ( $fig, $feature_data, $add_features, $regions ) = @_;
419 :    
420 :     foreach my $region ( @$regions ) {
421 : parrello 1.11 my $new_feats = $add_features->{ $region->{ 'genome_id' } };
422 :     foreach my $nf ( @$new_feats ) {
423 :     if ( $nf->{ 'contig' } eq $region->{ 'contig' } &&
424 :     $nf->{ 'start' } < $region->{ 'end' } &&
425 :     $nf->{ 'start' } > $region->{ 'beg' } ) {
426 :     $feature_data->{ $nf->{ 'name' } } = &new_feature_entry( $fig, $nf->{ 'name' }, $region->{ 'mid' }, $region->{ 'contig' }, $nf->{ 'start' }, $nf->{ 'stop' }, $nf->{ 'type' }, $nf->{ 'function' } );
427 :     push @{ $region->{ 'features' } }, $nf->{ 'name' };
428 :     }
429 :     }
430 : bartels 1.8 }
431 :     }
432 :    
433 :     sub new_feature_entry {
434 :     my ( $fig, $fid, $region_mid, $contig, $beg, $end, $type, $func ) = @_;
435 :    
436 :     if ( !defined( $type ) ) {
437 : parrello 1.11 $type = 'unknown';
438 : bartels 1.8 }
439 :    
440 :     if ( !defined( $func ) ) {
441 : parrello 1.11 $func = '';
442 : bartels 1.8 }
443 :    
444 :     my($left, $right) = sort {$a <=> $b} ($beg, $end);
445 :     my $size = $right - $left + 1;
446 :     my $strand = ($beg <= $end)? '+' : '-';
447 :     my $offset = int(($left + $right)/2) - $region_mid;
448 :     my $offset_beg = $left - $region_mid;
449 :     my $offset_end = $right - $region_mid;
450 :    
451 :     return {
452 : parrello 1.11 'fid' => $fid,
453 :     'type' => $type,
454 :     'contig' => $contig,
455 :     'beg' => $beg,
456 :     'end' => $end,
457 :     'size' => $size,
458 :     'strand' => $strand,
459 :     'offset' => $offset,
460 :     'offset_beg' => $offset_beg,
461 :     'offset_end' => $offset_end,
462 :     'function' => $func,
463 : bartels 1.8 };
464 :     }
465 :    
466 : dsouza 1.1 sub feature_data {
467 : paczian 1.16 my($fig, $regions, $extended) = @_;
468 : dsouza 1.1 my %feature_data;
469 :    
470 :     foreach my $region ( @$regions )
471 :     {
472 : parrello 1.11 my $region_mid = $region->{'mid'};
473 :     my $fids = $region->{'features'};
474 : dsouza 1.1
475 : parrello 1.11 foreach my $fid ( @$fids )
476 :     {
477 :     # Get feature data if this feature has not been seen before, this avoids repeating
478 :     # this step when pegs occur in multiple regions
479 :     if ( not exists $feature_data{$fid} )
480 :     {
481 : paczian 1.16 $feature_data{$fid} = &feature_entry($fig, $fid, $region_mid, $extended);
482 : parrello 1.11 }
483 :     }
484 : dsouza 1.1 }
485 :    
486 : paczian 1.16 if ($extended) {
487 :     # get the evidence codes
488 :     my @all_fids = keys(%feature_data);
489 :     my @codes = grep { $_->[1] =~ /^evidence_code/i } $fig->get_attributes(\@all_fids, 'evidence_code');
490 :     my $pretty_codes = {};
491 :     foreach my $code (@codes) {
492 :     my $pretty_code = $code->[2];
493 :     if ($pretty_code =~ /;/) {
494 :     my ($cd, $ss) = split(";", $code->[2]);
495 :     $pretty_code = $cd;
496 :     }
497 :     $pretty_code =~ s/lit\((\d+)\)/lit\(<a href='http:\/\/www\.ncbi\.nlm\.nih\.gov\/sites\/entrez\?cmd=Retrieve&db=PubMed&list_uids=$1&dopt=AbstractPlus' target=_blank>$1<\/a>\)/;
498 :     push(@{$pretty_codes->{$code->[0]}}, $pretty_code);
499 :     }
500 :     foreach my $entry (keys(%$pretty_codes)) {
501 :     $feature_data{$entry}{'evcodes'} = join(", ", @{$pretty_codes->{$entry}});
502 :     }
503 :     }
504 :    
505 : dsouza 1.1 return \%feature_data;
506 :     }
507 :    
508 :     sub feature_entry {
509 : paczian 1.16 my($fig, $fid, $region_mid, $extended) = @_;
510 : dsouza 1.1
511 :     my $type = $fig->ftype($fid);
512 :     my $loc = $fig->feature_location($fid);
513 :     my($contig, $beg, $end) = $fig->boundaries_of($loc);
514 :     my($left, $right) = sort {$a <=> $b} ($beg, $end);
515 :     my $strand = ($beg <= $end)? '+' : '-';
516 :     my $offset = int(($left + $right)/2) - $region_mid;
517 :     my $offset_beg = $left - $region_mid;
518 :     my $offset_end = $right - $region_mid;
519 :     my $func = scalar $fig->function_of($fid) || '';
520 : paczian 1.27 my $genome = $fig->genome_of($fid);
521 :     my $location = FullLocation->new($fig, $genome, $loc);
522 :     my $size = 0;
523 :     map { $size += $_->Length } @{$location->Locs};
524 : dsouza 1.1
525 : paczian 1.16 my $retval = { 'fid' => $fid,
526 : paczian 1.26 'location' => $loc,
527 : paczian 1.16 'type' => $type,
528 :     'contig' => $contig,
529 :     'beg' => $beg,
530 :     'end' => $end,
531 :     'size' => $size,
532 :     'strand' => $strand,
533 :     'offset' => $offset,
534 :     'offset_beg' => $offset_beg,
535 :     'offset_end' => $offset_end,
536 : dsouza 1.25 'function' => $func };
537 : paczian 1.16 if ($extended) {
538 :     my $aliases = $fig->feature_aliases($fid) || '';
539 :     $retval->{aliases} = $aliases;
540 :     }
541 :    
542 :     return $retval;
543 : dsouza 1.1 }
544 :    
545 : dsouza 1.3 sub add_functional_coupling {
546 :     my($fig, $pin_desc, $regions, $feature_data) = @_;
547 :    
548 :     my $fc_cutoff = defined($pin_desc->{'fc_cutoff'})? $pin_desc->{'fc_cutoff'} : 4;
549 :    
550 :     foreach my $region ( @$regions )
551 :     {
552 : parrello 1.11 my $pin = $region->{'pinned_peg'};
553 :     my @pegs = grep {$feature_data->{$_}{'type'} eq 'peg'} @{ $region->{'features'} };
554 : dsouza 1.3
555 : parrello 1.11 foreach my $couple ( $fig->coupled_to_batch(@pegs) )
556 :     {
557 :     my($peg1, $peg2, $sc) = @$couple;
558 :    
559 :     if ( $peg1 eq $pin and $sc >= $fc_cutoff )
560 :     {
561 :     $feature_data->{$peg2}{'fc_score'} = $sc;
562 : paczian 1.15 $feature_data->{$peg2}{'fc_pin'} = $peg1;
563 : parrello 1.11 }
564 :     }
565 : dsouza 1.3 }
566 :     }
567 :    
568 : dsouza 1.5 sub add_figfams {
569 :     my($fig, $feature_data) = @_;
570 :    
571 : dsouza 1.6 # Get FigFams directory from config file
572 : olson 1.10 my $figfam_dir = $fig->get_figfams_data();
573 : dsouza 1.5
574 : dsouza 1.6 # Check if FigFams directory is defined and exists on current machine
575 :     if ( defined($figfam_dir) and (-d $figfam_dir) )
576 : dsouza 1.5 {
577 : parrello 1.11 # Get all PEG IDs
578 :     my @pegs = grep {$feature_data->{$_}{'type'} eq 'peg'} keys %$feature_data;
579 :     # Get $figfams object
580 :     my $figfams = new FigFams($fig, $figfam_dir);
581 :     # Get FigFam family ID for @pegs
582 :     my $figfam = $figfams->families_containing_peg_bulk(\@pegs);
583 :     # Get hash of FigFam ID to family function
584 :     my $family_function = $figfams->family_functions();
585 :    
586 :     # Some FigFams (the ones that are not subsystem related) have the FigFam ID in the family function.
587 :     # This results in the popup displaying the ID twice, so one should be removed.
588 :    
589 :     my %figfam_text;
590 :     foreach my $fid ( keys %$feature_data )
591 :     {
592 :     if ( $figfam->{$fid} )
593 :     {
594 :     my $figfam_id = $figfam->{$fid};
595 :     if ( ! exists $figfam_text{$figfam_id} ) {
596 :     if ( $family_function->{$figfam_id} =~ /^FIG\d+/ ) {
597 :     $figfam_text{$figfam_id} = $family_function->{$figfam_id};
598 :     } else {
599 :     $figfam_text{$figfam_id} = $figfam_id . ': ' . $family_function->{$figfam_id};
600 :     }
601 :     }
602 : dsouza 1.7
603 : parrello 1.11 # Add FigFam information to hash -- to go into the popup text
604 :     $feature_data->{$fid}{'figfam'} = $figfam_text{$figfam_id};
605 :     }
606 :     }
607 : dsouza 1.5 }
608 :     }
609 :    
610 : dsouza 1.3 sub add_subsystem_data {
611 : paczian 1.17 my($fig, $pin_desc, $feature_data, $extended) = @_;
612 : dsouza 1.14
613 :     # Get subsystem_information for =all= pegs
614 :    
615 : paczian 1.16 my @fids = keys(%$feature_data);
616 :     my %ssdata = $fig->subsystems_for_pegs_complete(\@fids);
617 :     my @subsystems = ();
618 :     foreach my $p (keys(%ssdata)) {
619 :     foreach my $entry (@{$ssdata{$p}}) {
620 :     push(@subsystems, [ $entry->[0], $entry->[1], $entry->[2], $p ]);
621 :     }
622 :     }
623 : paczian 1.17 unless ($extended) {
624 : paczian 1.19 @subsystems = grep { $fig->usable_subsystem($_->[0]) } @subsystems;
625 : paczian 1.18 @subsystems = grep { $fig->is_exchangable_subsystem($_->[0]) } @subsystems;
626 : paczian 1.17 }
627 : paczian 1.16
628 : dsouza 1.14 my %peg_to_ss;
629 : paczian 1.16 foreach my $rec ( @subsystems ) {
630 :     my($ss_name, $role, $variant, $fid) = @$rec;
631 :     $ss_name =~ s/_/ /g;
632 :    
633 :     if ( $variant eq '0' ) {
634 :     # no subsystem
635 : paczian 1.19 if ($extended) {
636 :     my $ss_text = "$ss_name (not yet classified for this organism)";
637 : paczian 1.20 $peg_to_ss{$fid}{$ss_name} = $ss_text;
638 : paczian 1.19 }
639 : paczian 1.16 } elsif ( $variant eq '-1' or $variant eq '*-1' ) {
640 :     # subsystem not functional in this organism
641 :     my $ss_text = "$ss_name (classified 'not active' in this organism)";
642 : paczian 1.20 $peg_to_ss{$fid}{$ss_name} = $ss_text;
643 : paczian 1.16 } else {
644 :     $peg_to_ss{$fid}{$ss_name} = 1;
645 : dsouza 1.14 }
646 :     }
647 :    
648 : dsouza 1.3 # Count number of occurences of each subsystem
649 :     my %ss_count;
650 : dsouza 1.14 foreach my $fid ( keys %peg_to_ss )
651 : dsouza 1.3 {
652 : dsouza 1.14 foreach my $ss ( keys %{ $peg_to_ss{$fid} } )
653 :     {
654 :     $ss_count{$ss}++;
655 :     }
656 : dsouza 1.3 }
657 :    
658 :     # Sort subsystems based on count and create hash with unique index for each subsystem where
659 :     # lower indices correspond to higher number of occurences of the subsystem.
660 :     my %ss_index;
661 :     my $index = 0;
662 :     foreach my $ss ( sort {$ss_count{$b} <=> $ss_count{$a} or $a cmp $b} keys %ss_count )
663 :     {
664 : parrello 1.11 $ss_index{$ss} = ++$index;
665 : dsouza 1.3 }
666 :    
667 :     # Add subsystem information for pegs in subsystems
668 :     foreach my $fid ( keys %peg_to_ss )
669 :     {
670 : paczian 1.20 my @subsystems;
671 :     foreach my $key (keys(%{$peg_to_ss{$fid}})) {
672 :     if ($peg_to_ss{$fid}{$key} ne "1") {
673 :     push(@subsystems, [ $peg_to_ss{$fid}{$key}, $ss_index{$key} ]);
674 :     } else {
675 :     push(@subsystems, [ $key, $ss_index{$key} ]);
676 :     }
677 :     }
678 : parrello 1.11
679 :     if ( @subsystems )
680 :     {
681 : paczian 1.20 $feature_data->{$fid}{'subsystems'} = [sort {$a->[1] <=> $b->[1]} @subsystems];
682 : parrello 1.11 }
683 : dsouza 1.3 }
684 :     }
685 :    
686 : dsouza 1.1 sub color_pegs {
687 : dsouza 1.25 my($fig, $pin_desc, $pinned_pegs, $regions, $feature_data, $fast_color, $sims_from) = @_;
688 : dsouza 1.1
689 :     # Run blastp and get connected pegs
690 :     my $blast_hit = {};
691 :     my $color_sim_cutoff = $pin_desc->{'color_sim_cutoff'};
692 :    
693 :     if ( $sims_from eq 'blast' )
694 :     {
695 : dsouza 1.25 $blast_hit = &blast_hits($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff);
696 : dsouza 1.1 }
697 :     else
698 :     {
699 : dsouza 1.25 $blast_hit = &blast_hits_from_sims($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff);
700 : dsouza 1.1 }
701 :    
702 :     # Assign set numbers to pegs based on blast scores
703 :     my $color_sets = &partition_pegs($blast_hit);
704 :    
705 :     # Sort peg sets to that a) larger sets have smaller set numbers, and
706 :     # b) sets closer to the pinned peg have smaller set numbers
707 : dsouza 1.4 $color_sets = &sort_color_sets($pin_desc, $pinned_pegs, $color_sets, $feature_data);
708 : dsouza 1.1
709 :     # Add color set number into $feature_data
710 :     for (my $i = 0; $i < @$color_sets; $i++)
711 :     {
712 : parrello 1.11 # Use an index that starts at 1 (matches with coloring index)
713 :     my $n = $i + 1;
714 :     foreach my $peg ( @{ $color_sets->[$i] } )
715 :     {
716 :     $feature_data->{$peg}{'set_number'} = $n;
717 :    
718 :     # If this is the pinned set, set the 'color' to 'red'
719 :     if ( $n == 1 )
720 :     {
721 :     $feature_data->{$peg}{'color'} = 'red';
722 :     }
723 :     }
724 : dsouza 1.1 }
725 :     }
726 :    
727 :     sub sort_color_sets {
728 :     my($pin_desc, $pinned_pegs, $color_sets, $feature_data) = @_;
729 :    
730 : dsouza 1.3 # Find the color set containing the set of pinned pegs, i.e. the set containing the input peg.
731 :     # If the input peg is found (or if input is a list of pegs, returned value is the array index for the
732 :     # set.
733 :     # If the input peg is not found, the returned value is an reference to an array containing the input peg.
734 :     my $set = &pinned_set($pin_desc, $pinned_pegs, $color_sets);
735 : dsouza 1.1
736 : dsouza 1.3 my $pinned_color_set;
737 :     if ( $set =~ /^\d+$/ )
738 :     {
739 : parrello 1.11 # Splice out the color set containing the input peg
740 :     ($pinned_color_set) = splice(@$color_sets,$set,1);
741 : dsouza 1.3 }
742 :     else
743 :     {
744 : parrello 1.11 $pinned_color_set = $set;
745 : dsouza 1.3 }
746 : dsouza 1.1
747 : dsouza 1.3 # Add offset (summed distance from
748 :     my @color_sets = map {[$_, &offset($_, $feature_data)]} @$color_sets;
749 : dsouza 1.1 # Sort the remaining color sets based on:
750 :     # a. size (number of pegs) and
751 :     # b. offset from mid-point of region
752 :     @$color_sets = map {$_->[0]}
753 :     sort {@{$b->[0]} <=> @{$a->[0]} or $a->[1] <=> $b->[1]}
754 : dsouza 1.3 # sort {$a->[1] <=> $b->[1] or @{$b->[0]} <=> @{$a->[0]}}
755 : dsouza 1.1 map {[$_, &offset($_, $feature_data)]} @$color_sets;
756 :    
757 :     # Add the set of pinned pegs at the front of the returned list so that it gets colored red
758 :     return [$pinned_color_set, @$color_sets];
759 :     }
760 :    
761 : dsouza 1.3 sub pinned_set {
762 : dsouza 1.1 my($pin_desc, $pinned_pegs, $color_sets) = @_;
763 :    
764 : dsouza 1.3 # Returns an integer if the input is a peg-list or if the input peg is in a set.
765 :     # Returns the input peg (as an array reference) if the input peg is not in a set.
766 :    
767 : dsouza 1.1 if ( @{ $pin_desc->{'pegs'} } == 1 )
768 :     {
769 : parrello 1.11 # Get input peg if it exists -- the set containing this peg should be colored red
770 :     my $peg = $pin_desc->{'pegs'}[0];
771 : dsouza 1.1
772 : parrello 1.11 # Iterate through the color sets until you find the set containing the input peg
773 :     for (my $i = 0; $i < @$color_sets; $i++)
774 :     {
775 :     foreach my $peg2 ( @{ $color_sets->[$i] } )
776 :     {
777 :     if ( $peg2 eq $peg )
778 :     {
779 :     # Return the set index
780 :     return $i;
781 :     }
782 :     }
783 :     }
784 : dsouza 1.1
785 : parrello 1.11 # The input peg may not be in a set if there is only one region or the coloring cutoff is very stringent.
786 :     return [$peg];
787 : dsouza 1.1 }
788 :     else
789 :     {
790 : parrello 1.11 # Input is a peg-list, which may be split into multiple sets -- the largest will be called the
791 :     # "pinned" set.
792 : parrello 1.12 my $i;
793 :     my $max_count = 0;
794 : parrello 1.11 my %pinned = map {$_ => 1} @$pinned_pegs;
795 :    
796 :     for (my $j = 0; $j < @$color_sets; $j++)
797 :     {
798 :     # count how many pinned pegs are found in each set
799 : parrello 1.12 my $count = scalar(grep {$pinned{$_}} @{ $color_sets->[$j] }) || 0;
800 : parrello 1.11
801 :     if ( $max_count < $count )
802 :     {
803 :     # Keep track of the set having the largest number of pinned pegs
804 :     $max_count = $count;
805 :     $i = $j;
806 :     }
807 :     }
808 : dsouza 1.1
809 : parrello 1.11 return $i;
810 : dsouza 1.1 }
811 :     }
812 :    
813 :     sub offset {
814 :     my($set, $feature_data) = @_;
815 :    
816 :     my $offset;
817 :     foreach my $peg ( @$set )
818 :     {
819 : parrello 1.11 $offset += abs($feature_data->{$peg}{'offset'});
820 : dsouza 1.1 }
821 : dsouza 1.3
822 :     return sprintf("%.2f", $offset/@$set);
823 : dsouza 1.1 }
824 :    
825 :     sub partition_pegs {
826 :     my($blast_hit) = @_;
827 :    
828 :     my %seen;
829 :     my $sets = [];
830 :    
831 :     # Iterate through the pegs with blast hits in arbitrary order
832 :     foreach my $peg1 ( keys %$blast_hit )
833 :     {
834 : parrello 1.11 # If it has not been 'seen' (and placed in a set) use it as the seed for a set
835 :     if ( not $seen{$peg1} )
836 :     {
837 :     my $set = [$peg1];
838 :    
839 :     # Mark $peg1 as seen
840 :     $seen{$peg1} = 1;
841 :    
842 :     # Grow set through transitive closure -- note that @$set keeps growing
843 :     for (my $i = 0; $i < @$set; $i++)
844 :     {
845 :     $peg1 = $set->[$i];
846 :    
847 :     # Iterate through blast hits
848 :     foreach my $peg2 ( keys %{ $blast_hit->{$peg1} } )
849 :     {
850 :     # If $peg2 has not been seen, put it in the set, and mark it as seen
851 :     if ( not exists $seen{$peg2} )
852 :     {
853 :     push @$set, $peg2;
854 :     $seen{$peg2} = 1;
855 :     }
856 :     }
857 :     }
858 :    
859 :     # Add the new set to the set of sets
860 :     push @$sets, $set;
861 :     }
862 : dsouza 1.1 }
863 :    
864 :     return $sets;
865 :     }
866 :    
867 :     sub blast_hits {
868 : dsouza 1.25 my($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff) = @_;
869 :    
870 :     # Set blast environment variables
871 :     $ENV{"BLASTMAT"} ||= "$FIG_Config::blastmat";
872 :     if ($ENV{"PATH"} !~ /fig\/bin/) { $ENV{"PATH"} = "$FIG_Config::bin:" . $ENV{"PATH"}; }
873 : dsouza 1.1
874 :     # Get amino acid sequences
875 : dsouza 1.21 my @pegs = grep {$feature_data->{$_}{'type'} eq 'peg'} keys %$feature_data;
876 :     my $sequences = &get_peg_sequences($fig, \@pegs);
877 : dsouza 1.1
878 :     # Write the entire set of sequences to a fasta file
879 :     my $all_seqs_file = "$FIG_Config::temp/all_seqs.$$.tmp.fasta";
880 :     &write_seqs_to_file($sequences, $all_seqs_file);
881 :    
882 : dsouza 1.25 # Run formatdb
883 :     &formatdb_file($fig, $all_seqs_file);
884 :    
885 :     # If $fast_color == 0, the complete blast of all vs. all sequences is performed
886 :     # Otherwise, instead of all vs. all, the sequences from a single pinned peg region
887 :     # is blasted against all sequences. If any of the hits are better than a given cutoff
888 :     # ($cutoff_2), the pegs hit are deemed to be 'done', i.e. it is assumed that blasting this
889 :     # peg will not yield additional information for forming the peg sets. These 'done' pegs
890 :     # are then omitted from the blast when the sequences from the region they belong to
891 :     # is blasted.
892 :     my %blast_hit;
893 :     if ( $fast_color )
894 : dsouza 1.1 {
895 : dsouza 1.25 my $cutoff_2 = $color_sim_cutoff * 1e-20;
896 :     my %done_with;
897 :    
898 :     foreach my $region ( @$regions )
899 :     {
900 :     # Iterate through each region
901 :     my $fids = $region->{'features'};
902 :    
903 :     # Build up a hash of peg sequences which are not 'done_with'
904 :     my %region_seqs;
905 :     foreach my $peg ( grep {$feature_data->{$_}{'type'} eq 'peg'} @$fids )
906 :     {
907 :     if ( $sequences->{$peg} and not $done_with{$peg} )
908 :     {
909 :     $region_seqs{$peg} = $sequences->{$peg};
910 :     }
911 :     }
912 :    
913 :     if ( scalar keys %region_seqs )
914 :     {
915 :     # Write the region sequences to a file
916 :     my $region_seqs_file = "$FIG_Config::temp/region_seqs.$$.tmp.fasta";
917 :     &write_seqs_to_file(\%region_seqs, $region_seqs_file);
918 :    
919 :     # BLAST the region sequences against all other sequences
920 :     my $hits = &blast_files($fig, $region_seqs_file, $all_seqs_file, $color_sim_cutoff);
921 :    
922 :     # Build up hash of blast hits
923 :     foreach my $hit ( @$hits )
924 :     {
925 :     my($peg1, $peg2, $sc) = (split(/\s+/, $hit))[0,1,10];
926 :    
927 :     if ( $peg1 ne $peg2 )
928 :     {
929 :     $blast_hit{$peg1}{$peg2} = 1;
930 :     $blast_hit{$peg2}{$peg1} = 1;
931 :    
932 :     # If the blast score is less than the chosen cutoff, mark $peg2 as 'done_with' so
933 :     # that it will not be blasted with it's region sequences
934 :     if ( $sc <= $cutoff_2 )
935 :     {
936 :     $done_with{$peg2} = 1;
937 :     }
938 :     }
939 :     }
940 :     }
941 :     }
942 : dsouza 1.1 }
943 :     else
944 :     {
945 : parrello 1.11 # BLAST sequence file against itself
946 : dsouza 1.25 my $hits = &blast_files($fig, $all_seqs_file, $all_seqs_file, $color_sim_cutoff);
947 : dsouza 1.1
948 : dsouza 1.25 # Build up hash of blast hits
949 :     foreach my $hit ( @$hits )
950 :     {
951 :     my($peg1, $peg2, $sc) = (split(/\s+/, $hit))[0,1,10];
952 : parrello 1.11
953 : dsouza 1.25 if ( $peg1 ne $peg2 )
954 :     {
955 :     $blast_hit{$peg1}{$peg2} = 1;
956 :     $blast_hit{$peg2}{$peg1} = 1;
957 :     }
958 :     }
959 : dsouza 1.1 }
960 :    
961 :     return \%blast_hit;
962 :     }
963 :    
964 :     sub blast_hits_from_sims {
965 : dsouza 1.25 my($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff) = @_;
966 : dsouza 1.1
967 :     my %blast_hit;
968 :    
969 :     my $maxN = 2000;
970 :     my $maxP = $color_sim_cutoff;
971 :     my $select = 'fig';
972 :     my $max_expand = '';
973 :     my $filters = '';
974 :    
975 :     # Create a hash of all pegs
976 :     my %region_peg = map {$_ => 1} grep {$feature_data->{$_}{'type'} eq 'peg'} keys %$feature_data;
977 :    
978 : dsouza 1.25 if ( $fast_color == 1 )
979 : dsouza 1.1 {
980 : dsouza 1.25 my $cutoff_2 = $color_sim_cutoff * 1e-20;
981 :     my %done_with;
982 :    
983 :     # Iterate through each peg
984 :     foreach my $peg1 ( keys %region_peg )
985 :     {
986 :     # Skip the 'done_with' pegs
987 :     next if ($done_with{$peg1});
988 : dsouza 1.1
989 : dsouza 1.25 my @sims = $fig->sims($peg1, $maxN, $maxP, $select, $max_expand, $filters);
990 : parrello 1.11
991 : dsouza 1.25 foreach my $sim ( grep {$region_peg{$_->[1]} and $_->[1] ne $peg1} @sims )
992 :     {
993 :     my($peg2, $sc) = @$sim[1,10];
994 : parrello 1.11
995 : dsouza 1.25 $blast_hit{$peg1}{$peg2} = 1;
996 :     $blast_hit{$peg2}{$peg1} = 1;
997 :    
998 :     # If the blast score is less than the chosen cutoff, mark $peg2 as 'done_with' so
999 :     # that it will not be blasted with it's region sequences
1000 :     if ( $sc <= $cutoff_2 )
1001 :     {
1002 :     $done_with{$peg2} = 1;
1003 :     }
1004 :     }
1005 :     }
1006 :     }
1007 :     else
1008 : dsouza 1.1 {
1009 : dsouza 1.25 # Iterate through each peg
1010 :     foreach my $peg1 ( keys %region_peg )
1011 :     {
1012 :     my @sims = $fig->sims($peg1, $maxN, $maxP, $select, $max_expand, $filters);
1013 :    
1014 :     foreach my $peg2 ( map {$_->[1]} grep {$region_peg{$_->[1]} and $_->[1] ne $peg1} @sims )
1015 :     {
1016 :     $blast_hit{$peg1}{$peg2} = 1;
1017 :     $blast_hit{$peg2}{$peg1} = 1;
1018 :     }
1019 :     }
1020 : dsouza 1.1 }
1021 : dsouza 1.25
1022 :     return \%blast_hit;
1023 : dsouza 1.1 }
1024 :    
1025 :     sub blast_files {
1026 :     my($fig, $input, $database, $cutoff) = @_;
1027 :    
1028 : dsouza 1.24 my $cmd = "$FIG_Config::ext_bin/blastall";
1029 :     my @args = ('-p', 'blastp', '-i', $input, '-d', $database, '-m', 8, '-e', $cutoff);
1030 :     my @blast_out = $fig->run_gathering_output($cmd, @args);
1031 : dsouza 1.25
1032 : dsouza 1.24 return \@blast_out;
1033 :     }
1034 : overbeek 1.23
1035 : dsouza 1.1 sub formatdb_file {
1036 :     my($fig, $file) = @_;
1037 :    
1038 :     my $cmd = "$FIG_Config::ext_bin/formatdb -i $file -p T";
1039 :     $fig->run($cmd);
1040 :     }
1041 :    
1042 :     sub write_seqs_to_file {
1043 :     my($seq, $fasta_file) = @_;
1044 :    
1045 :     open(FASTA, ">$fasta_file") or die "could not create FASTA file '$fasta_file': $!";
1046 :     foreach my $peg ( keys %$seq )
1047 :     {
1048 : parrello 1.11 print FASTA ">$peg\n$seq->{$peg}\n";
1049 : dsouza 1.1 }
1050 :     close(FASTA) or die "could not close file FASTA file '$fasta_file': $!";
1051 :     }
1052 :    
1053 :     sub get_peg_sequences {
1054 : dsouza 1.21 my($fig, $pegs) = @_;
1055 : dsouza 1.1 my %sequences;
1056 :    
1057 :     # Iterate over each peg
1058 : dsouza 1.21 foreach my $peg ( @$pegs )
1059 : dsouza 1.1 {
1060 : parrello 1.11 my $seq = $fig->get_translation($peg);
1061 : dsouza 1.1
1062 : parrello 1.11 if ( $seq )
1063 :     {
1064 :     $sequences{$peg} = $seq;
1065 :     }
1066 :     else
1067 :     {
1068 :     print STDERR "could not get sqeuence for $peg\n";
1069 :     }
1070 : dsouza 1.1 }
1071 :    
1072 :     return \%sequences;
1073 :     }
1074 :    
1075 :    
1076 :     1;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3