- Notifications
You must be signed in to change notification settings - Fork2
Write PubMed search results with two display options (citation or listview) to PDF or Word
License
nalomran/pubmed2doc
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Would you like your PubMed search results to be saved as PDF or Ms Word file format? If yes, then lookno further, I present to youpubmed2doc, a python module implemented to write your PubMed searchresults to PDF or Word file. The basic workflow of the module in a nutshell is as follow:
- It takes your query as an input and searches it against the PubMed database.
- The returned PubMed results will be then prepared in one of the two display options i.e citation or listview (basedon the user's choice).
- The prepared results will finally be written to user's supplied file choice (PDF or Word).
To my knowledge, PubMed doesn't offer this feature i.e saving (or exporting) the search results to PDF or Word andtherefore this module provides the following advantages:
- It doesn't require any intermediate software to aid in exporting the PubMed results to PDF or Word.
- It Keeps the document stored locally and can be retrieved at a later time.
- The generated document is easier to read, view and edit comparing with the csv or text files exported by PubMed.
- It can also be ported or incorporated easily into the user's own research resources.
You need to have python version >= 3.4 installed and a terminal (or similar program) to executethe module through the command line.
The following sections will guide you to execute the module successfully in a step-by-step fashioned.
The following are the core Python libraries (dependencies) required for this module:
biopythonfpdfpython-docx
First, you need to download the compressed file in GitHub.
Uncompress it and change to the directory
cd
:unzip Pubmed_To_Docs.zipcd Pubmed_To_Docs/
It is highly recommended to create conda or python virtual environment andinstall the aforementioned dependencies within such environment (OPTIONAL):
Creating conda virtual environment, please change "your_env_name" your desire environment name:
conda create -n your_env_nameconda activate your_env_name
Creating python virtual environment:
pip install virtualenvvirtualenv your_env_namesource your_env_name/bin/activate
Note: don't forget to de-activate your environment once you are completely done running the module:
# for conda envconda deactivate# for python envdeactivate
You may now try to install the dependencies by running the following command:
sudo pip install -r requirements.txt
- You will be prompted to enter a password if you run the
sudo
command, the password isthe root password (system administrator) of the computer you are currently running.
Please make sure you are in the same directory location as the module pubmed2doc.py, and you may try tocheck the presence of the module by running the following command:
ls -ltrh*.py
-q: a query to be searched against PubMed database (REQUIRED)
-e: a user's email to access to the PubMed db (REQUIRED)
-pdf: write PubMed results to PDF (OPTIONAL) (Default value is True)
-word: write PubMed results to Word (OPTIONAL) (Default value is False)
-retmax: total num of records from query to be retrieved (OPTIONAL)(Default value is 20)
-sopt: type of returned results display options (citation or listview)(OPTIONAL) (Default is citation)
-mndate: custom start or minimum publication date (OPTIONAL)"
-mxdate: custom end or maximum publication date (OPTIONAL)"
is_abstract: include abstract to your search results
- You can list all the module parameters by running the following command:
python pubmed2doc.py -h
- A Word or PDF document consists of the results from PubMed according to the type of display optionchosen by the user
python pubmed2doc.py \-q"gene expression" \-e"your_email" \-pdf F \-word T \-sopt listview
The above command is just an example, you can create your own advance query and include other arguments, please seeabove sub-section "Inputs + Options"
Please note that the output file will be saved in a directory called "output"
example_command.sh
You can modify the shell script to follow your needs.
That is it! Please check the output folder for your file
If you have an issue (error or bug) when executing the module or have any other enquires please feel free to sendme anemail and I will reply as soon as I can