[Bio] / FigKernelScripts / make_annotations_for_sprout.pl Repository:
ViewVC logotype

Annotation of /FigKernelScripts/make_annotations_for_sprout.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : overbeek 1.1 # -*- perl -*-
2 : olson 1.12 #
3 :     # Copyright (c) 2003-2006 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 :    
19 : overbeek 1.1
20 :     use FIG;
21 :     ($fig = new FIG) || die "FIG constructor failed";
22 :    
23 :     $usage = "make_FIG_annotations_for_sprout GenomeFile AnnotationsFile IsTargetOfFile MadeAnnotationFile";
24 :    
25 :     (@ARGV
26 :     && ($genomes_file = shift) && (-s $genomes_file)
27 :     && ($annotations_file = shift)
28 :     && ($istarget_file = shift)
29 :     && ($makeannot_file = shift)
30 : overbeek 1.2 ) || die "\n usage: $usage\n\n";
31 : overbeek 1.1
32 :     @genomes = grep { m/^(\S+)/; $_ = $1 } `cut -f1 $genomes_file`;
33 :    
34 : overbeek 1.4 open(ANNOT, "| sort -u > $annotations_file") || die "could not write-open $annotations_file";
35 :     open(TARGET, "| sort -u > $istarget_file") || die "could not write-open $istarget_file";
36 :     open(MAKEAN, "| sort -u > $makeannot_file") || die "could not write-open $makeannot_file";
37 : overbeek 1.1
38 :     $time = time();
39 : olson 1.3 %user_time = (KEGG => $time + 1,
40 : parrello 1.11 NCBI => $time + 2,
41 :     SwissProt => $time + 3,
42 :     UniProt => $time + 4);
43 : overbeek 1.1 $tick = 0;
44 :     foreach $org (@genomes)
45 :     {
46 :     print STDERR "Processing $org " if $ENV{FIG_VERBOSE};
47 :    
48 : overbeek 1.4 @pegs = $fig->pegs_of($org);
49 : overbeek 1.1 warn "No pegs for $org" unless @pegs;
50 :    
51 :     foreach $peg (@pegs)
52 :     {
53 : parrello 1.11 my %seen_timestamp;
54 :     if ($ENV{FIG_VERBOSE} && ($tick >= 1000)) { print STDERR '.'; $tick = 0; } else {++$tick; }
55 :    
56 :     if ($func = $fig->function_of($peg))
57 :     {
58 :     if (!$fig->hypo($func))
59 :     {
60 :     print ANNOT "$peg:$time\t$time\tFIG\\nSet FIG function to\\n$func\n";
61 :     print TARGET "$peg\t$peg:$time\n";
62 :     print MAKEAN "FIG\t$peg:$time\n";
63 :     }
64 :    
65 :     foreach $x ($fig->feature_annotations($peg,"raw"))
66 :     {
67 :     (undef, $timestamp, $user, $annot) = @$x;
68 :     $annot =~ s/\cM//gs;
69 :     $annot =~ s/\n/\\n/gs;
70 :     $annot =~ s/\t/\\t/gs;
71 : overbeek 1.10 # if ($annot !~ m/^Set .*function to/)
72 :     $annot =~ s/Set master function/Set FIG function/s;
73 : parrello 1.11 {
74 :     if ($timestamp =~ /^\d+$/)
75 :     {
76 :     while ($seen_timestamp{$timestamp})
77 :     {
78 :     $timestamp++;
79 :     }
80 :     $seen_timestamp{$timestamp} = 1;
81 :     print ANNOT "$peg:$timestamp\t$timestamp\t$user\\n$annot\n";
82 :     print TARGET "$peg\t$peg:$timestamp\n";
83 :     print MAKEAN "$user\t$peg:$timestamp\n";
84 :     }
85 :     else
86 :     {
87 :     print STDERR "$peg has nonnumeric timestamp in annotations\n";
88 :     }
89 :     }
90 :     }
91 : overbeek 1.10
92 :     # We pick up external assignments separately, so these are unnecessary
93 : parrello 1.11 #
94 :     # if (@aliases = $fig->mapped_prot_ids($peg))
95 :     # {
96 :     # foreach $alias_record (@aliases)
97 :     # {
98 :     # $alias = $alias_record->[0];
99 :     # $func = $fig->function_of($alias);
100 :     #
101 :     # $user = $setname = "";
102 :     # if ($alias =~ m/^fig\|/)
103 :     # {
104 :     # next;
105 :     # }
106 :     # elsif ($alias =~ m/^kegg\|/)
107 :     # {
108 :     # $user = $setname = 'KEGG';
109 :     # }
110 :     # elsif ($alias =~ m/^gi\|/)
111 :     # {
112 :     # $user = $setname = 'NCBI';
113 :     # }
114 :     # elsif ($alias =~ m/^(sp|tr|tn)\|/)
115 :     # {
116 :     # $user = $setname = 'SwissProt';
117 :     # }
118 :     # elsif ($alias =~ m/^uni\|/)
119 :     # {
120 :     # $user = $setname = 'UniProt';
121 :     # }
122 :     # else
123 :     # {
124 :     # warn "could not handle alias $alias";
125 :     # next;
126 :     # }
127 :     #
128 :     # if ($user && $setname && $func)
129 :     # {
130 :     # my $thistime = $user_time{$user};
131 :     # die "No time found for user $user" unless defined($thistime);
132 :     # print ANNOT "$alias:$thistime\t$thistime\t$user\\nSet $setname function to\\n$func\n";
133 :     # print TARGET "$peg\t$alias:$thistime\n";
134 :     # print MAKEAN "$user\t$alias:$thistime\n";
135 :     # }
136 :     # }
137 :     # }
138 :     }
139 : overbeek 1.1 }
140 :    
141 :     print STDERR "\n" if $ENV{FIG_VERBOSE};
142 :     }

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3