[Bio] / FigKernelScripts / promote_orfs_to_pegs.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/promote_orfs_to_pegs.pl

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

revision 1.14, Fri Jul 16 15:09:17 2010 UTC revision 1.15, Tue Nov 23 18:22:21 2010 UTC
# Line 56  Line 56 
56      ) {      ) {
57      @neighbors = map { m/^(\d+\.\d+)/o ? ($1) : () } &FIG::file_read($neighbors_file);      @neighbors = map { m/^(\d+\.\d+)/o ? ($1) : () } &FIG::file_read($neighbors_file);
58  }  }
59    else {
60        warn qq(WARNING: $self could not read either nearest neighbors file\n);
61    }
62    
63  open(CALLED_BY, ">>$to_call_dir/called_by")  open(CALLED_BY, ">>$to_call_dir/called_by")
64      || die "could not open $to_call_dir/called_by";      || die "could not open $to_call_dir/called_by";
65    
66  #...Build file of "nearby" PEGs  #...Build file of "nearby" PEGs
67  if (@neighbors) {  if (@neighbors == 0) {
68        warn qq($self: No nearby genomes found --- Skipping promotion based on sims\n);
69    }
70    else {
71      my $tmp_close = "$FIG_Config::temp/tmp_close_$$.fasta";      my $tmp_close = "$FIG_Config::temp/tmp_close_$$.fasta";
72      system("/bin/rm -f $tmp_close*");      system("/bin/rm -f $tmp_close*");
73    
# Line 70  Line 75 
75          print STDERR "Appending $org to $tmp_close\n" if $ENV{VERBOSE};          print STDERR "Appending $org to $tmp_close\n" if $ENV{VERBOSE};
76          system("cat $FIG_Config::organisms/$org/Features/peg/fasta >> $tmp_close");          system("cat $FIG_Config::organisms/$org/Features/peg/fasta >> $tmp_close");
77      }      }
78    
79        if (!-s $tmp_close) {
80            warn qq($self: Something is wrong --- Could not find any PEG sequences for nearby genomes);
81        }
82        else {
83      &FIG::run("formatdb -i$tmp_close -pT");      &FIG::run("formatdb -i$tmp_close -pT");
84    
85      my @promoted_fids;      my @promoted_fids;
# Line 77  Line 87 
87      open(TMP_SIMS, ">$tmp_sims")      open(TMP_SIMS, ">$tmp_sims")
88          || die "Could not write-open $tmp_sims";          || die "Could not write-open $tmp_sims";
89      foreach my $orf_id ($to_call->get_fids_for_type('orf')) {      foreach my $orf_id ($to_call->get_fids_for_type('orf')) {
         if (@neighbors) {  
90              my $sims = &blast_against($to_call->get_feature_sequence($orf_id), $tmp_close);              my $sims = &blast_against($to_call->get_feature_sequence($orf_id), $tmp_close);
91    
92              if (@$sims) {              if (@$sims) {
# Line 106  Line 115 
115                  print STDERR "No sims for $orf_id\n" if $ENV{VERBOSE};                  print STDERR "No sims for $orf_id\n" if $ENV{VERBOSE};
116              }              }
117          }          }
118      }  
119            if (not $ENV{DEBUG}) {
120                #...Clean up...
121      close(TMP_SIMS) || die "Could not close $tmp_sims";      close(TMP_SIMS) || die "Could not close $tmp_sims";
122                unlink($tmp_sims)  || die "Could not remove $tmp_sims";
123                unlink($tmp_close) || die "Could not remove $tmp_close";
124            }
125        }
126    
127  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++  #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
128  # Disable the auto assignment of the fids we just called.  # Disable the old auto assignment of the fids we just called.
129  #=======================================================================  #=======================================================================
130      if (0)  #     if (0)
131      {  #     {
132          my $tmp_seqs = "$FIG_Config::temp/tmp_seqs.$$";  #       my $tmp_seqs = "$FIG_Config::temp/tmp_seqs.$$";
133          open(TMP_SEQS, ">$tmp_seqs")  #       open(TMP_SEQS, ">$tmp_seqs")
134              || die "Could not write-open $tmp_seqs";  #           || die "Could not write-open $tmp_seqs";
135          print TMP_SEQS map { join("\t", ($_, $to_call->get_feature_sequence($_))) . qq(\n) } @promoted_fids;  #       print TMP_SEQS map { join("\t", ($_, $to_call->get_feature_sequence($_))) . qq(\n) } @promoted_fids;
136          close(TMP_SEQS) || die "Could not close $tmp_seqs";  #       close(TMP_SEQS) || die "Could not close $tmp_seqs";
137          my @auto_assigns = `cat $tmp_seqs | auto_assign sims=$tmp_sims`;  #       my @auto_assigns = `cat $tmp_seqs | auto_assign sims=$tmp_sims`;
138    #
139    #       open(FOUND, ">>$found_file")
140    #           || die "Could not append-open FoundFamiliesFile $found_file";
141    #       foreach my $entry (@auto_assigns) {
142    #           if ($entry =~ m/^(\S+)\t(.*)$/o) {
143    #               if ($to_call->set_function($1, $2)) {
144    #                   print FOUND "$1\tCLOSE_SIMS\t$2\n";
145    #               }
146    #               else {
147    #                   die "Could not set function of $1 to $2";
148    #               }
149    #           }
150    #           else {
151    #               die "Could not parse auto-assignment: $entry";
152    #           }
153    #       }
154    #       close(FOUND) || die "Could not close $found_file";
155    #       unlink($tmp_seqs)  || die "Could not remove $tmp_seqs";
156    #     }
157    #-----------------------------------------------------------------------
158    
         open(FOUND, ">>$found_file")  
             || die "Could not append-open FoundFamiliesFile $found_file";  
         foreach my $entry (@auto_assigns) {  
             if ($entry =~ m/^(\S+)\t(.*)$/o) {  
                 if ($to_call->set_function($1, $2)) {  
                     print FOUND "$1\tCLOSE_SIMS\t$2\n";  
                 }  
                 else {  
                     die "Could not set function of $1 to $2";  
                 }  
             }  
             else {  
                 die "Could not parse auto-assignment: $entry";  
             }  
         }  
         close(FOUND) || die "Could not close $found_file";  
         unlink($tmp_seqs)  || die "Could not remove $tmp_seqs";  
159      }      }
160    
     unlink($tmp_sims)  || die "Could not remove $tmp_sims";  
     unlink($tmp_close) || die "Could not remove $tmp_close";  
 }  
 #-----------------------------------------------------------------------  
161    
162    
163  #...Promote any remaining unpromoted ORFs...  #...Promote any remaining unpromoted ORFs...

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3