Queries in PubMed and MEDLINE with Entrez
0
0
Entering edit mode
5.5 years ago
pl640 • 0

I'm trying to set up a PubMed query using Entrez and MEDLINE to retrieve journals about a complicated subject. I want to retrieve the most relevant abstracts of articles about the effectiveness of various drugs and treatments in infantile colic. Moreover, I want to see what MESH terms are linked to the search query. My goal is to improve the search query as much as possible, so I need a way in which I can build on top of my results.

-Update, I've replaced my last code with its newest version-

I've succeeded partly in setting up the general code for extracting titles, PMIDs, MeSH terms and Abstracts of a query. I'm now trying to create a loop in which I can test different queries and their results. Does anyone know how to efficiently create a loop? Or does anyone have an useful tutorial for doing this?

#Initialisation
Entrez.api_key = "example"
Entrez.email = "example@example.com"

TERM= "infant*[mh] AND colic[majr]"

handle = Entrez.egquery(term=TERM)
record = Entrez.read(handle)
for row in record["eGQueryResult"]:
    if row["DbName"]=="pubmed":
        print(row["Count"])

handle = Entrez.esearch(db="pubmed",
                        term=TERM,
                        retmax='100',
                        sort='relevance',
                        retmode='xml',
                        mindate="2016/11",
                        maxdate="2019/02")
record = Entrez.read(handle)
handle.close()
idlist = record["IdList"]
for i in idlist:
    if i == '27631535':
        idlist.remove(i)

print(idlist)

#downloading the corresponding MEDLINE records
handle = Entrez.efetch(db="pubmed",
                       id=idlist, rettype="medline", retmode="json")
records = Medline.parse(handle)
records = list(records)
for record in records:
    #if record[PMID] == '27631535':
        #records.remove(record)
    print("title:", record.get("TI", "?"))
    print("PMID:", record.get("PMID", "?"))
    print("MeSH Terms:", record.get("MH","?"))
    #print("abstracts:", record.get("AB", "?"))
    print("")

Many thanks in advance!

Biopython Entrez Pubmed MESH medline • 1.9k views
ADD COMMENT
0
Entering edit mode

Go to PubMed and play with your query first. I suggest something like these:

  • (infantile colic[mesh] AND effectiveness) AND (drugs OR herbal* OR sugar* OR safety)
  • (infantile colic[mesh] AND treatment) AND (effectiveness OR drugs OR herbal* OR sugar* OR safety)

Remember, that parenthesis in your query are important.

ADD REPLY
0
Entering edit mode

Thank you for your response, I've experimented with the queries in PubMed and I've set up a list of queries that I want to test. Do you have recommendations of how to efficiently incorporate a loop in my code to do so?

ADD REPLY

Login before adding your answer.

Traffic: 2579 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6