Changeset 259

Show
Ignore:
Timestamp:
09/08/09 16:43:05 (3 months ago)
Author:
cholt
Message:

mpi_iprscan more maker like behavior

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • MPI/mpi_iprscan

    r258 r259  
    1414use threads; 
    1515use threads::shared; 
    16 use Cwd; 
    1716 
    1817BEGIN{ 
     
    3433   #what to do on ^C 
    3534    $SIG{'INT'} = sub { 
    36         print STDERR "\n\nMaker aborted by user!!\n\n"; 
     35        print STDERR "\n\nmpi_iprscan aborted by user!!\n\n"; 
    3736        my @threads = threads->list; 
    3837        foreach my $thr (@threads){ 
     
    7574use Iterator::Fasta; 
    7675use Fasta; 
    77 use basiclog
     76use ds_utility
    7877use Error qw(:try); 
    7978use Error::Simple; 
    8079use Process::IPRchunk; 
    8180use Process::MpiTiers; 
     81use Process::IPRchunk; 
    8282use Parallel::MPIcar qw(:all); 
     83use iprscan::runlog; 
    8384 
    8485unless($threads::VERSION >= 1.67){ 
     
    173174my $root = 0; #define root node (only changed for debugging) 
    174175 
     176$CTL_OPT{retry} = 2; 
     177$CTL_OPT{seqtype} = 'p'; #default 
     178 
    175179#---Process options on the command line 
    176180GetOptions("i=s"       => \$CTL_OPT{infile}, 
    177181           "o=s"       => \$CTL_OPT{outfile}, 
    178182           "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 
     183           "nocrc"     => \$CTL_OPT{nocrc}, 
     184           "seqtype=s" => \$CTL_OPT{seqtype}, 
     185           "trtable=i" => \$CTL_OPT{trtable}, 
     186           "goterms"   => \$CTL_OPT{goterms}, 
     187           "iprlookup" => \$CTL_OPT{iprlookup}, 
     188           "format=s"  => \$CTL_OPT{format}, 
     189           "verbose"   => \$CTL_OPT{verbose}, 
     190           "retry"     => \$CTL_OPT{retry}, 
     191           "chpc"      => \$CTL_OPT{chpc}, #hidden option for retrying 
    187192           "cli"       => \$CTL_OPT{cli}, #just used to strip off the option 
    188193           ); 
     
    208213 
    209214$CTL_OPT{appl} = \@appl; #apply apps to CTL_OPT 
     215 
     216#build out_base and out_name for datastore 
     217$CTL_OPT{out_name} = ($CTL_OPT{outfile}) ? $CTL_OPT{outfile} : $CTL_OPT{infile}; 
     218$CTL_OPT{out_name} =~ /([^\/]+)$/; 
     219$CTL_OPT{out_name} = $1; 
     220$CTL_OPT{out_name} =~ s/(.+)\.[^\.]+$/$1/; 
     221$CTL_OPT{out_base} = Cwd::cwd()."/$CTL_OPT{out_name}.iprscan.output"; 
    210222 
    211223#build localized iprscan database for each node 
     
    297309        $command .= " -iprlookup" if($CTL_OPT{iprlookup}); 
    298310        $command .= " -format $CTL_OPT{format}" if(defined $CTL_OPT{format}); 
     311        $command .= " -verbose" if($CTL_OPT{verbose}); 
    299312        $command .= " -appl " . join(" -appl ", @{$CTL_OPT{appl}}) if(@{$CTL_OPT{appl}}); 
    300313        $command .= " -i $tfile" if($CTL_OPT{infile}); #test options on dummy file 
     
    328341    $name = $CTL_OPT{outfile} if($CTL_OPT{outfile}); 
    329342 
    330     my $DS_CTL = new basiclog("$name.log"); 
     343    my $DS_CTL = new ds_utility(\%CTL_OPT); 
    331344    my $iterator = new Iterator::Fasta($CTL_OPT{infile}); 
    332345 
     
    379392            while (my $fasta = $iterator->nextFasta() || shift @failed){ 
    380393                $tier = Process::MpiTiers->new({fasta     => $fasta, 
    381                                                 CTL_OPT   => \%CTL_OPT 
     394                                                CTL_OPT   => \%CTL_OPT, 
    382395                                                params    => \@ARGV, 
    383396                                                iprscan   => "$EXE -cli", 
     
    445458                while (my $fasta = $iterator->nextFasta() || shift @failed){ 
    446459                $tier = Process::MpiTiers->new({fasta     => $fasta, 
    447                                                 CTL_OPT   => \%CTL_OPT 
     460                                                CTL_OPT   => \%CTL_OPT, 
    448461                                                params    => \@ARGV, 
    449462                                                iprscan   => "$EXE -cli", 
     
    615628    $thr->detach() unless($thr->is_detached); 
    616629     
    617     print STDERR "\n\nMaker is now finished!!!\n\n"
     630    print STDERR "\n\nmpi_iprscan is now finished!!!\n\n" unless($main::quiet)
    618631} 
    619632#------SECONDARY MPI PROCESSES------ 
  • lib/Process/IPRchunk.pm

    r258 r259  
    1 #! /usr/bin/perl -w 
    2  
     1#! /usr/bin/perl 
    32package Process::IPRchunk; 
    43 
     
    1413use Widget::iprscan; 
    1514use URI::Escape; 
     15use iprscan::runlog; 
    1616 
    1717#--set object variables for serialization of data 
     
    134134      $VARS->{LOG} = iprscan::runlog->new($VARS->{CTL_OPT}, 
    135135                                          {seq_id     => $VARS->{seq_id}, 
    136                                            seq_length => length(${$VARS->{q_seq_ref}}), 
    137136                                           out_dir    => $VARS->{out_dir}, 
    138137                                           the_void   => $VARS->{the_void}, 
     
    144143      $VARS->{DS_CTL}->add_entry($VARS->{seq_id}, $VARS->{out_dir}, $message); 
    145144      if($VARS->{c_flag} == 0){ 
    146           my $cfile = $VARS->{c_flag}; 
     145          my $cfile = $VARS->{cfile}; 
    147146          die "ERROR: Can't find $cfile yet iprscan::runlog says the contig is finished\n" 
    148147              if(! -e $cfile); 
     
    158157              open($FH, ">&STDOUT"); 
    159158          } 
     159 
     160          #open for reading 
     161          open(my $CFH, "< $cfile"); 
    160162           
    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; 
     163          while(my $line = <$CFH>){ 
     164              print $FH $line; 
    168165          } 
    169166           
     
    329326            #------------------------ARGS_IN 
    330327            @args = (qw{CTL_OPT 
     328                        safe_id 
    331329                        safe_fasta 
    332330                        app 
     
    334332                        iprscan 
    335333                        the_void 
     334                        LOG 
    336335                        } 
    337336                    ); 
     
    342341            my %CTL_OPT    = %{$VARS->{CTL_OPT}}; 
    343342            my $safe_fasta = $VARS->{safe_fasta}; 
     343            my $safe_id    = $VARS->{safe_id}; 
    344344            my $app        = $VARS->{app}; 
    345345            my $params     = $VARS->{params}; 
    346346            my $iprscan    = $VARS->{iprscan}; 
    347347            my $the_void   = $VARS->{the_void}; 
    348  
     348            my $LOG        = $VARS->{LOG}; 
     349             
    349350            #make files 
    350351            my (undef, $ifile) = tempfile(); 
    351             my $ofile = "$the_void/$CTL_OPT{safe_id}.$app"; 
     352            my $ofile = "$the_void/$safe_id.$app"; 
    352353            FastaFile::writeFile($safe_fasta, $ifile); 
    353354 
     
    360361            $command .= " -iprlookup" if($CTL_OPT{iprlookup}); 
    361362            $command .= " -format $CTL_OPT{format}" if(defined $CTL_OPT{format}); 
     363            $command .= " -verbose" if($CTL_OPT{verbose}); 
    362364            $command .= " " . join(' ', @$params); 
    363365            $command .= " -appl $app -i $ifile -o $ofile"; 
     366 
     367            $LOG->add_entry("STARTED", $ofile, ""); 
    364368 
    365369            my $w = new Widget::iprscan(); 
     
    372376            } 
    373377 
     378            $LOG->add_entry("FINISHED", $ofile, ""); 
     379 
    374380            unlink($ifile); 
    375381            open(my $IN, "< $ofile"); 
     
    403409            @args = (qw{CTL_OPT 
    404410                        cfile 
    405                         outfile 
    406411                       },                     
    407412                     @{$VARS->{CTL_OPT}{appl}} 
     
    411416         elsif ($flag eq 'run') { 
    412417            #-------------------------CODE 
     418            my %CTL_OPT = %{$VARS->{CTL_OPT}}; 
    413419            my $cfile = $VARS->{cfile}; #combined contig output file 
    414             my $outfile = $VARS->{outfile}; #combined every contig output file 
     420            my $outfile = $CTL_OPT{outfile}; #combined every contig output file 
    415421 
    416422            my $lock = new File::NFSLock(".iprscan_lock", 'EX', 40, 40); 
     
    427433            open($CFH, "> $cfile"); 
    428434 
    429             while(my $key = each %{$VARS}){ 
    430                 next if($key eq 'outfile'); 
     435            foreach my $key (@{$CTL_OPT{appl}}){ 
     436                next if(! defined ($VARS->{$key})); 
    431437                print $FH $VARS->{$key}; 
    432                 print $CFH $cfile
     438                print $CFH $VARS->{$key}
    433439            } 
    434440 
  • lib/Process/MpiTiers.pm

    r258 r259  
    4646          #optionaly override chunk type 
    4747          $self->{CHUNK_REF} = shift @args || "Process::MpiChunk"; 
    48           require $self->{CHUNK_REF}; 
    49           $self->{CHUNK_REF} = new $self->{CHUNK_REF}; #turn into object 
     48          eval "require ". $self->{CHUNK_REF}; 
     49          $self->{CHUNK_REF} = $self->{CHUNK_REF}->new(); #turn into object 
    5050 
    5151          #setup the tier 
  • lib/iprscan/runlog.pm

    r258 r259  
    11#------------------------------------------------------------------------------- 
    2 #------                           runlog                               --------- 
    3 #------------------------------------------------------------------------------- 
    4 package runlog; 
     2#------                       iprscan::runlog                          --------- 
     3#------------------------------------------------------------------------------- 
     4package iprscan::runlog; 
    55use strict; 
    66use vars qw(@ISA @EXPORT $VERSION); 
     
    5555   print STDERR "\n\n\n--Next Contig--\n\n" unless($main::quiet); 
    5656 
    57    my $min_contig = $self->{CTL_OPTIONS}->{min_contig} || 0; 
    58    my $length = $self->{params}->{seq_length}; 
    59  
    60    if($length < $min_contig){#skip if this is a short contig 
    61       $self->{continue_flag} = -2; #skipped signal is -2 
    62  
    63       return 0; 
    64    
     57   #my $min_contig = $self->{CTL_OPTIONS}->{min_contig} || 0; 
     58   #my $length = $self->{params}->{seq_length}; 
     59 
     60   #if($length < $min_contig){#skip if this is a short contig 
     61   #   $self->{continue_flag} = -2; #skipped signal is -2 
     62   # 
     63   #   return 0; 
     64   #
    6565    
    6666   return 1; 
     
    186186                        $key eq 'goterms' || 
    187187                        $key eq 'iprlookup' || 
    188                         $key eq 'format' || 
     188                        $key eq 'format' 
    189189                        ) { 
    190190                        $rm_key{all}++; 
     
    334334   my $out_dir = $self->{params}->{out_dir}; 
    335335   my $fasta_ref = $self->{params}->{fasta_ref}; 
    336    my $length = $self->{params}->{seq_length}; 
     336   #my $length = $self->{params}->{seq_length}; 
    337337 
    338338   if($flag == 0){ 
     
    341341                   "mpi_iprscan will now skip to the next contig.\n", 
    342342                   "SeqID: $seq_id\n", 
    343                    "Length: $length\n",                   
     343                   #"Length: $length\n",                  
    344344                   "#---------------------------------------------------------------------\n\n\n"; 
    345345   } 
     
    348348                   "Now starting the contig!!\n", 
    349349                   "SeqID: $seq_id\n", 
    350                    "Length: $length\n", 
     350                   #"Length: $length\n", 
    351351                   "#---------------------------------------------------------------------\n\n\n"; 
    352352   } 
     
    356356                   "All contig related data will be erased before continuing!!\n", 
    357357                   "SeqID: $seq_id\n", 
    358                    "Length: $length\n", 
     358                   #"Length: $length\n", 
    359359                   "Retry: $die_count!!\n", 
    360360                   "#---------------------------------------------------------------------\n\n\n"; 
     
    364364                   "Now retrying the contig!!\n", 
    365365                   "SeqID: $seq_id\n", 
    366                    "Length: $length\n", 
     366                   #"Length: $length\n", 
    367367                   "Retry: $die_count!!\n", 
    368368                   "#---------------------------------------------------------------------\n\n\n"; 
     
    374374                   "The contig will be stored in a fasta file that you can use for debugging.\n", 
    375375                   "SeqID: $seq_id\n", 
    376                    "Length: $length\n", 
     376                   #"Length: $length\n", 
    377377                   "FASTA: $out_dir/$seq_out_name.died.fasta\n", 
    378378                   "#---------------------------------------------------------------------\n\n\n"; 
     
    386386                   "Skipping the contig because it is too short!!\n", 
    387387                   "SeqID: $seq_id\n", 
    388                    "Length: $length\n", 
     388                   #"Length: $length\n", 
    389389                   "#---------------------------------------------------------------------\n\n\n"; 
    390390   }