Skip to content

Python code for searching PubMed using the Entrez API.

Notifications You must be signed in to change notification settings

markuslibrary/pubmed-search

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pubmed Search

This code contains functions for using the NIH's Entrez API to search the PubMed database and retrieve/download search results.

get_results

This function retrieves raw results from a PubMed search given an input string to search. Specify the search type using the parameter_type variable, which is a string. You can choose between 'keyword', 'identifier', 'author', or 'advanced'.

For the first three options, use the search_term variable and enter the desired search term as a string. For the advanced search, enter the search query from the PubMed Advanced Search Builder as a string.

The results_cap variable dictates how many results will be returned (the default is 10). If the search returns a list of results longer than the value of results_cap, a warning will be printed.

The output of this function is a dictionary containing the raw search results from PubMed.

get_pmids

This function takes in the raw results returned by get_results() and returns the PMIDs as a list of strings.

export_pmids

This function takes in the raw results returned by get_results() and exports the list of PMIDs in .txt or .csv format. You can dictate the desired file type by specifying the filetype variable as '.txt' or '.csv'. You may also assign the value of the filename variable as a string to specify the name of the output file, as well as the desired saving location by adding a file path.

export_results

This function takes in the raw results returned by get_results() and exports the full details in .txt or .csv format. You can dictate the desired file type by specifying the filetype variable as '.txt' or '.csv'. You may also assign the value of the filename variable as a string to specify the name of the output file, as well as the desired saving location by adding a file path.

export_citations

This function takes in the list of PMIDs returned by get_pmids() (or just a list of PMIDs) and exports a RIS citation file, which is compatible with most reference management software. You may assign the value of the filename variable as a string to specify the name of the output file, as well as the desired saving location by adding a file path.

About

Python code for searching PubMed using the Entrez API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages