[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.10 - (view) (download) (as text)

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

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3