ELink with a Perl script

Condition


  • If we want to know another database associated with specific data in the other database, is there a method for connect two different databases in some cues? The following is the example that we give a nucleotide identifier as specific data and its related protein data as another database in the above description.

  • Perl Coding:

#!/usr/bin/perl

use strict;
use LWP::Simple;

# global variable
my $dbfrom = "nuccore";            # linked from
my $todb = "protein";            # linked to
my $linkName = "nuccore_protein";
my $baseURL = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils";

# ELink
my $id_list = "306412420,306412402,306412365";
my $url = $baseURL."/elink.fcgi?";
$url .= "dbfrom=$dbfrom&db=$todb&id=$id_list&linkname=$linkName&cmd=neighbor_history";

my $elink_res = get($url);

# another syntax to extract necessary web environment and query key information
my $webEnv = $1 if ($elink_res =~ m|(.*)|);
my $queryKey = $1 if ($elink_res =~ m|(.*)|);

# EFetch to capture protein sequence information
my $efetch_url = $baseURL."/efetch.fcgi?";
$efetch_url .= "db=$todb&query_key=$queryKey&WebEnv=$webEnv&rettype=fasta&retmode=text";

my $efetch_res = get($efetch_url);
print $efetch_res."\n";

results matching ""

    No results matching ""