[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.5 - (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 :     my $all_aliases = $fig->feature_aliases_bulk([ map { $_->[0] } @$all_data ]);
31 :     for my $feature (@$all_data)
32 : olson 1.1 {
33 :     my($fid, $loc, $aliases, $type, $b, $e, $func, $who) = @$feature;
34 : olson 1.2
35 : olson 1.5 $aliases = $all_aliases->{$fid};
36 :    
37 : olson 1.2 my @ss = $fig->peg_to_subsystems($fid, 1, 1);
38 : olson 1.3 @ss = map { defined($_) ? encode_utf8($_) : () } @ss;
39 : olson 1.2 my $ss = join("\n", map { s/_/ /g; $_ } @ss);
40 : olson 1.4 $ss =~ s/&/&amp;/g;
41 :     $ss =~ s/</&lt;/g;
42 :     $ss =~ s/>/&gt;/g;
43 : olson 1.1
44 : olson 1.3 $func = defined($func) ? encode_utf8($func) : "";
45 : olson 1.1 $func =~ s/&/&amp;/g;
46 :     $func =~ s/</&lt;/g;
47 :     $func =~ s/>/&gt;/g;
48 : olson 1.5 if ($aliases)
49 :     {
50 :     $aliases = join("\n", @$aliases);
51 :     $aliases =~ s/&/&amp;/g;
52 :     $aliases =~ s/</&lt;/g;
53 :     $aliases =~ s/>/&gt;/g;
54 :     }
55 : olson 1.1 if ($fid =~ /^fig\|(\d+)\.(\d+)\.([^.]+)\.(\d+)$/)
56 :     {
57 :     my ($g, $ext, $type, $num) = ($1, $2, $3, $4);
58 :     my $tnum = $tmap{$type};
59 :     my $enc = $g << 26 | $ext << 18 | $tnum << 16 | $num;
60 :     print <<END;
61 :     <sphinx:document id="$enc">
62 :     <fid>$fid</fid>
63 :     <annotation>$func</annotation>
64 : olson 1.5 <genome>$genome $gs</genome>
65 :     <alias>$aliases</alias>
66 :     <subsystem>$ss</subsystem>
67 : olson 1.1 </sphinx:document>
68 :     END
69 :     }
70 :     }
71 :     }
72 :     print "</sphinx:docset>\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3