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

Annotation of /FortyEight/rp_auto_assign.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : gdpusch 1.14 # -*- perl -*-
2 :     #########################################################################
3 :     # Copyright (c) 2003-2008 University of Chicago and Fellowship
4 :     # for Interpretations of Genomes. All Rights Reserved.
5 :     #
6 :     # This file is part of the SEED Toolkit.
7 :     #
8 :     # The SEED Toolkit is free software. You can redistribute
9 :     # it and/or modify it under the terms of the SEED Toolkit
10 :     # Public License.
11 :     #
12 :     # You should have received a copy of the SEED Toolkit Public License
13 :     # along with this program; if not write to the University of Chicago
14 :     # at info@ci.uchicago.edu or the Fellowship for Interpretation of
15 :     # Genomes at veronika@thefig.info or download a copy from
16 :     # http://www.theseed.org/LICENSE.TXT.
17 :     #########################################################################
18 : olson 1.1
19 :     #
20 :     # Perform auto-assignment on unassigned pegs.
21 :     #
22 :    
23 :     use strict;
24 : gdpusch 1.15
25 : olson 1.1 use FIG;
26 :     use FIG_Config;
27 : gdpusch 1.15 use SeedUtils;
28 :    
29 :     use Job48;
30 :     use GenomeMeta;
31 :    
32 : olson 1.1 use File::Basename;
33 : gdpusch 1.15 use Carp qw(croak confess);
34 : olson 1.1
35 :     @ARGV == 1 or die "Usage: $0 job-dir\n";
36 :    
37 :     my $jobdir = shift;
38 :    
39 :     -d $jobdir or die "$0: job dir $jobdir does not exist\n";
40 :    
41 :     my $genome = &FIG::file_head("$jobdir/GENOME_ID");
42 :     chomp $genome;
43 :     $genome =~ /^\d+\.\d+/ or die "$0: Cannnot find genome ID for jobdir $jobdir\n";
44 : gdpusch 1.15 my $genome_dir = "$jobdir/rp/$genome";
45 : olson 1.1
46 :     my $meta = new GenomeMeta($genome, "$jobdir/meta.xml");
47 :    
48 : gdpusch 1.15 my %done;
49 :    
50 : olson 1.1 my $tbl = "$jobdir/rp/$genome/Features/peg/tbl";
51 : gdpusch 1.15 (-f $tbl) || die "$0: Cannot find tbl file $tbl\n";
52 :     open(TBL, "<$tbl") or &fatal("Cannot open tbl file $tbl: $!");
53 : olson 1.1
54 :     my $proposed = "$jobdir/rp/$genome/proposed_functions";
55 : gdpusch 1.15 if (!open(PROP, "<$proposed")) {
56 : olson 1.1 warn "could not open proposed functions $proposed: $!";
57 :     $meta->add_log_entry($0, "could not open proposed fucntions $proposed");
58 :     }
59 : gdpusch 1.15 else {
60 :     while (<PROP>) {
61 : olson 1.1 chomp;
62 :     my($peg, $assign) = split;
63 :     $done{$peg} = $assign;
64 :     }
65 :     close(PROP);
66 :     }
67 :    
68 : olson 1.4 my $simfile = "$jobdir/rp/$genome/expanded_similarities";
69 : olson 1.6 my $cmd = "$FIG_Config::bin/auto_assign -orgdir $jobdir/rp/$genome > $jobdir/rp/$genome/proposed_non_ff_functions";
70 : olson 1.1 print "running $cmd\n";
71 :     open(AA, "| $cmd")
72 : gdpusch 1.15 or &fatal("aa failed: $!");
73 : olson 1.1
74 :     my $peg_count = 0;
75 : gdpusch 1.15 while (<TBL>) {
76 : olson 1.1 chomp;
77 :     my($peg, @rest) = split(/\t/);
78 : gdpusch 1.15 if (!$done{$peg}) {
79 :     ++$peg_count;
80 : olson 1.1 print AA "$peg\n";
81 :     }
82 :     }
83 :     close(TBL);
84 :    
85 :     $meta->add_log_entry($0, "computing auto_assign on $peg_count pegs");
86 :    
87 : gdpusch 1.15 if (!close(AA)) {
88 :     &fatal("error on close of pipe-cmd=\'$cmd\': \$?=$? \$!=$!");
89 : olson 1.1 }
90 :    
91 : gdpusch 1.15
92 :    
93 :     #+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
94 :     #... Call of `rapid_subsystem_inference` removed from `rapid_propagation`
95 :     # to here. -- /gdp
96 :     #-----------------------------------------------------------------------
97 :     my %func_of;
98 :     foreach my $file (map { $genome_dir . q(/) . $_
99 :     } qw(assigned_functions proposed_non_ff_functions proposed_functions)) {
100 :     if (-s $file) {
101 :     map { chomp; m/^(\S+)\t(.*)$/o ? ($func_of{$1} = $2) : () } &SeedUtils::file_read($file);
102 :     }
103 :     }
104 :    
105 :     open(METAB, qq(| rapid_subsystem_inference $genome_dir/Subsystems))
106 :     || die qq(Could not pipe-open rapid_subsystem_inference);
107 :     print METAB map { $_ . qq(\t) . $func_of{$_} . qq(\n) } (sort keys %func_of);
108 :     close(METAB);
109 :    
110 :    
111 :    
112 : olson 1.8
113 : olson 1.1 $meta->add_log_entry($0, "auto_assign completed\n");
114 :     $meta->set_metadata("status.auto_assign", "complete");
115 : olson 1.7 $meta->set_metadata("auto_assign.running", "no");
116 : olson 1.1
117 : gdpusch 1.15 sub fatal {
118 :     my ($msg) = @_;
119 :    
120 : olson 1.1 $meta->add_log_entry($0, ['fatal error', $msg]);
121 :     $meta->set_metadata("status.auto_assign", "error");
122 : gdpusch 1.15
123 : gdpusch 1.14 confess "$0: $msg";
124 : olson 1.1 }
125 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3