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

Diff of /FigKernelPackages/PinnedRegions.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.20, Thu Jun 4 12:30:37 2009 UTC revision 1.21, Wed Jun 24 19:52:31 2009 UTC
# Line 16  Line 16 
16  # http://www.theseed.org/LICENSE.TXT.  # http://www.theseed.org/LICENSE.TXT.
17  ########################################################################  ########################################################################
18    
   
19  package PinnedRegions;  package PinnedRegions;
20    
21  use strict;  use strict;
# Line 111  Line 110 
110              # First add input peg, then sort by phylogeny              # First add input peg, then sort by phylogeny
111              @pegs = $fig->sort_fids_by_taxonomy($peg, @$sim_pegs, @$pch_pinned_pegs);              @pegs = $fig->sort_fids_by_taxonomy($peg, @$sim_pegs, @$pch_pinned_pegs);
112          }          }
113          else          elsif ( $pin_desc->{'sort_by'} eq 'phylogenetic_distance' )
114          {          {
115              # Sort by phylogenetic distance or organism name              # Sort by phylogenetic distance or organism name
116              my $g1 = $fig->genome_of($peg);              my $g1 = $fig->genome_of($peg);
# Line 121  Line 120 
120              # Add input peg at front of list              # Add input peg at front of list
121              unshift @pegs, $peg;              unshift @pegs, $peg;
122          }          }
123            elsif ( $pin_desc->{'sort_by'} eq 'similarity' )
124            {
125                # Sort by similarity to input peg (first peg in list of arguments)
126                @pegs = &sort_pegs_by_similarity($fig, $peg, @$sim_pegs, @$pch_pinned_pegs);
127       }       }
128         }
129    
130      return \@pegs      return \@pegs
131  }  }
132    
# Line 235  Line 239 
239      return $pegs;      return $pegs;
240  }  }
241    
242    sub sort_pegs_by_similarity {
243        my($fig, $input_peg, @other_pegs) = @_;
244    
245        # Set blast environment variables
246        $ENV{"BLASTMAT"} ||= "$FIG_Config::blastmat";
247        if ($ENV{"PATH"} !~ /fig\/bin/) { $ENV{"PATH"} = "$FIG_Config::bin:" . $ENV{"PATH"}; }
248    
249        # Get amino acid sequences
250        my $sequences = &get_peg_sequences($fig, [$input_peg, @other_pegs]);
251    
252        # Write the input peg sequence to a fasta file
253        my $input_seq = {$input_peg => $sequences->{$input_peg}};
254        my $input_seq_file = "$FIG_Config::temp/input_seq.$$.tmp.fasta";
255        &write_seqs_to_file($input_seq, $input_seq_file);
256    
257        # Write the other peg sequences to a fasta file
258        delete $sequences->{$input_peg};
259        my $other_seq_file = "$FIG_Config::temp/other_seq.$$.tmp.fasta";
260        &write_seqs_to_file($sequences, $other_seq_file);
261    
262        # Run formatdb
263        &formatdb_file($fig, $other_seq_file);
264    
265        # BLAST input peg sequence against other peg sequences
266        # set high evalue cutoff so all hits get reported
267        my $cutoff = 10;
268        my $hits = &blast_files($fig, $input_seq_file, $other_seq_file, $cutoff);
269    
270        my @sorted = ($input_peg);
271        foreach my $hit ( @$hits )
272        {
273            # BLAST output is already sorted by similarity
274            my($peg2) = (split(/\s+/, $hit))[1];
275            push @sorted, $peg2;
276        }
277    
278        return @sorted;
279    }
280    
281  sub filter_regions_1 {  sub filter_regions_1 {
282      my($pin_desc, $regions) = @_;      my($pin_desc, $regions) = @_;
283      my $new_regions;      my $new_regions;
# Line 818  Line 861 
861    
862  sub blast_hits {  sub blast_hits {
863      my($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff) = @_;      my($fig, $regions, $feature_data, $fast_color, $color_sim_cutoff) = @_;
     my($t0, $dt);  
864    
865      # Set blast environment variables      # Set blast environment variables
866      $ENV{"BLASTMAT"} ||= "$FIG_Config::blastmat";      $ENV{"BLASTMAT"} ||= "$FIG_Config::blastmat";
867      if ($ENV{"PATH"} !~ /fig\/bin/) { $ENV{"PATH"} = "$FIG_Config::bin:" . $ENV{"PATH"}; }      if ($ENV{"PATH"} !~ /fig\/bin/) { $ENV{"PATH"} = "$FIG_Config::bin:" . $ENV{"PATH"}; }
868    
869      # Get amino acid sequences      # Get amino acid sequences
870      my $sequences = &get_peg_sequences($fig, $feature_data);      my @pegs = grep {$feature_data->{$_}{'type'} eq 'peg'} keys %$feature_data;
871        my $sequences = &get_peg_sequences($fig, \@pegs);
872    
873      # Write the entire set of sequences to a fasta file      # Write the entire set of sequences to a fasta file
874      my $all_seqs_file = "$FIG_Config::temp/all_seqs.$$.tmp.fasta";      my $all_seqs_file = "$FIG_Config::temp/all_seqs.$$.tmp.fasta";
# Line 1003  Line 1046 
1046  }  }
1047    
1048  sub get_peg_sequences {  sub get_peg_sequences {
1049      my($fig, $feature_data) = @_;      my($fig, $pegs) = @_;
1050      my %sequences;      my %sequences;
1051    
1052      # Iterate over each peg      # Iterate over each peg
1053      foreach my $peg ( grep {$feature_data->{$_}{'type'} eq 'peg'} keys %$feature_data )      foreach my $peg ( @$pegs )
1054      {      {
1055          my $seq = $fig->get_translation($peg);          my $seq = $fig->get_translation($peg);
1056    

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3