Domanda

Is it possible to transform pmc-ids (pubmed central ids) to pmids (pubmed ids) via a ncbi api? You can do it via the web form but I would like to use a program - of course I can always write a screen scrapper ... thanks

È stato utile?

Soluzione

You can convert pubmed central ids to pubmed ids with EFetch, from the NCBI Entrez Programming Utilities (E-utilities). It is possible to use EFetch from any programming language that can read data from HTTP and parse XML.

For example, if one of the articles in your list is:

Wang TT, et al. J Biol Chem. 2010 Jan 22;285(4):2227-31.
PubMed PMID: 19948723 PubMed Central PMCID: PMC2807280

You can get an XML document from the following EFetch url:

"http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&id=2807280&rettype=medline&retmode=xml"

The XML document contains the PubMed ID:

<pmc-articleset>
   <article>
     <front>
        <article-meta>
            <article-id pub-id-type="pmc">2807280</article-id>
            <article-id pub-id-type="pmid">19948723</article-id>

One way to convert a pmcid to a pmid in perl is:

#!/usr/bin/perl
# pmcid2pmid.pl -- convert a pubmed central id to a pubmed id with EFetch 
# http://eutils.ncbi.nlm.nih.gov/corehtml/query/static/efetchlit_help.html

use strict;
use warnings;
use LWP::UserAgent;    # send request to eutils.ncbi.nlm.nih.gov
use XML::Smart;        # parse response

# check parameter
my ($id) = @ARGV;
if ( not(defined($id))  ) { 
    print STDERR "must provide a pmcid as 1st parameter...\n";  
    exit(-1);
}    

$id =~ s/PMC//;
sleep(3);  #  recommended delay between queries

# build & send efetch query
my $efetch= "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?";
my $efetch_query = "db=pmc&id=$id&rettype=medline&retmode=xml";
my $url = $efetch.$efetch_query;

my $xml  = XML::Smart->new($url);
##print $xml->dump_tree(),"\n";

# parse the response
$xml = $xml->{'pmc-articleset'}->{'article'}->{'front'}{'article-meta'};
my $pmid   = $xml->{'article-id'}('pub-id-type','eq','pmid')->content; 

print STDOUT "PMID = $pmid";

>perl pmcid2pmid.pl PMC2807280
PMID = 19948723

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top