Giter Site home page Giter Site logo

nalomran / pubmed2doc Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 3.0 275 KB

Write PubMed search results with two display options (citation or listview) to PDF or Word

License: MIT License

Python 95.19% Shell 4.81%
bioinformatics pubmed pubmed-parser python3 biopython fpdf docx

pubmed2doc's Introduction

pubmed2doc

Introduction

Would you like your PubMed search results to be saved as PDF or Ms Word file format? If yes, then look no further, I present to you pubmed2doc, a python module implemented to write your PubMed search results to PDF or Word file. The basic workflow of the module in a nutshell is as follow:

  1. It takes your query as an input and searches it against the PubMed database.
  2. The returned PubMed results will be then prepared in one of the two display options i.e citation or listview (based on the user's choice).
  3. 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 and therefore this module provides the following advantages:

  1. It doesn't require any intermediate software to aid in exporting the PubMed results to PDF or Word.
  2. It Keeps the document stored locally and can be retrieved at a later time.
  3. The generated document is easier to read, view and edit comparing with the csv or text files exported by PubMed.
  4. It can also be ported or incorporated easily into the user's own research resources.

Getting Started

  • You need to have python version >= 3.4 installed and a terminal (or similar program) to execute the module through the command line.

  • The following sections will guide you to execute the module successfully in a step-by-step fashioned.

Prerequisites

  • The following are the core Python libraries (dependencies) required for this module:

    biopython
    fpdf
    python-docx

Install

  1. First, you need to download the compressed file in GitHub.

  2. Uncompress it and change to the directory cd:

    unzip Pubmed_To_Docs.zip
    cd Pubmed_To_Docs/
  3. It is highly recommended to create conda or python virtual environment and install 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_name
      conda activate your_env_name
    • Creating python virtual environment:

      pip install virtualenv
      virtualenv your_env_name
      source your_env_name/bin/activate
    • Note: don't forget to de-activate your environment once you are completely done running the module:

      # for conda env
      conda deactivate
      
      # for python env
      deactivate
  4. 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 is the root password (system administrator) of the computer you are currently running.

Running the Module (pubmed2doc.py)

  • Please make sure you are in the same directory location as the module pubmed2doc.py, and you may try to check the presence of the module by running the following command:

    ls -ltrh *.py  
    
  • Inputs + Options

    • -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

  • List All Module Parameters

    • You can list all the module parameters by running the following command:
    python pubmed2doc.py -h 
  • Output

    • A Word or PDF document consists of the results from PubMed according to the type of display option chosen by the user

1. Executing it with python command:

  • Command Example

    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 see above sub-section "Inputs + Options"

  • Please note that the output file will be saved in a directory called "output"

2. Executing it with the prepared shell script:

  • Command Example

    example_command.sh
  • You can modify the shell script to follow your needs.

  • That is it! Please check the output folder for your file

Asking for Help

If you have an issue (error or bug) when executing the module or have any other enquires please feel free to send me an email and I will reply as soon as I can

pubmed2doc's People

Contributors

nalomran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pubmed2doc's Issues

Pip instalation?

Thanks Nawaf for the nice tool.
Wouldn't be nice to enable installing the library directly through pip without the need to clone github repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.