[Bio] / FigKernelScripts / svr_run_RAST_jobs.pl Repository:
ViewVC logotype

Diff of /FigKernelScripts/svr_run_RAST_jobs.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Wed Oct 28 16:32:47 2009 UTC revision 1.3, Tue Dec 8 02:11:31 2009 UTC
# Line 8  Line 8 
8  use strict;  use strict;
9  use Data::Dumper;  use Data::Dumper;
10    
11  @ARGV == 2 or die "Usage: $0 username password < contig-id-list\n";  my $use_test_server = 0;
12    if (@ARGV && ($ARGV[0] =~ m/-test/o)) {
13        shift @ARGV;
14        $use_test_server = 1;
15    }
16    
17    @ARGV == 2 or die "Usage: $0 [-test] username password < contig-id-list\n";
18    
19  my $username = shift;  my $username = shift;
20  my $password = shift;  my $password = shift;
21    
22  my $rast = new RASTserver($username, $password);  my $rast = RASTserver->new($username, $password, { -test => $use_test_server});
23    
24  my @input_ids = <STDIN>;  my @input_ids = <STDIN>;
25  chomp @input_ids;  chomp @input_ids;
# Line 21  Line 27 
27  my @job_sets;  my @job_sets;
28  my $redundancies_seen;  my $redundancies_seen;
29    
30    my $tmpdir = "/tmp/rast_submit.tmp.$$";
31    mkdir $tmpdir;
32    
33  my %seen;  my %seen;
34  for my $id (@input_ids)  for my $id (@input_ids)
35  {  {
# Line 48  Line 57 
57    
58  if ($redundancies_seen)  if ($redundancies_seen)
59  {  {
60      die "Not submitting jobs, redudancies were found\n";      die "Not submitting jobs, redundancies were found\n";
61  }  }
62    
63  #  #
# Line 60  Line 69 
69  my $idx = 1;  my $idx = 1;
70  for my $ids (@job_sets)  for my $ids (@job_sets)
71  {  {
72      print "Retrieve @$ids\n";      print "Retrieve @$ids from Entrez\n";
73      my $data = $rast->get_contigs_from_entrez({ -id => $ids });      my $data = $rast->get_contigs_from_entrez({ -id => $ids });
74      my $file= "data.$idx";      my $file= "$tmpdir/data.$idx";
75      $idx++;      $idx++;
76      open(F, ">", $file) or die "Cannot open $file: $!";      open(F, ">", $file) or die "Cannot open $file: $!";
77      for my $ent (@$data)      for my $ent (@$data)
# Line 70  Line 79 
79          my $txt = $ent->{contents};          my $txt = $ent->{contents};
80          my $id = $ent->{id};          my $id = $ent->{id};
81          $ent->{contents} = '';          $ent->{contents} = '';
82          print Dumper($ent);          print "Contig information for $id:\n";
83          print "write $id\n";          print "\t$_\t$ent->{$_}\n" for keys %$ent;
84          print F $txt;          print F $txt;
85      }      }
86      close(F);      close(F);
# Line 92  Line 101 
101    
102  for my $jobdata (@jobs)  for my $jobdata (@jobs)
103  {  {
104      my($file, $data) = @$jobdata{qw(file data)};      my($file, $data, $ids) = @$jobdata{qw(file data ids)};
105    
106      my @biggest = sort { $b->{length} <=> $a->{length} } @$data;      my @biggest = sort { $b->{length} <=> $a->{length} } @$data;
107      print Dumper(\@biggest);  
108      my $biggest = $biggest[0];      my $biggest = $biggest[0];
109    
110      my $taxonomy = $biggest->{taxonomy};      my $taxonomy = $biggest->{taxonomy};
# Line 111  Line 120 
120          -geneCaller => 'RAST',          -geneCaller => 'RAST',
121      };      };
122    
123      print Dumper($submit_params);      print "Submitting job to RAST for contigs @$ids with these parameters:\n";
124        print "\t$_\t$submit_params->{$_}\n" for keys %$submit_params;
125    
126    
127      my $res = $rast->submit_RAST_job($submit_params);      my $res = $rast->submit_RAST_job($submit_params);
128      print Dumper($res);  
129        if ($res->{status} eq 'ok')
130        {
131            my $job = $res->{job_id};
132            print "Successfully submitted job $job\n";
133        }
134        else
135        {
136            print "There was an error on submission: $res->{error_msg}\n";
137        }
138  }  }
139    
 #  
 # Loop waiting for jobs to finish and retrieve results when they do.  
 #  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3