Hi, I'm new here and I need help.
I have an array with all the PMIDs I get as my query in pubmed using Entrez.esearch, but I need the PMCID to after then access the full article. Can someone help me?
Hi, I'm new here and I need help.
I have an array with all the PMIDs I get as my query in pubmed using Entrez.esearch, but I need the PMCID to after then access the full article. Can someone help me?
You'll need to use eUtils, specifically eLink. You can re-use this Python script that I've written (tested in Python 2.7), called PMIDtoPMCID.py
import sys
import argparse
from Bio import Entrez
parser = argparse.ArgumentParser(description="Looks up PMCID with OMID")
parser.add_argument("-e", action="store", dest="EmailAddress", required=True, help="Entrez requires your email address.")
parser.add_argument("-i", action="store", dest="SearchTerm", required=True, help="PMID.")
arguments = parser.parse_args()
Entrez.email = arguments.EmailAddress
SearchTerm = arguments.SearchTerm
handle = Entrez.elink(dbfrom="pubmed", db="pmc", linkname="pubmed_pmc", id=SearchTerm, retmode="text")
print(handle.read())
handle.close()
Now try it:
python PMIDtoPMCID.py -e MyWine@chardonnay.com -i 21990379
https://eutils.ncbi.nlm.nih.gov/eutils/dtd/20101123/elink.dtd">
<eLinkResult>
<LinkSet>
<DbFrom>pubmed</DbFrom>
<IdList>
<Id>21990379</Id>
</IdList>
<LinkSetDb>
<DbTo>pmc</DbTo>
<LinkName>pubmed_pmc</LinkName>
<Link>
<Id>3266030</Id>
</Link>
</LinkSetDb>
</LinkSet>
</eLinkResult>
I'll have to leave it to you to parse the output. The PMCID is 3266030
Kevin
In case this is useful, Europe PMC (PubMed Central partner) provides a file with PMID-PMCID-DOI mappings that you can download via FTP: ftp://ftp.ebi.ac.uk/pub/databases/pmc/DOI/ Disclaimer: I work for Europe PMC
Here is a complete solution. you need to pass an email
for Entrez API requests and obviously the pmid
which you need to cenvert
from Bio import Entrez
import xml.etree.ElementTree as ET
def pmid2pmcid(email, pmid):
Entrez.email = email
handle = Entrez.elink(dbfrom="pubmed", db="pmc", linkname="pubmed_pmc", id=pmid, retmode="text")
handle_read = handle.read()
handle.close()
root = ET.fromstring(handle_read)
pmcid = ""
for link in root.iter('Link'):
for id in link.iter('Id'):
pmcid = id.text
return pmcid
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
it would help if you post example PMIDs. Try NCBI eutils and here is a shell solution:
output:
input: