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

Annotation of /FortyEight/rp_rapid_propagation.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download) (as text)

1 : olson 1.1
2 :     #
3 :     # Perform rapid propagation.
4 :     #
5 :    
6 :     use strict;
7 :     use FIG;
8 :     use FIG_Config;
9 :     use File::Basename;
10 :     use GenomeMeta;
11 :    
12 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
13 :    
14 :     my $jobdir = shift;
15 :    
16 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
17 :    
18 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
19 :     chomp $genome;
20 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
21 :    
22 :     my $job = basename($jobdir);
23 :    
24 :     my $meta_file = "$jobdir/meta.xml";
25 :     my $meta = new GenomeMeta($genome, $meta_file);
26 :    
27 :     my $raw_dir = "$jobdir/raw/$genome";
28 :     my $rp_dir = "$jobdir/rp/$genome";
29 :    
30 :     my $errdir = "$jobdir/rp.errors";
31 :     &FIG::verify_dir($errdir);
32 :    
33 :     if (! -d $raw_dir)
34 :     {
35 :     &fatal("raw genome directory $raw_dir does not exist");
36 :     }
37 :    
38 :    
39 :     #
40 :     # Perform the rapid propagation.
41 :     #
42 :     # We work from the raw genome directory. We assume the incoming contigs
43 :     # are present in raw/genome-id/unformatted_contigs. We run
44 :     # reformat_contigs -split before the actual rapid propagation to
45 :     # split any scaffolds present in the contigs.
46 :     #
47 :     # When the rp is finished, we move the split contigs out of the way
48 :     # and rerun reformat_contigs without the split option in order
49 :     # to recover the original contig coordinates.
50 :     #
51 :    
52 :     my $unformatted = "$raw_dir/unformatted_contigs";
53 :    
54 :     if (! -f $unformatted)
55 :     {
56 :     &fatal("Unformatted contigs file $unformatted does not exist\n");
57 :     }
58 :    
59 :     #
60 :     # Reformat and split.
61 :     #
62 :    
63 :     my $formatted = "$raw_dir/contigs";
64 :     my $reformat_split_log = "$errdir/reformat_contigs_split.stderr";
65 :    
66 :     my @cmd = ("$FIG_Config::bin/reformat_contigs", "-v", "-logfile=$reformat_split_log", "-split", $unformatted, $formatted);
67 :    
68 :     print "Run @cmd\n";
69 :    
70 :     $meta->add_log_entry($0, ['running', @cmd]);
71 :    
72 :     my $rc = system(@cmd);
73 :     if ($rc != 0)
74 :     {
75 :     &fatal("reformat command failed with rc=$rc: @cmd\n");
76 :     }
77 :    
78 :     #
79 :     # Do the rapid propagation itself.
80 :     #
81 :    
82 :     my $tmp = "tmprp.job$job.$$";
83 :     my $tmpdir = "/scratch/$tmp";
84 :    
85 :     &FIG::verify_dir("$jobdir/rp");
86 :    
87 :     @cmd = ("$FIG_Config::bin/rapid_propagation", "--errdir", $errdir,
88 :     "--meta", $meta_file, "--tmpdir", $tmpdir, $raw_dir, $rp_dir);
89 :     print "Run @cmd\n";
90 :     $meta->add_log_entry($0, ['running', @cmd]);
91 :    
92 :     $rc = system(@cmd);
93 :    
94 :     if ($rc != 0)
95 :     {
96 :     &fatal("rapid_propagation command failed with rc=$rc: @cmd\n");
97 :     }
98 :    
99 :     #
100 :     # RP should be done. Check to see that we at least had a features directory created.
101 :     #
102 :    
103 :     if (! -d "$rp_dir/Features/peg")
104 :     {
105 :     &fatal("rapid_propagation did not create any features");
106 :     }
107 :    
108 :     $meta->add_log_entry($0, "rapid_propagation completed\n");
109 :     $meta->set_metadata("rp.running", "no");
110 :     $meta->set_metadata("status.rp", "complete");
111 :    
112 :     exit;
113 :    
114 :     sub fatal
115 :     {
116 :     my($msg) = @_;
117 :    
118 :     $meta->add_log_entry($0, ['fatal error', $msg]);
119 :     $meta->set_metadata("status.auto_assign", "error");
120 :    
121 :     croak "$0: $msg";
122 :     }
123 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3