suggest.pl

Auto-completion suggests are queried by PathwayLinker's main search box using this Perl script.

This is the documentation of all downloads.

Move your mouse over the code area and look at its top right corner where a set of icons for downloading, copy-pasting, etc. will appear.


#!/usr/bin/perl
use strict;
use warnings;

use JSON;
use CGI;
use Data::Dumper;
use lib "/home/adam/perllib";  # put here the directory containing Prefix.pm, Prefix/Dir.pm, Prefix/Hash.pm

use Tree::Prefix;

my $q = CGI->new;
print $q->header();

# ======================= parameters =======================
# note: no exception handling

my $prefix=lc $q->Vars->{term};
my $species=$q->Vars->{species};

if ($prefix eq "") { exit; }

# ======================= initialize =======================

my $path="/home/adam/autocomplete";  # put here the root directory of the downloaded+unpacked autocomplete data
our $limit=10;                       # number of suggestions to show
our $min_char=3;

our $tree=new Tree::Prefix;
$tree->{limit}=$limit;
$tree->set_basedir($path."/".$species);

my $results=$tree->list_files($prefix);
print encode_json $results;