[Bio] / FortyEight / create_import_job.pl Repository:
ViewVC logotype

Diff of /FortyEight/create_import_job.pl

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

revision 1.1, Wed Sep 5 21:41:46 2007 UTC revision 1.5, Wed Oct 31 23:16:50 2007 UTC
# Line 28  Line 28 
28  use Job48;  use Job48;
29  use NRTools;  use NRTools;
30    
31  my $usage = "create_import_job prev-nr prev-syn prev-sims";  my $usage = "create_import_job [-new-nr-data dir] [-import-biodb] [-from-job jobnum] [prev-nr prev-syn prev-sims]";
32    
33  #  #
34  # Incoming NR data.  # Incoming NR data.
35  #  #
36  my $dir_biodb = "/vol/biodb";  my $dir_biodb = "/vol/biodb";
37  #my $dir_biodb_nr_input = "$dir_biodb/processed_data/for_build_nr";  my $dir_biodb_nr_input = "$dir_biodb/processed_data/for_build_nr";
 my $dir_biodb_nr_input = "/local/FIGdisk/FIG/Data/NR";  
   
38    
39  #  #
40  # Existing SEED data  # Existing SEED data
41  #  #
42    
43  #my $dir_reference_seed_data = "/vol/seed-data-anno-mirror/Data.Jan3";  my $dir_reference_seed_data = "/vol/seed-data-anno-mirror/Data.Jan3";
44  my $dir_reference_seed_data = "/local/FIGdisk/FIG/Data";  #my $dir_reference_seed_data = "/local/FIGdisk/FIG/Data";
45    
46  #  #
47  # RAST server from which to pull genomes to import.  # RAST server from which to pull genomes to import.
# Line 55  Line 53 
53  # Startup.  # Startup.
54  #  #
55    
56    my $do_biodb_import;
57    my $from_job_id;
58    
59    while ((@ARGV > 0) && ($ARGV[0] =~ /^-/))
60    {
61        my $arg = shift @ARGV;
62        if ($arg =~ /^-import-biodb/i)
63        {
64            $do_biodb_import++;
65        }
66        elsif ($arg =~ /^-new-nr-data/)
67        {
68            $dir_biodb_nr_input = shift @ARGV;
69            $do_biodb_import++;
70        }
71        elsif ($arg =~ /^-from-job/)
72        {
73            $from_job_id = shift @ARGV;
74        }
75        else
76        {
77            die $usage;
78        }
79    }
80    
81    my $prev_nr_src;
82    my $prev_syn_src;
83    my $prev_sim_dir;
84    my $from_job;
85    
86    if (defined($from_job_id))
87    {
88        @ARGV == 0 or die $usage;
89    
90        $from_job = ImportJob->new($from_job_id);
91        $from_job or die "From-job id $from_job_id does not exist";
92    
93        my $dir = $from_job->dir();
94        $prev_nr_src = "$dir/nr";
95        $prev_syn_src = "$dir/peg.synonyms";
96        $prev_sim_dir = sprintf("$dir/Sims.%03d", $from_job_id);
97    }
98    else
99    {
100  @ARGV == 3 or die $usage;  @ARGV == 3 or die $usage;
101    
102  my $prev_nr_src = shift;      $prev_nr_src = shift;
103  my $prev_syn_src = shift;      $prev_syn_src = shift;
104  my $prev_sim_dir = shift;      $prev_sim_dir = shift;
105    }
106    
107  #  #
108  # Validate  # Validate
# Line 92  Line 135 
135      die "Cannot open previous synonyms file $prev_syn_src: $!\n";      die "Cannot open previous synonyms file $prev_syn_src: $!\n";
136  }  }
137    
138  if (not(-d $prev_sim_dir and <$prev_sim_dir/sims*> > 0))  my @sfiles = <$prev_sim_dir/sims*>;
139    if (not(-d $prev_sim_dir and @sfiles > 0))
140  {  {
141      die "previous sim dir $prev_sim_dir does not appear to contain sims\n";      die "previous sim dir $prev_sim_dir does not appear to contain sims\n";
142  }  }
143    
144    
145    print "Creating import job\n";
146    print "\tprev_nr=$prev_nr_src\n";
147    print "\tprev_syn=$prev_syn_src\n";
148    print "\tprev_sim=$prev_sim_dir\n";
149    
150  #  #
151  # Initial validation.  # Initial validation.
152  #  #
153  &validate_dirs($dir_biodb_nr_input, $dir_reference_seed_data, $dir_rast_jobs);  &validate_dirs($dir_reference_seed_data, $dir_rast_jobs);
154    
155    if ($do_biodb_import)
156    {
157        &validate_dirs($dir_biodb_nr_input);
158    }
159    
160  #  #
161  # Create our jobdir.  # Create our jobdir.
# Line 142  Line 196 
196  my %NR_dirs;  my %NR_dirs;
197    
198  scan_NR_dir(\%NR_dirs, "$dir_reference_seed_data/NR");  scan_NR_dir(\%NR_dirs, "$dir_reference_seed_data/NR");
199    
200    if ($do_biodb_import)
201    {
202  scan_NR_dir(\%NR_dirs, "$dir_biodb_nr_input");  scan_NR_dir(\%NR_dirs, "$dir_biodb_nr_input");
203    }
204    
205  #scan_NR_dir(\%NR_dirs, "$dir_biodb_nr_input", { skip => qr(^(SwissProt|.*\.bak)) });  #scan_NR_dir(\%NR_dirs, "$dir_biodb_nr_input", { skip => qr(^(SwissProt|.*\.bak)) });
206    
207  #  #
# Line 164  Line 223 
223  #  #
224  # Scan for RAST jobs to import.  # Scan for RAST jobs to import.
225  #  #
226    # We update our NR component list with the peg features from the job,
227    # and we add the job directory of each to the rast.jobs file. This
228    # will be used later during the installation of these jobs into the SEED.
229    #
230    
231    open(JOBS, ">$jobdir/rast.jobs") or die "Cannot create $jobdir/rast.jobs: $!";
232    
233  my @rast_jobs;  my @rast_jobs;
234  scan_rast_jobs(\@rast_jobs, $dir_rast_jobs);  scan_rast_jobs(\@rast_jobs, $dir_rast_jobs);
235    
236    my @new_rast_jobs;
237  for my $job (@rast_jobs)  for my $job (@rast_jobs)
238  {  {
239      my $gid = $job->genome_id;      my $gid = $job->genome_id;
# Line 178  Line 244 
244    
245      if (exists($NR_dirs{$gid}))      if (exists($NR_dirs{$gid}))
246      {      {
247          die "Rast job $j already exists in SEED server\n";          warn "Rast job $j already exists in SEED server\n";
248            next;
249      }      }
250        push(@new_rast_jobs, $job);
251    
252        print JOBS $job->dir(), "\n";
253    
254      my $fasta = $job->orgdir() . "/Features/peg/fasta";      my $fasta = $job->orgdir() . "/Features/peg/fasta";
255      -f $fasta or die "Job $j has no fasta file in $fasta\n";      -f $fasta or die "Job $j has no fasta file in $fasta\n";
256      $NR_dirs{$gid} = {type => "rast_job", name => $gname, path => $job->orgdir,      $NR_dirs{$gid} = {type => "rast_job", name => $gname, path => $job->orgdir,
257                              fasta_path => $fasta, size => -s _ };                              fasta_path => $fasta, size => -s _ };
258  }  }
259    close(JOBS);
260    @rast_jobs = @new_rast_jobs;
261    
262  open(F, ">$jobdir/all.nr.dirs");  open(F, ">$jobdir/all.nr.dirs");
263  open(F2, ">$jobdir/nr.sources");  open(F2, ">$jobdir/nr.sources");

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3