Question: Queries in PubMed and MEDLINE with Entrez
0
gravatar for pl640
6 days ago by
pl6400
pl6400 wrote:

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!

ADD COMMENTlink modified 3 days ago • written 6 days ago by pl6400

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 REPLYlink modified 6 days ago • written 6 days ago by a.zielezinski8.7k

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 REPLYlink written 1 day ago by pl6400
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1929 users visited in the last hour