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

View of /FigKernelScripts/sphinx_index_genome.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (download) (as text) (annotate)
Mon Jun 7 18:35:58 2010 UTC (9 years, 11 months ago) by olson
Branch: MAIN
Changes since 1.2: +2 -2 lines
remove undef warnings

use strict;
use Encode;
use FIG;
my $fig = new FIG;

print <<END;
<?xml version="1.0" encoding="utf-8"?>
<sphinx:docset>
<sphinx:schema>
<sphinx:field name="fid"/>
<sphinx:field name="annotation"/>
<sphinx:field name="content"/>
</sphinx:schema>
END

my %tmap = (peg => 1, rna => 2);

for my $genome ($fig->genomes(1))
{
    print STDERR "$genome\n";
    my $gs = $fig->genus_species($genome);
    for my $feature (@{$fig->all_features_detailed_fast($genome)})
    {
	my($fid, $loc, $aliases, $type, $b, $e, $func, $who) = @$feature;

	my @ss = $fig->peg_to_subsystems($fid, 1, 1);
	@ss = map { defined($_) ? encode_utf8($_) : () } @ss;
	my $ss = join("\n", map { s/_/ /g; $_ } @ss);
	
	$func = defined($func) ? encode_utf8($func) : "";
	$func =~ s/&/&amp;/g;
	$func =~ s/</&lt;/g;
	$func =~ s/>/&gt;/g;
	$aliases =~ s/&/&amp;/g;
	$aliases =~ s/</&lt;/g;
	$aliases =~ s/>/&gt;/g;
	$genome =~ s/&/&amp;/g;
	$genome =~ s/</&lt;/g;
	$genome =~ s/>/&gt;/g;
	$aliases =~ s/,/ /g;
	if ($fid =~ /^fig\|(\d+)\.(\d+)\.([^.]+)\.(\d+)$/)
	{
	    my ($g, $ext, $type, $num) = ($1, $2, $3, $4);
	    my $tnum = $tmap{$type};
	    my $enc = $g << 26 | $ext << 18 | $tnum << 16 | $num;
	    print <<END;
<sphinx:document id="$enc">
<fid>$fid</fid>
<annotation>$func</annotation>
<content>$genome $gs
$aliases
$ss</content>
</sphinx:document>
END
	}
    }
}
print "</sphinx:docset>\n";

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3