Saber: Sequence Annotator for Biomedical Entities and Relations
Project description
Saber
Saber (Sequence Annotator for Biomedical Entities and Relations) is a deep-learning based tool for information extraction in the biomedical domain.
Installation • Quickstart • Documentation
Installation
To install Saber, you will need python>=3.5
. If not already installed, python>=3.5
can be installed via
- The official installer
- Homebrew, on MacOS (
brew install python3
) - Miniconda3 / Anaconda3
(OPTIONAL) Activate your virtual environment (see below for help)
$ conda activate saber
# Notice your command prompt has changed to indicate that the environment is active
(saber) $
then install Saber
(saber) $ pip install saber
To get the latest development version of Saber, install it right from this repository with pip
(saber) $ pip install https://github.com/BaderLab/saber.git
or by cloning the repository and then using pip
to install the package
(saber) $ git clone https://github.com/BaderLab/saber.git
(saber) $ cd saber
(saber) $ pip install .
For now, you will need to install the required Spacy model and the keras-contrib repository (even if you installed with pip install saber
)
# keras-contrib
(saber) $ pip install git+https://www.github.com/keras-team/keras-contrib.git
# NeuralCoref medium model built on top of Spacy, this might take a few minutes to download!
(saber) $ pip install https://github.com/huggingface/neuralcoref-models/releases/download/en_coref_md-3.0.0/en_coref_md-3.0.0.tar.gz
(OPTIONAL) Creating and activating virtual environments
When using pip
it is generally recommended to install packages in a virtual environment to avoid modifying system state. To create a virtual environment named saber
Using virtualenv or venv
Using virtualenv
$ virtualenv --python=python3 /path/to/new/venv/saber
Using venv
$ python3 -m venv /path/to/new/venv/saber
Next, you need to activate the environment
$ source /path/to/new/venv/saber/bin/activate
# Notice your command prompt has changed to indicate that the environment is active
(saber) $
Using Conda
If you use Conda, you can create an environment named saber
by running
$ conda create -n saber python=3.6
then activate the environment with
$ conda activate saber
# Again, your command prompt should change to indicate that the environment is active
(saber) $
Quickstart
If your goal is to use Saber to annotate biomedical text, then you can either use the web-service or a pre-trained model. If you simply want to check Saber out, without installing anything locally, try the Google Colaboratory notebook.
Google Colaboratory
The fastest way to check out Saber is by following along with the Google Colaboratory notebook (). In order to be able to run the cells, select "Open in Playground" or, alternatively, save a copy to your own Google Drive account (File > Save a copy in Drive).
Web-service
To use Saber as a local web-service, run
(saber) $ python -m saber.cli.app
or, if you prefer, you can pull & run the Saber image from Docker Hub
# Pull Saber image from Docker Hub
$ docker pull pathwaycommons/saber
# Run docker (use `-dt` instead of `-it` to run container in background)
$ docker run -it --rm -p 5000:5000 --name saber pathwaycommons/saber
There are currently two endpoints, /annotate/text
and /annotate/pmid
. Both expect a POST
request with a JSON payload, e.g.,
{
"text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53."
}
or
{
"pmid": 11835401
}
For example, running the web-service locally and using cURL
$ curl -X POST 'http://localhost:5000/annotate/text' \
--data '{"text": "The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53."}'
Documentation for the Saber web-service API can be found here.
Pre-trained models
First, import the Saber
class. This is the interface to Saber
from saber.saber import Saber
To load a pre-trained model, first create a Saber
object
saber = Saber()
and then load the model of our choice
saber.load('PRGE')
You can see all the pre-trained models in the web-service API docs or, the saber/pretrained_models folder in this repository, or by running the following line of code
from saber.constants import ENTITIES; print(list(ENTITIES.keys()))
To annotate text with the model, just call the Saber.annotate()
method
saber.annotate("The phosphorylation of Hdm2 by MK2 promotes the ubiquitination of p53.")
See the documentation for more details.
Documentation
Documentation for the Saber API can be found here. The web-service API has its own documentation here. Finally, we provide a jupyter notebook which introduces the main ways of using Saber. See here for help setting up JupyterLab.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file saber-0.1.0.tar.gz
.
File metadata
- Download URL: saber-0.1.0.tar.gz
- Upload date:
- Size: 39.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e373ac8f87ba2ce63a84dc2462821016b8ffc187c81772f9dbe1530c2d959af3 |
|
MD5 | f04ccdb9c3c477991f728d44f48db027 |
|
BLAKE2b-256 | 6f57d6f6d9b6b594194734a68af4b1c07b6d22b1da0425d2247ff897099c3a96 |