root/bin/evaluator

Revision 198, 5.7 kB (checked in by cholt, 8 months ago)

Changed back to three control files, and added mpi_evaluator

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl -w
2
3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4     if 0; # not running under some shell
5
6 use strict "vars";
7 use strict "refs";
8
9 use FindBin;
10 use lib "$FindBin::Bin/../lib";
11 use lib "$FindBin::Bin/../perl/lib";
12 use vars qw($RANK $LOG $CMD_ARGS);
13
14 BEGIN{
15    $main::eva = 1; #tells scripts this is evaluator
16
17    if (not ($ENV{CGL_SO_SOURCE})) {
18       $ENV{CGL_SO_SOURCE} = "$FindBin::Bin/../lib/CGL/so.obo";
19    }
20    if (not ($ENV{CGL_GO_SOURCE})) {
21       $ENV{CGL_GO_SOURCE} = "$FindBin::Bin/../lib/CGL/gene_ontology.obo"
22    }
23    
24    $CMD_ARGS = join(' ', @ARGV);
25    
26    #what to do on ^C
27    $SIG{'INT'} = sub {
28       print STDERR "\n\nProgram aborted by user!!\n\n";
29       exit (1);
30    };   
31    
32    #supress warnings from storable module
33    $SIG{'__WARN__'} = sub {
34       warn $_[0] if ( $_[0] !~ /Not a CODE reference/ &&
35                       $_[0] !~ /Can\'t store item CODE/
36                     );
37    };
38
39    #output to log file of seq that caused rank to die
40    $SIG{'__DIE__'} =
41    sub {
42       if (defined ($LOG) && defined $_[0]) {
43          my $die_count = $LOG->get_die_count();
44          $die_count++;
45          
46          $LOG->add_entry("DIED","RANK",$RANK);
47          $LOG->add_entry("DIED","COUNT",$die_count);
48       }
49
50       die "#----------------------\n",
51           "FATAL: failed!!\n",
52           "#----------------------\n",
53           $_[0] . "\n";
54    };
55 }
56
57 use Cwd;
58 use FileHandle;
59 use File::Path;
60 use Getopt::Long;
61 use File::Temp qw(tempfile tempdir);
62 use Bio::DB::Fasta;
63 use GI;
64 use Dumper::GFF::GFFV3;
65 use Iterator::Any;
66 use Iterator::Fasta;
67 use Iterator::GFF3;
68 use Fasta;
69 use FastaChunker;
70 use maker::auto_annotator;
71 use cluster;
72 use repeat_mask_seq;
73 use runlog;
74 use ds_utility;
75 use GFFDB;
76 use Error qw(:try);
77 use Error::Simple;
78 use Process::MpiChunk;
79 use Process::MpiTiers;
80
81 $| = 1;
82
83 my $usage = "
84 Usage:
85      mpi_evaluator [options] <eval_opts> <eval_bopts> <eval_exe>
86
87
88 Options:
89
90      -genome_gff <file>  Specify the maker gff file to evaluate.
91
92      -model_gff  <file>  Specify the external gff file to evaluate.
93
94      -genome     <file>  Specify the genome fasta file.  This if optional if the
95                          fasta entries are also found in the gff file.
96
97      -RM_off|R           Turns all repeat masking off.
98
99      -retry   <integer>  Rerun failed contigs up to the specified count.
100
101      -cpus|c  <integer>  Tells how many cpus to use for BLAST analysis.
102
103      -force|f            Forces program to delete old files before running again.
104                          This will require all blast analyses to be rerun.
105      -again|a            Caculate all output files again even if no settings have
106                          changed.
107
108      -quiet|q            Silences most of the status messages.
109
110      -CTL                Generate empty control files in the current directory.
111
112      -help|?             Prints this usage statement.
113
114
115 ";
116
117 #-------------------------------------------------------------------------------
118 #------------------------------------ MAIN -------------------------------------
119 #-------------------------------------------------------------------------------
120
121 #---global variables
122 my %OPT;
123 my $rank = 0;
124 my $size = 1;
125 $RANK = $rank;
126
127 #---Process options on the command line
128 try{
129     GetOptions("RM_off|R" => \$OPT{R},
130                "force|f" => \$OPT{force},
131                "genome|g=s" => \$OPT{genome},
132                "cpus|c=i" => \$OPT{cpus},
133                "predictor=s" =>\$OPT{predictor},
134                "retry=i" =>\$OPT{retry},
135                "evaluate" =>\$OPT{evaluate},
136                "again|a" =>\$OPT{again},
137                "quiet" =>\$main::quiet,
138                "CTL" => sub {GI::generate_control_files(); exit(0);},
139                "help|?" => sub {print $usage; exit(0)}
140                );
141 }
142 catch Error::Simple with{
143     my $E = shift;
144    
145     print STDERR $E->{-text};
146     die "\n\nFailed parsing command line options!!\n\n";
147 };
148
149 #varibles that are persistent outside of try
150 my %CTL_OPT;
151 my $iterator;
152 my $DS_CTL;
153 my $GFF_DB;
154 my $build;
155 my @failed;
156
157 try{
158     #get arguments off the command line
159     my @ctlfiles = @ARGV;
160    
161     if (not @ctlfiles) {
162         if (-e "eval_opts.ctl" &&
163             -e "eval_bopts.ctl" &&
164             -e "eval_exe.ctl"
165             ) {
166            
167             @ctlfiles = ("eval_opts.ctl",
168                          "eval_bopts.ctl",
169                          "eval_exe.ctl"
170                          );
171         }
172         else {
173             print STDERR  "ERROR: Control files not found\n";
174             print $usage;
175             exit(0);
176         }
177     }
178    
179     #--Control file processing
180     
181     #set up control options from control files
182     %CTL_OPT = GI::load_control_files(\@ctlfiles, \%OPT, $size);
183    
184     #--open datastructure controller
185     $DS_CTL = ds_utility->new(\%CTL_OPT);
186    
187     #--set up gff database
188     $GFF_DB = new GFFDB(\%CTL_OPT);
189     $build = $GFF_DB->next_build;
190    
191     #---load genome multifasta/GFF3 file
192     $iterator = new Iterator::Any( -fasta => $CTL_OPT{'genome'},
193                                    -gff => $CTL_OPT{'genome_gff'},
194                                    );
195 }
196 catch Error::Simple with{
197     my $E = shift;
198     print STDERR $E->{-text};
199     print STDERR "\n\nProgram failed while examining startup data\n",
200     "(control files and input fasta files)!!\n\n";
201     my $code = 2;
202     $code = $E->{-value} if (defined($E->{-value}));
203    
204     exit($code);
205 };
206
207 my $tier;
208 while (my $fasta = $iterator->nextFasta() || shift @failed){
209     $tier = Process::MpiTiers->new({fasta =>$fasta,
210                                     CTL_OPT => \%CTL_OPT,
211                                     DS_CTL  => $DS_CTL,
212                                     GFF_DB  => $GFF_DB,
213                                     build   => $build},
214                                    '0'
215                                    );
216
217     next if($tier->terminated);
218     $tier->run while(! $tier->terminated && ! $tier->failed);
219     $DS_CTL->add_entry($tier->DS);
220     push(@failed, $tier->fasta) if ($tier->failed);
221 }
222
223 print STDERR "\n\nProgram is now finished!!!\n\n";
224
225 #-----------------------------------------------------------------------------
226 #----------------------------------- SUBS ------------------------------------
227 #-----------------------------------------------------------------------------
228
Note: See TracBrowser for help on using the browser.