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

Annotation of /FortyEight/imp_process_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1
2 :     #
3 :     # Postprocess computed sims.
4 :     #
5 :     # The sim compute happens in a sims workdir. The timelogic sim submission results in the
6 :     # creation of two files, a task list and a job map.
7 :     #
8 :     # The task.list maps a task number to input and output files, and parameters.
9 :     #
10 :     # The job map maps an input filename to a timelogic job number.
11 :     #
12 :     # The task of this script is to identify the output files for all tasks, to
13 :     # ensure they exist and to do a sanity check that the majority of the input
14 :     # sequences are accounted for in the generated data. Once the sanity
15 :     # checking is complete, standard SEED postprocessing is performed and a
16 :     # flipped sims file is created.
17 :     #
18 :    
19 :     use strict;
20 :    
21 :     use Data::Dumper;
22 :     use FIG;
23 :     use FIG_Config;
24 :     use File::Basename;
25 :     use File::Copy;
26 :     use ImportJob;
27 :     use GenomeMeta;
28 :     use JobStage;
29 :    
30 :     my $hits_max = 300;
31 :    
32 :     @ARGV == 2 or die "Usage: $0 job-dir sim-dir\n";
33 :    
34 :     my $jobdir = shift;
35 :     my $simdir = shift;
36 :    
37 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
38 :    
39 :     my $stage = new JobStage('ImportJob', 'process_sims', $jobdir);
40 :    
41 :     $stage or die "$0: Could not create job object";
42 :     my $job = $stage->job();
43 :    
44 :     $stage->log("Running on " . $stage->hostname);
45 :    
46 :     $stage->set_status("running");
47 :     $stage->set_running("yes");
48 :    
49 :     $stage->set_qualified_metadata("host", $stage->hostname);
50 :    
51 :     #
52 :     # Load job map.
53 :     #
54 :    
55 :     open(JM, "<$simdir/job.map") or $stage->fatal("Cannot open jobmap $simdir/job.map: $!");
56 :    
57 :     my %jobmap;
58 :     while (<JM>)
59 :     {
60 :     chomp;
61 :     my($file, $tl_file) = split(/\t/);
62 :     $jobmap{$file} = $tl_file;
63 :     }
64 :     close(JM);
65 :    
66 :     open(TL, "<$simdir/task.list") or $stage->fatal("Cannot open task list $simdir/task.list: $!");
67 :    
68 :     my @tasks;
69 :     while (<TL>)
70 :     {
71 :     chomp;
72 :     my($id, $in, $nr, $args, $out, $err) = split(/\t/);
73 :    
74 :     my $simfile = $jobmap{basename($in)};
75 :     if (!$simfile)
76 :     {
77 :     $stage->fatal("Cannot map input file $in\n");
78 :     }
79 :    
80 :     $simfile = "$simdir/sims/$simfile.out";
81 :     if (! -f $simfile)
82 :     {
83 :     $stage->fatal("Cannot open mapped input file $simfile (for $in)");
84 :     }
85 :    
86 :     push(@tasks, [$id, $in, $nr, $args, $out, $err, $simfile]);
87 :     }
88 :    
89 :     #
90 :     # Process sims into $simdir/processed
91 :     #
92 :    
93 :     my $procdir = "$simdir/processed";
94 :     if (-d $procdir)
95 :     {
96 :     rename($procdir, "$procdir." . time);
97 :     }
98 :     mkdir($procdir) or $stage->fatal("cannot mkdir $procdir: $!");
99 :    
100 :     my $syn = "$jobdir/peg.synonyms";
101 :     my $nr = "$jobdir/nr";
102 :    
103 :     my $prefix = "sims." . $job->id();
104 :    
105 :     my $pipeline = "reformat_timelogic_sims | ";
106 :     $pipeline .= "reduce_sims $syn $hits_max | reformat_sims $nr | split_sims $procdir $prefix";
107 :    
108 :     open(PIPE, "|$pipeline") or $stage->fatal("cannot run pipeline $pipeline: $!");
109 :    
110 :     for my $task (@tasks)
111 :     {
112 :     my($id, $in, $nr, $args, $out, $err, $simfile) = @$task;
113 :    
114 :     open(F, "<$simfile") or $stage->fatal("Cannot open $simfile: $!");
115 :     copy(\*F, \*PIPE);
116 :     close(F);
117 :     }
118 :     close(PIPE) or $stage->fatal("Error closing pipeline $pipeline: \$!=$! \$?=$?");
119 :    
120 :     $stage->log("completed");
121 :     $stage->set_running("no");
122 :     $stage->set_status("complete");

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3