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

Annotation of /FortyEight/rp_preprocess_sims.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1
2 :    
3 :     use strict;
4 :     use FIG;
5 :     use FIG_Config;
6 :     use File::Basename;
7 :     use GenomeMeta;
8 :     use Carp 'croak';
9 :    
10 :     @ARGV == 3 or die "Usage: $0 job-dir NR peg.synonyms\n";
11 :    
12 :     my $jobdir = shift;
13 :     my $sims_nr = shift;
14 :     my $sims_peg_synonyms = 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 $meta = new GenomeMeta($genome, "$jobdir/meta.xml");
23 :    
24 :     #
25 :     # Use pull_sims_from_server to extract sims for the fasta file we have,
26 :     # writing them to jobdir/sims.job/sims.server. Write the sequences that did not
27 :     # have sims to jobdir/sims.job/seqs_needing_sims.
28 :     #
29 :     # Use rp_chunk_sims to chunk the remaining sims, setting up for the main
30 :     # pipeline script to submit them.
31 :     #
32 :    
33 :     my $fasta = "$jobdir/rp/$genome/Features/peg/fasta";
34 :     if (! -f $fasta)
35 :     {
36 :     &fatal("Fasta file $fasta is not present");
37 :     }
38 :    
39 :     -d "$jobdir/sims.job" or mkdir "$jobdir/sims.job" or die "mkdir $jobdir/sims.job failed: $!";
40 :    
41 :     my $server_sims = "$jobdir/sims.job/sims.server";
42 :     my $seqs_needing_sims = "$jobdir/sims.job/seqs_needing_sims";
43 :     my $ids_needing_sims = "$jobdir/sims.job/ids_needing_sims";
44 :    
45 : olson 1.2 my $cmd;
46 :     if ($FIG_Config::rast_sims_database)
47 :     {
48 :     my($dsn, $user, $pw, $tbl) = @$FIG_Config::rast_sims_database;
49 : olson 1.3 $cmd = "$FIG_Config::bin/pull_sims_from_database '$dsn' '$user' '$pw' '$tbl' < $fasta > $server_sims 2> $ids_needing_sims";
50 : olson 1.2 }
51 :     else
52 :     {
53 :     $cmd = "$FIG_Config::bin/pull_sims_from_server < $fasta > $server_sims 2> $ids_needing_sims";
54 :     }
55 : olson 1.1 $meta->add_log_entry($0, $cmd);
56 :     my $rc = system($cmd);
57 :     if ($rc != 0)
58 :     {
59 :     &fatal("pull_sims_from_server failed with rc=$rc: $cmd");
60 :     }
61 :    
62 :     #
63 :     # Reinflate the ids to a fasta.
64 :     #
65 :    
66 :     $cmd = "$FIG_Config::bin/pull_fasta_entries $fasta < $ids_needing_sims > $seqs_needing_sims";
67 :     $rc = system($cmd);
68 :     if ($rc != 0)
69 :     {
70 :     &fatal("pull_fasta_entries failed with rc=$rc: $cmd");
71 :     }
72 :    
73 :     #
74 :     # And chunk.
75 :     #
76 :     $cmd = "$FIG_Config::bin/rp_chunk_sims -include-self -self-fasta $fasta $seqs_needing_sims $sims_nr $sims_peg_synonyms $jobdir/sims.job > $jobdir/sims.job/chunk.out";
77 :     $rc = system($cmd);
78 :     if ($rc != 0)
79 :     {
80 :     &fatal("rp_chunk_sims failed with rc=$rc: $cmd");
81 :     }
82 :    
83 :    
84 :     $meta->add_log_entry($0, "sims_preprocess completed\n");
85 :     $meta->set_metadata("status.sims_preprocess", "complete");
86 :     $meta->set_metadata("sims_preprocess.running", "no");
87 :    
88 :     sub fatal
89 :     {
90 :     my($msg) = @_;
91 :    
92 :     $meta->add_log_entry($0, ['fatal error', $msg]);
93 :     $meta->set_metadata("status.sims_preprocess", "error");
94 :    
95 :     croak "$0: $msg";
96 :     }
97 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3