Changeset 209
- Timestamp:
- 04/28/09 15:01:45 (7 months ago)
- Files:
-
- INSTALL (modified) (1 diff)
- MPI/mpi_maker (modified) (3 diffs)
- README (modified) (1 diff)
- lib/File/NFSLock.pm (modified) (3 diffs)
- lib/GI.pm (modified) (16 diffs)
- lib/ds_utility.pm (modified) (1 diff)
- lib/runlog.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
INSTALL
r180 r209 86 86 87 87 a. You will have to download the source code and complile it on your machine. 88 You will also have to install Glib . If your using Mac OS-X you can do this89 by typing fink install glib.88 You will also have to install Glib or Glib 2.0. If your using Mac OS-X you 89 can do this by typing fink install glib and fink install glib2-dev. 90 90 b. Change to the directory containing the Exonerate package to be compiled. 91 91 c. To install exonerate in the directory /usr/local/exonerate, type: MPI/mpi_maker
r198 r209 260 260 "again|a" =>\$OPT{again}, 261 261 "quiet" =>\$main::quiet, 262 "no_thread" =>\$main::no_thread, 262 263 "CTL" => sub {GI::generate_control_files() if($rank == $root); MPI_Finalize(); exit(0);}, 263 264 "help|?" => sub {print $usage if($rank == $root); MPI_Finalize(); exit(0)} … … 343 344 #---main code for distribution of mpi data starts here 344 345 345 #thread for root node to other things than just manage mpi346 #thread for root node to do other things than just manage mpi 346 347 my $thr = threads->create(\&node_thread); 347 348 my $go_mpi_status = 1; 348 $t_need_flag = 1;349 $t_need_flag = ($main::no_thread) ? 0 : 1; #set to true for threads false for no threads 349 350 350 351 while($go_mpi_status){ … … 818 819 my $tier; 819 820 my $chunk; 821 822 if($main::no_thread){ #pause and return if no thread is needed 823 $t_need_flag = 0; 824 return; 825 } 826 820 827 $t_need_flag = 1; 821 828 README
r206 r209 35 35 *Augustus 2.0 or higher (augustus.gobics.de) 36 36 *GeneMark.hmm-E 3.9 or higher (exon.biology.gatech.edu) 37 *FgenesH (www.softberry.com/) - requires licence37 *FgenesH 2.6 or higher (www.softberry.com/) - requires licence 38 38 39 39 To install mpi_maker, you must have an mpi package installed, try the lib/File/NFSLock.pm
r159 r209 133 133 time() + $self->{blocking_timeout} : 0; 134 134 135 ### remove an old lockfile if it is older than the stale_timeout136 if( -e $self->{lock_file} &&137 $self->{stale_lock_timeout} > 0 &&138 time() - (stat _)[9] > $self->{stale_lock_timeout} ){139 unlink $self->{lock_file};140 }141 142 135 while (1) { 136 ### remove an old lockfile if it is older than the stale_timeout 137 if( -e $self->{lock_file} && 138 $self->{stale_lock_timeout} > 0 && 139 time() - (stat _)[9] > $self->{stale_lock_timeout} ){ 140 unlink $self->{lock_file}; 141 } 142 143 143 ### open the temporary file 144 144 $self->create_magic … … 161 161 ### If lock exists and is readable, see who is mooching on the lock 162 162 163 if ( -e $self->{lock_file} && 164 open (_FH,"+<$self->{lock_file}") ){ 165 166 my @mine = (); 167 my @them = (); 168 my @dead = (); 169 170 my $has_lock_exclusive = !((stat _)[2] & $SHARE_BIT); 171 my $try_lock_exclusive = !($self->{lock_type} & LOCK_SH); 172 173 while(defined(my $line=<_FH>)){ 174 if ($line =~ /^$HOSTNAME (\d+) /) { 175 my $pid = $1; 176 if ($pid == $$) { # This is me. 177 push @mine, $line; 178 }elsif(kill 0, $pid) { # Still running on this host. 179 push @them, $line; 180 }else{ # Finished running on this host. 181 push @dead, $line; 182 } 183 } else { # Running on another host, so 184 push @them, $line; # assume it is still running. 185 } 186 } 187 188 ### If there was at least one stale lock discovered... 189 if (@dead) { 190 # Lock lock_file to avoid a race condition. 191 local $LOCK_EXTENSION = ".shared"; 192 my $lock = new File::NFSLock { 193 file => $self->{lock_file}, 194 lock_type => LOCK_EX, 195 blocking_timeout => 62, 196 stale_lock_timeout => 60, 197 }; 198 199 ### Rescan in case lock contents were modified between time stale lock 200 ### was discovered and lockfile lock was acquired. 201 seek (_FH, 0, 0); 202 my $content = ''; 203 while(defined(my $line=<_FH>)){ 204 if ($line =~ /^$HOSTNAME (\d+) /) { 205 my $pid = $1; 206 next if (!kill 0, $pid); # Skip dead locks from this host 207 } 208 $content .= $line; # Save valid locks 209 } 210 211 ### Save any valid locks or wipe file. 212 if( length($content) ){ 213 seek _FH, 0, 0; 214 print _FH $content; 215 truncate _FH, length($content); 216 close _FH; 217 }else{ 218 close _FH; 219 unlink $self->{lock_file}; 220 } 221 222 ### No "dead" or stale locks found. 223 } else { 224 close _FH; 225 } 226 227 ### If attempting to acquire the same type of lock 228 ### that it is already locked with, and I've already 229 ### locked it myself, then it is safe to lock again. 230 ### Just kick out successfully without really locking. 231 ### Assumes locks will be released in the reverse 232 ### order from how they were established. 233 if ($try_lock_exclusive eq $has_lock_exclusive && @mine){ 234 return $self; 235 } 163 if ( -e $self->{lock_file} && open (_FH,"+<$self->{lock_file}") ){ 164 my @mine = (); 165 my @them = (); 166 my @dead = (); 167 168 my $has_lock_exclusive = !((stat _)[2] & $SHARE_BIT); 169 my $try_lock_exclusive = !($self->{lock_type} & LOCK_SH); 170 171 while(defined(my $line=<_FH>)){ 172 if ($line =~ /^$HOSTNAME (\d+) /) { 173 my $pid = $1; 174 if ($pid == $$) { # This is me. 175 push @mine, $line; 176 }elsif(kill 0, $pid) { # Still running on this host. 177 push @them, $line; 178 }else{ # Finished running on this host. 179 push @dead, $line; 180 } 181 } else { # Running on another host, so 182 push @them, $line; # assume it is still running. 183 } 184 } 185 186 ### If there was at least one stale lock discovered... 187 if (@dead) { 188 # Lock lock_file to avoid a race condition. 189 local $LOCK_EXTENSION = ".shared"; 190 my $lock = new File::NFSLock { 191 file => $self->{lock_file}, 192 lock_type => LOCK_EX, 193 blocking_timeout => 62, 194 stale_lock_timeout => 60, 195 }; 196 197 ### Rescan in case lock contents were modified between time stale lock 198 ### was discovered and lockfile lock was acquired. 199 seek (_FH, 0, 0); 200 my $content = ''; 201 while(defined(my $line=<_FH>)){ 202 if ($line =~ /^$HOSTNAME (\d+) /) { 203 my $pid = $1; 204 next if (!kill 0, $pid); # Skip dead locks from this host 205 } 206 $content .= $line; # Save valid locks 207 } 208 209 ### Save any valid locks or wipe file. 210 if( length($content) ){ 211 seek _FH, 0, 0; 212 print _FH $content; 213 truncate _FH, length($content); 214 close _FH; 215 }else{ 216 close _FH; 217 unlink $self->{lock_file}; 218 } 219 220 ### No "dead" or stale locks found. 221 } else { 222 close _FH; 223 } 224 225 ### If attempting to acquire the same type of lock 226 ### that it is already locked with, and I've already 227 ### locked it myself, then it is safe to lock again. 228 ### Just kick out successfully without really locking. 229 ### Assumes locks will be released in the reverse 230 ### order from how they were established. 231 if ($try_lock_exclusive eq $has_lock_exclusive && @mine){ 232 return $self; 233 } 236 234 } 237 235 … … 434 432 ### hard link to the actual file which will bring it up to date 435 433 return ( link( $file, $rand_file) && unlink($rand_file) ); 434 } 435 436 sub refresh { 437 my $self = shift; 438 439 $errstr = undef; 440 my $rand_file = $self->{rand_file}; 441 my $file = $self->{lock_file}; 442 $self->{lock_line} = "$HOSTNAME $self->{lock_pid} ".time()." ".int(rand()*10000)."\n"; 443 local *_FH; 444 open (_FH,">$rand_file") or do { $errstr = "Couldn't open \"$rand_file\" [$!]"; return undef; }; 445 print _FH $self->{lock_line}; 446 close _FH; 447 448 my $err; 449 system("mv $rand_file $file") && ($err = "ERROR: Could not refresh lock\n"); 450 unlink($rand_file) if(-e $rand_file); 451 die $err if($err); 452 453 return 1; 436 454 } 437 455 lib/GI.pm
r198 r209 5 5 6 6 use strict; 7 use vars qw(@ISA @EXPORT $VERSION $TMP); 7 use vars qw(@ISA @EXPORT $VERSION $TMP $LOCK); 8 use FindBin; 8 9 use Exporter; 9 10 use FileHandle; … … 41 42 use maker::sens_spec; 42 43 use File::NFSLock; 44 use threads; 43 45 44 46 @ISA = qw( … … 796 798 my $CTL_OPT = shift; 797 799 my $LOG = shift; 798 799 my $exe = $CTL_OPT->{gmhmme3}; 800 801 #genemark sometimes fails if called directly so I built a wrapper 802 my $exe = "$FindBin::Bin/../lib/Widget/genemark/gmhmme3_wrap"; 803 my $gm = $CTL_OPT->{gmhmme3}; #genemark 804 my $pro = $CTL_OPT->{probuild}; #helper exe 800 805 my $hmm = $CTL_OPT->{gmhmm}; 801 806 … … 807 812 $LOG->add_entry("STARTED", $out_file, ""); 808 813 814 809 815 my $command = $exe; 810 816 $command .= " -m $hmm"; 817 $command .= " -g $gm"; 818 $command .= " -p $pro"; 811 819 $command .= " -o $out_file"; 812 820 $command .= " $in_file"; … … 1262 1270 #copy db to local tmp dir and run xdformat or formatdb 1263 1271 if ((! @{[<$tmp_db.x?d*>]} || ! @{[<$tmp_db.?sq*>]}) && (! -e $blast_finished)) { 1264 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', , 300)){1272 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', undef, 300)){ 1265 1273 copy($db, $tmp_db) if(! -e $tmp_db); 1266 1274 dbformat($formater, $tmp_db, 'blastn'); … … 1508 1516 #copy db to local tmp dir and run xdformat or format db 1509 1517 if ((! @{[<$tmp_db.x?d*>]} || ! @{[<$tmp_db.?sq*>]}) && (! -e $blast_finished) ) { 1510 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', , 300)){1518 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', undef, 300)){ 1511 1519 copy($db, $tmp_db) if(! -e $tmp_db); 1512 1520 dbformat($formater, $tmp_db, 'blastx'); … … 1766 1774 #copy db to local tmp dir and run xdformat or formatdb 1767 1775 if ((! @{[<$tmp_db.x?d*>]} || ! @{[<$tmp_db.?sq*>]}) && (! -e $blast_finished) ) { 1768 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', , 300)){1776 if(my $lock = new File::NFSLock("$tmp_db.lock", 'EX', undef, 300)){ 1769 1777 copy($db, $tmp_db) if(! -e $tmp_db); 1770 1778 dbformat($formater, $tmp_db, 'tblastx'); … … 2061 2069 2062 2070 return $the_void; 2071 } 2072 #----------------------------------------------------------------------------- 2073 #refreshes the maker directory lock every 30 seconds 2074 sub maintain_lock { 2075 my $lock = shift; 2076 2077 while(1){ 2078 sleep 30; 2079 $lock->refresh; 2080 } 2063 2081 } 2064 2082 #----------------------------------------------------------------------------- … … 2182 2200 'qrna', 2183 2201 'fathom', 2202 'probuild' 2184 2203 ); 2185 2204 … … 2398 2417 push (@infiles, 'snap') if (grep (/snap/, @{$CTL_OPT{_run}})); 2399 2418 push (@infiles, 'gmhmme3') if (grep (/genemark/, @{$CTL_OPT{_run}})); 2419 push (@infiles, 'probuild') if (grep (/genemark/, @{$CTL_OPT{_run}})); 2400 2420 push (@infiles, 'augustus') if (grep (/augustus/, @{$CTL_OPT{_run}})); 2401 2421 push (@infiles, 'fgenesh') if (grep (/fgenesh/, @{$CTL_OPT{_run}})); … … 2556 2576 if(! -d $CTL_OPT{out_base}); 2557 2577 2578 #--check if another instance of maker is running, if not lock the directory 2579 my $check; 2580 if(-e $CTL_OPT{out_base}."/.maker_lock.NFSLock"){ 2581 warn "WARNING: Lock found, maker may already be running.\n". 2582 "Checking for other instance.\n\n"; 2583 $check = 1; 2584 } 2585 2586 #lock must be global or it is detroyed outside of block 2587 if($LOCK = new File::NFSLock($CTL_OPT{out_base}."/.maker_lock", 'EX', 40, 40)){ 2588 warn "Everything seems ok!!\n\n" if($check); 2589 2590 my $thr = threads->create(\&maintain_lock, $LOCK); 2591 $thr->detach; 2592 } 2593 else{ 2594 die "ERROR: Another instance of maker is already running for this dataset\n"; 2595 } 2596 2597 2558 2598 #--set up optional global TMP 2559 2599 if($CTL_OPT{TMP}){ … … 2576 2616 my %O = (@_) ? @_ : set_defaults(); 2577 2617 my $ev = 1 if($main::eva); 2618 my $log = 1 if(@_); 2578 2619 2579 2620 #--build opts.ctl file 2580 2621 open (OUT, "> $dir/eval_opts.ctl") if($ev); 2581 open (OUT, "> $dir/maker_opts.ctl") if(!$ev); 2622 open (OUT, "> $dir/maker_opts.log") if(!$ev && $log); 2623 open (OUT, "> $dir/maker_opts.ctl") if(!$ev && !$log); 2582 2624 print OUT "#-----Genome (Required for De-Novo Annotation)\n" if(!$ev); 2583 2625 print OUT "#-----Genome (Required if not internal to GFF3 file)\n" if($ev); … … 2626 2668 print OUT "fgenesh_par_file:$O{fgenesh_par_file} #Fgenesh parameter file\n"; 2627 2669 print OUT "model_gff:$O{model_gff} #gene models from an external gff3 file (annotation pass-through)\n" if(!$ev); 2628 print OUT "pred_gff:$O{ model_gff} #ab-initio predictions from an external gff3 file\n";2670 print OUT "pred_gff:$O{pred_gff} #ab-initio predictions from an external gff3 file\n"; 2629 2671 print OUT "\n"; 2630 2672 print OUT "#-----Other Annotation Type Options (features maker doesn't recognize)\n" if(!$ev); … … 2662 2704 #--build bopts.ctl file 2663 2705 open (OUT, "> $dir/eval_bopts.ctl") if($ev); 2664 open (OUT, "> $dir/maker_bopts.ctl") if(!$ev); 2706 open (OUT, "> $dir/maker_bopts.log") if(!$ev && $log); 2707 open (OUT, "> $dir/maker_bopts.ctl") if(!$ev && !$log); 2665 2708 print OUT "#-----BLAST and Exonerate Statistics Thresholds\n"; 2666 2709 print OUT "blast_type:$O{blast_type} #set to 'wublast' or 'ncbi'\n"; … … 2697 2740 #--build maker_exe.ctl file 2698 2741 open (OUT, "> $dir/eval_exe.ctl") if($ev); 2699 open (OUT, "> $dir/maker_exe.ctl") if(!$ev); 2742 open (OUT, "> $dir/maker_exe.log") if(!$ev && $log); 2743 open (OUT, "> $dir/maker_exe.ctl") if(!$ev && !$log); 2700 2744 print OUT "#-----Location of Executables Used by Maker/Evaluator\n"; 2701 2745 print OUT "formatdb:$O{formatdb} #location of NCBI formatdb executable\n"; … … 2719 2763 print OUT "qrna:$O{qrna} #location of qrna executable (not yet implemented)\n"; 2720 2764 print OUT "fathom:$O{fathom} #location of fathom executable (not yet implemented)\n"; 2765 print OUT "probuild:$O{probuild} #location of probuild executable (required for genemark)\n"; 2721 2766 close(OUT); 2722 2767 } lib/ds_utility.pm
r127 r209 124 124 sub add_entry { 125 125 my $self = shift; 126 my $entry = join("\t", @_); 126 my @F = @_; 127 128 #remove deep directory data so log is relative 129 my $cwd = Cwd::cwd(); 130 my $entry = join("\t", @F); 131 132 if($entry =~ /\tFINISHED|\tSTARTED|\tDIED|\tSKIPPED|\tRETRY/){ 133 $entry =~ s/$cwd\/.*\.maker\.output\/*//; 134 } 127 135 128 136 open(my $IN, ">>", $self->{log}); lib/runlog.pm
r197 r209 506 506 507 507 my ($te) = $CTL_OPTIONS{repeat_protein} =~ /([^\/]+)$/; 508 $te =~ s/\.fasta$//; 509 510 @f = grep { ! /$te\.blastx$/} @f; 511 508 509 if($te){ 510 $te =~ s/\.fasta$//; 511 @f = grep { ! /$te\.blastx$/} @f; 512 } 513 512 514 foreach my $f (@f){ 513 515 push (@files, $f) if (-f $f); 514 516 push (@dirs, $f) if (-d $f); 515 517 } 518 516 519 } 517 520
