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

Diff of /FortyEight/migrate_job.pl

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

revision 1.1, Thu May 31 17:05:46 2007 UTC revision 1.2, Wed Jun 6 17:53:22 2007 UTC
# Line 7  Line 7 
7  # with the required initial data.  # with the required initial data.
8  #  #
9    
10  my $usage = "usage: migrate_job job-dir target";  my $usage = "usage: migrate_job [-new] job-dir target";
11    
12    
13  use strict;  use strict;
# Line 20  Line 20 
20                           qr/^correction\.automatic/);                           qr/^correction\.automatic/);
21  my $files_to_skip = qr/^(?:ACTIVE|DONE|DELETED|meta\.xml)$/;  my $files_to_skip = qr/^(?:ACTIVE|DONE|DELETED|meta\.xml)$/;
22    
23    my $new_num;
24    while ($ARGV[0] =~ /^-(.*)/)
25    {
26        shift;
27        my $arg = $1;
28        if ($arg =~ /^new/)
29        {
30            $new_num = 1;
31        }
32        else
33        {
34            die "Unknown argument $arg\n";
35        }
36    }
37    
38    
39    
40  @ARGV == 2 or die "$usage\n";  @ARGV == 2 or die "$usage\n";
41    
42  my $jobdir = shift;  my $jobdir = shift;
# Line 40  Line 57 
57  defined($genome_id) or die "Cannot read genomem id\n";  defined($genome_id) or die "Cannot read genomem id\n";
58  chomp $genome_id;  chomp $genome_id;
59    
60  my $new_jobdir = "$target/$jobnum";  my $target_jobnum;
61    if ($new_num)
62    {
63        # get new job id from job counter
64        open(FH, "$target/JOBCOUNTER") or die "could not open jobcounter file: $!\n";
65        $target_jobnum = <FH>;
66        $target_jobnum++;
67        close FH;
68        while (-d "$target/$target_jobnum")
69        {
70            $target_jobnum++;
71        }
72        open(FH, ">$target/JOBCOUNTER") or die "could not write to jobcounter file: $!\n";
73        print FH $target_jobnum;
74        close FH;
75    }
76    else
77    {
78        $target_jobnum = $jobnum;
79    }
80    
81    my $new_jobdir = "$target/$target_jobnum";
82    
83  warn "Copying job $jobnum for genome $genome_id from $jobdir to $new_jobdir\n";  warn "Copying job $jobnum for genome $genome_id from $jobdir to $new_jobdir\n";
84    
85  my $old_meta = new GenomeMeta(undef, "$jobdir/meta.xml");  my $old_meta = new GenomeMeta(undef, "$jobdir/meta.xml");
86  $old_meta or die "Cannot open $jobdir/meta.xml: $!\n";  $old_meta or die "Cannot open $jobdir/meta.xml: $!\n";
87    
88  -d $new_jobdir and die "Job $jobnum in $target already exists\n";  -d $new_jobdir and die "Job $target_jobnum in $target already exists\n";
89    
90  mkdir $new_jobdir or die "cannot mkdir $new_jobdir: $!\n";  mkdir $new_jobdir or die "cannot mkdir $new_jobdir: $!\n";
91    

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3