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

Annotation of /FigKernelScripts/sphinx_index_genome.pl

Parent Directory Parent Directory | Revision Log Revision Log


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

1 : olson 1.1
2 :     use strict;
3 :     use Encode;
4 :     use FIG;
5 :     my $fig = new FIG;
6 :    
7 :     print <<END;
8 :     <?xml version="1.0" encoding="utf-8"?>
9 :     <sphinx:docset>
10 :     <sphinx:schema>
11 :     <sphinx:field name="fid"/>
12 :     <sphinx:field name="annotation"/>
13 : olson 1.5 <sphinx:field name="genome"/>
14 :     <sphinx:field name="alias"/>
15 :     <sphinx:field name="subsystem"/>
16 : olson 1.1 </sphinx:schema>
17 :     END
18 :    
19 :     my %tmap = (peg => 1, rna => 2);
20 :    
21 :     for my $genome ($fig->genomes(1))
22 :     {
23 :     print STDERR "$genome\n";
24 :     my $gs = $fig->genus_species($genome);
25 : olson 1.4 $gs =~ s/&/&amp;/g;
26 :     $gs =~ s/</&lt;/g;
27 :     $gs =~ s/>/&gt;/g;
28 : olson 1.5
29 :     my $all_data = $fig->all_features_detailed_fast($genome);
30 : olson 1.6
31 :     my $ext_aliases_l = $fig->db_handle->SQL(qq(SELECT id, alias
32 :     FROM ext_alias
33 :     WHERE id like 'fig|${genome}.%'));
34 :     my %ext_aliases;
35 :     map { $ext_aliases{$_->[0]}->{$_->[1]}++ } @$ext_aliases_l;
36 :    
37 : olson 1.5 for my $feature (@$all_data)
38 : olson 1.1 {
39 :     my($fid, $loc, $aliases, $type, $b, $e, $func, $who) = @$feature;
40 : olson 1.2
41 :     my @ss = $fig->peg_to_subsystems($fid, 1, 1);
42 : olson 1.3 @ss = map { defined($_) ? encode_utf8($_) : () } @ss;
43 : olson 1.2 my $ss = join("\n", map { s/_/ /g; $_ } @ss);
44 : olson 1.4 $ss =~ s/&/&amp;/g;
45 :     $ss =~ s/</&lt;/g;
46 :     $ss =~ s/>/&gt;/g;
47 : olson 1.1
48 : olson 1.3 $func = defined($func) ? encode_utf8($func) : "";
49 : olson 1.1 $func =~ s/&/&amp;/g;
50 :     $func =~ s/</&lt;/g;
51 :     $func =~ s/>/&gt;/g;
52 : olson 1.6
53 :     my %aliases = map { $_ => 1 } split(",", $aliases);
54 :     map { $aliases{$_} = 1 } keys %{$ext_aliases{$fid}};
55 :     my @aliases = keys %aliases;
56 :     my $alias_txt = "";
57 :     if (@aliases)
58 : olson 1.5 {
59 : olson 1.6 $alias_txt = join("\n",
60 :     map { s/&/&amp;/g;
61 :     s/</&lt;/g;
62 :     s/>/&gt;/g;
63 :     $_ } @aliases);
64 : olson 1.5 }
65 : olson 1.1 if ($fid =~ /^fig\|(\d+)\.(\d+)\.([^.]+)\.(\d+)$/)
66 :     {
67 :     my ($g, $ext, $type, $num) = ($1, $2, $3, $4);
68 :     my $tnum = $tmap{$type};
69 :     my $enc = $g << 26 | $ext << 18 | $tnum << 16 | $num;
70 :     print <<END;
71 :     <sphinx:document id="$enc">
72 :     <fid>$fid</fid>
73 :     <annotation>$func</annotation>
74 : olson 1.5 <genome>$genome $gs</genome>
75 : olson 1.6 <alias>$alias_txt</alias>
76 : olson 1.5 <subsystem>$ss</subsystem>
77 : olson 1.1 </sphinx:document>
78 :     END
79 :     }
80 :     }
81 :     }
82 :     print "</sphinx:docset>\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3