[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.12, Thu Dec 6 00:07:06 2007 UTC revision 1.13, Wed Feb 13 14:54:27 2008 UTC
# Line 17  Line 17 
17  ########################################################################  ########################################################################
18    
19  use strict;  use strict;
20    use warnings;
21    
22  use FIG;  use FIG;
23  my $fig = new FIG;  my $fig = new FIG;
24    
25  use NewGenome;  use NewGenome;
26  use ToCall;  use ToCall;
27    
28    $0 =~ m/([^\/]+)$/o;
29    my $self  = $1;
30  my $usage = "usage: promote_orfs_to_pegs To_Call_Dir FoundFamiliesFile";  my $usage = "usage: promote_orfs_to_pegs To_Call_Dir FoundFamiliesFile";
31    
32  if (@ARGV && ($ARGV[0] =~ m/-h(elp)?/)) {  if (@ARGV && ($ARGV[0] =~ m/-h(elp)?/)) {
# Line 42  Line 46 
46  $to_call_dir =~ s/\/$//o;  $to_call_dir =~ s/\/$//o;
47    
48  my $to_call;  my $to_call;
49  $to_call = new NewGenome($to_call_dir,"all");  $to_call = NewGenome->new($to_call_dir, "all");
50    
51  my @neighbors = map { m/^(\d+\.\d+)/o ? ($1) : () } `cat $to_call_dir/neighbors`;  my @neighbors = map { m/^(\d+\.\d+)/o ? ($1) : () } `cat $to_call_dir/neighbors`;
52    
53    open(CALLED_BY, ">>$to_call_dir/called_by")
54        || die "could not open $to_call_dir/called_by";
55    
56  #...Build file of "nearby" PEGs  #...Build file of "nearby" PEGs
57  if (@neighbors) {  if (@neighbors) {
58      my $tmp_close = "$FIG_Config::temp/tmp_close_$$.fasta";      my $tmp_close = "$FIG_Config::temp/tmp_close_$$.fasta";
# Line 66  Line 73 
73              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);
74    
75              if (@$sims) {              if (@$sims) {
76                  print STDERR "Promoting $orf_id based on ", (scalar @$sims), " sims\n" if $ENV{VERBOSE};                  my $num_sims = (scalar @$sims);
77                    print STDERR "Promoting $orf_id based on $num_sims sims\n" if $ENV{VERBOSE};
78    
79                  my $orf = &NewGenome::ORF::new('NewGenome::ORF', $to_call, $orf_id);                  my $orf = &NewGenome::ORF::new('NewGenome::ORF', $to_call, $orf_id);
80                  my $fid = $orf->promote_to_peg($sims)                  my $annot  = [ qq(RAST),
81                      || die "Could not promote ORF $orf_id to a PEG";                                 qq(Called by "$self" based on $num_sims sims.)
82                                   ];
83                    my $fid = $orf->promote_to_peg($sims, undef, $annot);
84                    if ($fid) {
85                  push @promoted_fids, $fid;                  push @promoted_fids, $fid;
86                  @$sims = map { $_->[0] = $fid; $_ } @$sims;                  @$sims = map { $_->[0] = $fid; $_ } @$sims;
87                  print TMP_SIMS map { join("\t", @$_) . qq(\n) } @$sims;                  print TMP_SIMS map { join("\t", @$_) . qq(\n) } @$sims;
88    
89                        print CALLED_BY "$fid\tpromote_remaining_orfs (with sims)\n";
90    
91                        print STDERR "Succeeded:\t$orf_id --> $fid\n";
92                    }
93                    else {
94                        print STDERR "Could not promote ORF $orf_id to a PEG\n";
95                    }
96              }              }
97              else {              else {
98                  print STDERR "No sims for $orf_id\n" if $ENV{VERBOSE};                  print STDERR "No sims for $orf_id\n" if $ENV{VERBOSE};
# Line 95  Line 114 
114          my @auto_assigns = `cat $tmp_seqs | auto_assign sims=$tmp_sims`;          my @auto_assigns = `cat $tmp_seqs | auto_assign sims=$tmp_sims`;
115    
116          open(FOUND, ">>$found_file")          open(FOUND, ">>$found_file")
117              || die "Could not write-open FoundFamiliesFile $found_file";              || die "Could not append-open FoundFamiliesFile $found_file";
118          foreach my $entry (@auto_assigns) {          foreach my $entry (@auto_assigns) {
119              if ($entry =~ m/^(\S+)\t(.*)$/o) {              if ($entry =~ m/^(\S+)\t(.*)$/o) {
120                  if ($to_call->set_function($1, $2)) {                  if ($to_call->set_function($1, $2)) {
# Line 120  Line 139 
139    
140    
141  #...Promote any remaining unpromoted ORFs...  #...Promote any remaining unpromoted ORFs...
142  $to_call->promote_remaining_orfs;  $to_call->promote_remaining_orfs(\*CALLED_BY);
143    
144    close(CALLED_BY);
145    
146  #...NOTE: export_features also writes assigned_functions  #...NOTE: export_features also writes assigned_functions
147  $to_call->export_features;  $to_call->export_features;

Legend:
Removed from v.1.12  
changed lines
  Added in v.1.13

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3