Changeset 258
- Timestamp:
- 09/08/09 11:32:56 (3 months ago)
- Files:
-
- MPI/mpi_iprscan (modified) (7 diffs)
- lib/Process/IPRchunk.pm (modified) (8 diffs)
- lib/Process/MpiTiers.pm (modified) (2 diffs)
- lib/iprscan (added)
- lib/iprscan/runlog.pm (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
MPI/mpi_iprscan
r256 r258 168 168 169 169 #---global variables 170 my %OPT; 170 my %CTL_OPT; 171 my @appl; 172 171 173 my $root = 0; #define root node (only changed for debugging) 172 174 173 175 #---Process options on the command line 174 my $infile; 175 my $outfile; 176 my @appl; 177 my $chpc; 178 my $cli; #always enabled, just here for implementation 179 180 GetOptions("i=s" => \$infile, 181 "o=s" => \$outfile, 182 "appl=s" => \@appl, 183 "chpc" => \$chpc, #hidden option used on the CHPC's computer farm 184 "cli" => \$cli, #just used to strip off the option 176 GetOptions("i=s" => \$CTL_OPT{infile}, 177 "o=s" => \$CTL_OPT{outfile}, 178 "appl=s" => \@appl, 179 "nocrc" => $CTL_OPT{nocrc}, 180 "seqtype=s" => $CTL_OPT{seqtype}, 181 "trtable=i" => $CTL_OPT{trtable}, 182 "goterms" => $CTL_OPT{goterms}, 183 "iprlookup" => $CTL_OPT{iprlookup}, 184 "format=s" => $CTL_OPT{format}, 185 "verbose" => $CTL_OPT{verbose}, 186 "chpc" => \$CTL_OPT{chpc}, #hidden option used on the CHPC's computer farm 187 "cli" => \$CTL_OPT{cli}, #just used to strip off the option 185 188 ); 186 189 187 $main::quiet = 1 ; #suppress status messages190 $main::quiet = 1 unless($CTL_OPT{verbose}); #suppress status messages 188 191 189 192 if(! @appl){ … … 204 207 } 205 208 206 #build localized database for each node 207 if($chpc && ! -e "$TMP/iprscan/data/ok"){ 209 $CTL_OPT{appl} = \@appl; #apply apps to CTL_OPT 210 211 #build localized iprscan database for each node 212 if($CTL_OPT{chpc} && ! -e "$TMP/iprscan/data/ok"){ 208 213 my $lock = new File::NFSLock("$TMP/.iprscan_lock", 'EX', 1200, 1205); 209 214 … … 278 283 #---test command line options here 279 284 #test input files existance 280 if($ infile && ! -e $infile){281 die "ERROR: The input file \'$ infile\' does not exist.\n";285 if($CTL_OPT{infile} && ! -e $CTL_OPT{infile}){ 286 die "ERROR: The input file \'$CTL_OPT{infile}\' does not exist.\n"; 282 287 } 283 288 … … 286 291 my $exe = "$EXE -cli"; 287 292 my $command = "$exe " . join(' ', @ARGV); 288 $command .= " -appl " . join(" -appl ", @appl) if(@appl); 289 $command .= " -i $tfile" if($infile); #test options on dummy file 293 $command .= " -nocrc" if($CTL_OPT{nocrc}); 294 $command .= " -seqtype $CTL_OPT{seqtype}" if(defined $CTL_OPT{seqtype}); 295 $command .= " -trtable $CTL_OPT{trtable}" if(defined $CTL_OPT{trtable}); 296 $command .= " -goterms" if($CTL_OPT{goterms}); 297 $command .= " -iprlookup" if($CTL_OPT{iprlookup}); 298 $command .= " -format $CTL_OPT{format}" if(defined $CTL_OPT{format}); 299 $command .= " -appl " . join(" -appl ", @{$CTL_OPT{appl}}) if(@{$CTL_OPT{appl}}); 300 $command .= " -i $tfile" if($CTL_OPT{infile}); #test options on dummy file 290 301 open(my $PAR, "$command 2>&1 |"); 291 302 my @err = <$PAR>; … … 314 325 #---main code for distribution of mpi data starts here 315 326 316 my ($name) = $ infile=~ /([^\/]+)$/;317 $name = $ outfile if($outfile);327 my ($name) = $CTL_OPT{infile} =~ /([^\/]+)$/; 328 $name = $CTL_OPT{outfile} if($CTL_OPT{outfile}); 318 329 319 330 my $DS_CTL = new basiclog("$name.log"); 320 my $iterator = new Iterator::Fasta($ infile);331 my $iterator = new Iterator::Fasta($CTL_OPT{infile}); 321 332 322 333 #thread for root node to do other things than just manage mpi … … 367 378 my $tier; 368 379 while (my $fasta = $iterator->nextFasta() || shift @failed){ 369 $tier = Process::MpiTiers->new({fasta => $fasta, 370 appl => \@appl, 371 params => \@ARGV, 372 iprscan => "$EXE -cli", 373 infile => $infile, 374 outfile => $outfile, 375 DS_CTL => $DS_CTL}, 380 $tier = Process::MpiTiers->new({fasta => $fasta, 381 CTL_OPT => \%CTL_OPT 382 params => \@ARGV, 383 iprscan => "$EXE -cli", 384 DS_CTL => $DS_CTL}, 376 385 $root, 377 386 'Process::IPRchunk' … … 435 444 436 445 while (my $fasta = $iterator->nextFasta() || shift @failed){ 437 $tier = Process::MpiTiers->new({fasta => $fasta, 438 appl => \@appl, 439 params => \@ARGV, 440 iprscan => "$EXE -cli", 441 infile => $infile, 442 outfile => $outfile, 443 DS_CTL => $DS_CTL}, 444 $who, 445 'Process::IPRchunk' 446 ); 446 $tier = Process::MpiTiers->new({fasta => $fasta, 447 CTL_OPT => \%CTL_OPT 448 params => \@ARGV, 449 iprscan => "$EXE -cli", 450 DS_CTL => $DS_CTL}, 451 $who, 452 'Process::IPRchunk' 453 ); 447 454 448 455 last if(! $tier->terminated); lib/Process/IPRchunk.pm
r256 r258 116 116 #=== 117 117 118 my ($outname) = $VARS->{ infile} =~ /([^\/]+)$/;119 $outname = $VARS->{ outfile} if($VARS->{outfile});118 my ($outname) = $VARS->{CTL_OPT}{infile} =~ /([^\/]+)$/; 119 $outname = $VARS->{CTL_OPT}{outfile} if($VARS->{outfile}); 120 120 121 121 $VARS->{seq_id} = Fasta::getSeqID(\$VARS->{fasta}); 122 122 $VARS->{safe_id} = Fasta::seqID2SafeID($VARS->{seq_id}); 123 $VARS->{c_flag} = $VARS->{DS_CTL}->continue_flag($VARS->{seq_id}); 124 125 my $failed .= "$outname.failed/".$VARS->{safe_id}.".fasta"; 126 127 if(! $VARS->{c_flag}){ 128 warn "WARNING: ".$VARS->{seq_id} ."failed 2 time and will not be tried again\n", 129 "The fasta sequence will be saved for debugging in $failed\n"; 130 131 mkdir("$outname.failed") if(! -d "$outname.failed"); 132 133 open(my $OUT, ">$failed"); 134 print $OUT $VARS->{fasta}; 135 close($OUT); 136 $VARS->{DS_CTL}->add_entry($VARS->{seq_id}, 'DIED_PERMANENT'); 137 } 138 else{ 139 unlink($failed) if(-e $failed); #remove old failed 140 } 141 142 $VARS->{DS_CTL}->add_entry($VARS->{seq_id}, 'STARTED'); 123 124 #set up base and void directories for output 125 ($VARS->{out_dir}, $VARS->{the_void}) = $VARS->{DS_CTL}->seq_dirs($VARS->{seq_id}); 126 127 #contig combined output file 128 $VARS->{cfile} = $VARS->{out_dir}."/".$VARS->{safe_id}.".ipr"; 129 130 #=== 131 $status = 'trying to build/process the run.log file'; 132 #=== 133 134 $VARS->{LOG} = iprscan::runlog->new($VARS->{CTL_OPT}, 135 {seq_id => $VARS->{seq_id}, 136 seq_length => length(${$VARS->{q_seq_ref}}), 137 out_dir => $VARS->{out_dir}, 138 the_void => $VARS->{the_void}, 139 fasta_ref => \$VARS->{fasta}}, 140 $VARS->{the_void}."/run.log" 141 ); 142 143 ($VARS->{c_flag}, my $message) = $VARS->{LOG}->get_continue_flag(); 144 $VARS->{DS_CTL}->add_entry($VARS->{seq_id}, $VARS->{out_dir}, $message); 145 if($VARS->{c_flag} == 0){ 146 my $cfile = $VARS->{c_flag}; 147 die "ERROR: Can't find $cfile yet iprscan::runlog says the contig is finished\n" 148 if(! -e $cfile); 149 150 my $lock = new File::NFSLock(".iprscan_lock", 'EX', 40, 40); 151 my $outfile = $VARS->{CTL_OPT}{outfile}; 152 153 my $FH; 154 if($outfile){ 155 open($FH, ">> $outfile"); 156 } 157 else{ 158 open($FH, ">&STDOUT"); 159 } 160 161 my $CFH; 162 open($CFH, "> $cfile"); 163 164 while(my $key = each %{$VARS}){ 165 next if($key eq 'outfile'); 166 print $FH $VARS->{$key}; 167 print $CFH $cfile; 168 } 169 170 close($FH); 171 close($CFH); 172 173 $lock->unlock; 174 } 143 175 } 144 176 catch Error::Simple with { … … 287 319 if ($flag eq 'load') { 288 320 #-------------------------CHUNKER 289 foreach my $app (@{$VARS->{ appl}}) {321 foreach my $app (@{$VARS->{CTL_OPT}{appl}}) { 290 322 $VARS->{app} = $app; 291 323 my $chunk = new Process::IPRchunk($level, $VARS); … … 296 328 elsif ($flag eq 'init') { 297 329 #------------------------ARGS_IN 298 @args = (qw{safe_fasta 330 @args = (qw{CTL_OPT 331 safe_fasta 299 332 app 300 333 params 301 334 iprscan 335 the_void 302 336 } 303 337 ); … … 306 340 elsif ($flag eq 'run') { 307 341 #-------------------------CODE 342 my %CTL_OPT = %{$VARS->{CTL_OPT}}; 308 343 my $safe_fasta = $VARS->{safe_fasta}; 309 344 my $app = $VARS->{app}; 310 345 my $params = $VARS->{params}; 311 346 my $iprscan = $VARS->{iprscan}; 347 my $the_void = $VARS->{the_void}; 312 348 313 349 #make files 314 350 my (undef, $ifile) = tempfile(); 315 my (undef, $ofile) = tempfile();351 my $ofile = "$the_void/$CTL_OPT{safe_id}.$app"; 316 352 FastaFile::writeFile($safe_fasta, $ifile); 317 353 318 354 #build command 319 my $command = $iprscan . " " . join(' ', @$params); 355 my $command = $iprscan; 356 $command .= " -nocrc" if($CTL_OPT{nocrc}); 357 $command .= " -seqtype $CTL_OPT{seqtype}" if(defined $CTL_OPT{seqtype}); 358 $command .= " -trtable $CTL_OPT{trtable}" if(defined $CTL_OPT{trtable}); 359 $command .= " -goterms" if($CTL_OPT{goterms}); 360 $command .= " -iprlookup" if($CTL_OPT{iprlookup}); 361 $command .= " -format $CTL_OPT{format}" if(defined $CTL_OPT{format}); 362 $command .= " " . join(' ', @$params); 320 363 $command .= " -appl $app -i $ifile -o $ofile"; 321 364 322 365 my $w = new Widget::iprscan(); 323 print STDERR "running iprscan $app...\n" unless($main::quiet); 324 $w->run($command); 366 if(-e $ofile){ 367 print STDERR "rereading $ofile...\n" unless($main::quiet); 368 } 369 else{ 370 print STDERR "running iprscan $app...\n" unless($main::quiet); 371 $w->run($command); 372 } 325 373 326 374 unlink($ifile); … … 331 379 } 332 380 close($IN); 333 unlink($ofile);334 381 #-------------------------CODE 335 382 … … 354 401 elsif ($flag eq 'init') { 355 402 #------------------------ARGS_IN 356 @args = (qw{outfile}, 357 @{$VARS->{appl}} 403 @args = (qw{CTL_OPT 404 cfile 405 outfile 406 }, 407 @{$VARS->{CTL_OPT}{appl}} 358 408 ); 359 409 #------------------------ARGS_IN … … 361 411 elsif ($flag eq 'run') { 362 412 #-------------------------CODE 363 my $outfile = $VARS->{outfile}; 413 my $cfile = $VARS->{cfile}; #combined contig output file 414 my $outfile = $VARS->{outfile}; #combined every contig output file 364 415 365 416 my $lock = new File::NFSLock(".iprscan_lock", 'EX', 40, 40); … … 373 424 } 374 425 426 my $CFH; 427 open($CFH, "> $cfile"); 428 375 429 while(my $key = each %{$VARS}){ 376 430 next if($key eq 'outfile'); 377 431 print $FH $VARS->{$key}; 432 print $CFH $cfile; 378 433 } 434 379 435 close($FH); 436 close($CFH); 380 437 381 438 $lock->unlock; lib/Process/MpiTiers.pm
r256 r258 4 4 5 5 use strict; 6 use FindBin; 7 use lib "$FindBin::Bin/../lib"; 8 use lib "$FindBin::Bin/../perl/lib"; 6 9 use Error qw(:try); 7 10 use Error::Simple; … … 43 46 #optionaly override chunk type 44 47 $self->{CHUNK_REF} = shift @args || "Process::MpiChunk"; 48 require $self->{CHUNK_REF}; 45 49 $self->{CHUNK_REF} = new $self->{CHUNK_REF}; #turn into object 46 50
