# Papyrus-scripts
Collection of scripts to interact with the Papyrus bioactivity dataset.
![alt text](https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/papyrus_workflow.svg)
<br/>
**Associated Article:** <a href="https://doi.org/10.1186/s13321-022-00672-x">10.1186/s13321-022-00672-x</a>
```
Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
Papyrus - A large scale curated dataset aimed at bioactivity predictions.
J Cheminform 15, 3 (2023). https://doi.org/10.1186/s13321-022-00672-x
```
**Associated Preprint:** <a href="https://doi.org/10.33774/chemrxiv-2021-1rxhk">10.33774/chemrxiv-2021-1rxhk</a>
```
Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
Papyrus - A large scale curated dataset aimed at bioactivity predictions.
ChemRxiv. Cambridge: Cambridge Open Engage; 2021;
This content is a preprint and has not been peer-reviewed.
```
## Installation
```bash
pip install papyrus-scripts
```
:warning: If pip gives the following error and resolves in import errors
```bash
Defaulting to user installation because normal site-packages is not writeable
```
Then uninstall and reinstalling the library with the following commands:
```bash
pip uninstall -y papyrus-scripts
python -m pip install papyrus-scripts
```
Additional dependencies can be installed to allow:
- similarity and substructure searches
```bash
conda install FPSim2 openbabel h5py cupy -c conda-forge
```
- training DNN models:
```bash
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
```
## Getting started
### The new application programming interface (API)
This new object-oriented API is available since version 2.0.0.
It allows for easier filtering of the Papyrus data and ensures that any data being queried is downloaded.
```python
from papyrus_scripts import PapyrusDataset
data = (PapyrusDataset(version='05.7', plusplus=True) # Downloads the data if needed
.keep_source(['chembl', 'sharma']) # Keep specific sources
.keep_quality('high')
.proteins() # Get the corresponding protein targets
)
```
### Functional API (legacy)
The functional API requires the data to be downloaded beforehand.<br/>
One can donwload the dataset either with the functional API itself or the command line interface (CLI).
#### Donwloading with the command line interface (CLI)
The following command will download the Papyrus++ bioactivities and protein targets (high-quality Ki and KD data as well as IC50 and EC50 of reproducible assays) for the latest version.
```bash
papyrus download -V latest
```
The following command will donwload the entire set of high-, medium-, and low-quality bioactivities and protein targets along with all precomputed molecular and protein descriptors for version 05.5.
```bash
papyrus download -V 05.5 --more --d all
```
The following command will download Papyrus++ bioactivities, protein targets and compound structures for both version 05.4 and 05.5.
```bash
papyrus download -V 05.5 -V 05.4 -S
```
More options can be found using
```bash
papyrus download --help
```
By default, the data is downloaded to [pystow](https://github.com/cthoyt/pystow)'s default directory.<br/>
One can override the folder path by specifying the `-o` switch in the above commands.
#### Donwloading with the functional API
```python
from papyrus_scripts import download_papyrus
# Donwload the latest version of the entire dataset with all precomputed descriptors
download_papyrus(version='latest', only_pp=False, structures=True, descriptors='all')
```
#### Querying with the functional API
The query detailed above using the object-oriented API is reproduced below using the functional API.
```python
from papyrus_scripts import (read_papyrus, read_protein_set,
keep_quality, keep_source, keep_type,
keep_organism, keep_accession, keep_protein_class,
keep_match, keep_contains,
consume_chunks)
chunk_reader = read_papyrus(version='05.7', plusplus=True, is3d=False, chunksize=1_000_000)
protein_data = read_protein_set(version='05.7')
filter1 = keep_source(data=chunk_reader, source=['chembl', 'sharma'])
filter2 = keep_quality(data=filter1, min_quality='high')
data = consume_chunks(filter2, progress=False)
protein_data = protein_data.set_index('target_id').loc[data.target_id.unique()].reset_index()
```
## Versions of the Papyrus dataset
Different online servers host the Papyrus data based on release and ChEMBL version (table below).
| Papyrus version | ChEMBL version | Zenodo | 4TU |
|:---------------:|:--------------:|:---------------------------------------------------------:|:---------------------------------------------------------:|
| 05.4 | 29 | [:heavy_check_mark:](https://zenodo.org/records/10944245) | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) |
| 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/records/10943207) | :x: |
| 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/records/7821775) | :x: |
| 05.7 | 34 | [:heavy_check_mark:](https://zenodo.org/records/13787634) | :x: |
Precomputed molecular and protein descriptors along with molecular structures (2D for default set and 3D for low quality set with stereochemistry) are not available for version 05.4 from 4TU but are from Google Drive.
As stated in the pre-print **we strongly encourage** the use of the dataset in which stereochemistry was not considered.
This corresponds to files containing the mention "2D" and/or "without_stereochemistry".
## Interconversion of the compressed files
The available LZMA-compressed files (*.xz*) may not be supported by some software (e.g. Pipeline Pilot).
<br/>**Decompressing the data is strongly discouraged!**<br/>
Though Gzip files were made available at 4TU for version 05.4, we now provide a CLI option to locally interconvert from LZMA to Gzip and vice-versa.
To convert from LZMA to Gzip (or vice-versa) use the following command:
```bash
papyrus convert -v latest
```
## Removal of the data
One can remove the Papyrus data using either the CLI or the API.
The following exerts exemplify the removal of all Papyrus data files, including all versions utility files.
```bash
papyrus clean --remove_root
```
```python
from papyrus_scripts import remove_papyrus
remove_papyrus(papyrus_root=True)
```
## Easy handling of the dataset
Once installed the Papyrus-scripts allow for the easy filtering of the data.<br/>
- Simple examples can be found in the <a href="https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/simple_examples.ipynb">simple_examples.ipynb</a> notebook. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/simple_examples.ipynb)
- An example on matching data with the Protein Data Bank can be found in the <a href="https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/matchRCSB.ipynb">simple_examples.ipynb</a> notebook. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/matchRCSB.ipynb)
- More advanced examples will be added to the <a href="https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/advanced_querying.ipynb">advanced_querying.ipynb</a> notebook.
## Reproducing results of the pre-print
The scripts used to extract subsets, generate models and obtain visualizations can be found <a href="https://github.com/OlivierBeq/Papyrus-modelling">here</a>.
## Features to come
- [x] Substructure and similarity molecular searches
- [x] ability to use DNN models
- [x] ability to repeat model training over multiple seeds
- [x] y-scrambling
- [ ] adapt models to QSPRpred
## Examples to come
- Use of custom grouping schemes for training/test set splitting and cross-validation
- Use custom molecular and protein descriptors (either Python function or file on disk)
## Logos
Logos can be found under <a href="https://github.com/OlivierBeq/Papyrus-scripts/tree/master/figures/logo">**figures/logo**</a>
Two version exist depending on the background used.
:warning: GitHub does not render the white logo properly in the table below but should not deter you from using it!
<div class="colored-table">
| On white background | On colored background |
|:--------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/logo/Papyrus_trnsp-bg.svg" width=200> | <img src="https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/logo/Papyrus_trnsp-bg-white.svg" width=200> |
</div>
Raw data
{
"_id": null,
"home_page": "https://github.com/OlivierBeq/Papyrus-scripts",
"name": "papyrus-scripts",
"maintainer": "Olivier J. M. B\u00e9quignon",
"docs_url": null,
"requires_python": null,
"maintainer_email": "\"olivier.bequignon.maintainer@gmail.com\"",
"keywords": "bioactivity data, QSAR, proteochemometrics, cheminformatics, modelling, machine learning",
"author": "Olivier J. M. B\u00e9quignon - Brandon J. Bongers - Willem Jespers",
"author_email": "\"olivier.bequignon.maintainer@gmail.com\"",
"download_url": "https://files.pythonhosted.org/packages/1e/51/7384b55851506dee3ef93465a5e7150b29ec51102cdf997ea3c711217764/papyrus_scripts-2.1.1.tar.gz",
"platform": null,
"description": "# Papyrus-scripts\r\n\r\nCollection of scripts to interact with the Papyrus bioactivity dataset.\r\n\r\n![alt text](https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/papyrus_workflow.svg)\r\n\r\n<br/>\r\n\r\n**Associated Article:** <a href=\"https://doi.org/10.1186/s13321-022-00672-x\">10.1186/s13321-022-00672-x</a>\r\n```\r\nB\u00e9quignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.\r\nPapyrus - A large scale curated dataset aimed at bioactivity predictions.\r\nJ Cheminform 15, 3 (2023). https://doi.org/10.1186/s13321-022-00672-x\r\n```\r\n\r\n**Associated Preprint:** <a href=\"https://doi.org/10.33774/chemrxiv-2021-1rxhk\">10.33774/chemrxiv-2021-1rxhk</a>\r\n```\r\nB\u00e9quignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.\r\nPapyrus - A large scale curated dataset aimed at bioactivity predictions.\r\nChemRxiv. Cambridge: Cambridge Open Engage; 2021;\r\nThis content is a preprint and has not been peer-reviewed.\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\npip install papyrus-scripts\r\n``` \r\n\r\n:warning: If pip gives the following error and resolves in import errors\r\n```bash\r\nDefaulting to user installation because normal site-packages is not writeable\r\n```\r\nThen uninstall and reinstalling the library with the following commands:\r\n```bash\r\npip uninstall -y papyrus-scripts\r\npython -m pip install papyrus-scripts\r\n```\r\n\r\nAdditional dependencies can be installed to allow:\r\n - similarity and substructure searches\r\n ```bash\r\n conda install FPSim2 openbabel h5py cupy -c conda-forge\r\n ```\r\n\r\n- training DNN models:\r\n ```bash\r\n conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch\r\n ```\r\n\r\n## Getting started\r\n\r\n### The new application programming interface (API)\r\nThis new object-oriented API is available since version 2.0.0.\r\n\r\nIt allows for easier filtering of the Papyrus data and ensures that any data being queried is downloaded.\r\n\r\n```python\r\nfrom papyrus_scripts import PapyrusDataset\r\n\r\ndata = (PapyrusDataset(version='05.7', plusplus=True) # Downloads the data if needed\r\n .keep_source(['chembl', 'sharma']) # Keep specific sources\r\n .keep_quality('high')\r\n .proteins() # Get the corresponding protein targets\r\n )\r\n```\r\n\r\n### Functional API (legacy)\r\n\r\nThe functional API requires the data to be downloaded beforehand.<br/>\r\nOne can donwload the dataset either with the functional API itself or the command line interface (CLI).\r\n\r\n#### Donwloading with the command line interface (CLI)\r\nThe following command will download the Papyrus++ bioactivities and protein targets (high-quality Ki and KD data as well as IC50 and EC50 of reproducible assays) for the latest version.\r\n```bash\r\npapyrus download -V latest\r\n```\r\nThe following command will donwload the entire set of high-, medium-, and low-quality bioactivities and protein targets along with all precomputed molecular and protein descriptors for version 05.5.\r\n```bash\r\npapyrus download -V 05.5 --more --d all \r\n```\r\nThe following command will download Papyrus++ bioactivities, protein targets and compound structures for both version 05.4 and 05.5.\r\n```bash\r\npapyrus download -V 05.5 -V 05.4 -S \r\n```\r\n\r\nMore options can be found using \r\n```bash\r\npapyrus download --help \r\n```\r\n\r\nBy default, the data is downloaded to [pystow](https://github.com/cthoyt/pystow)'s default directory.<br/>\r\nOne can override the folder path by specifying the `-o` switch in the above commands.\r\n\r\n#### Donwloading with the functional API\r\n\r\n```python\r\n\r\nfrom papyrus_scripts import download_papyrus\r\n\r\n# Donwload the latest version of the entire dataset with all precomputed descriptors\r\ndownload_papyrus(version='latest', only_pp=False, structures=True, descriptors='all')\r\n```\r\n\r\n#### Querying with the functional API\r\n\r\nThe query detailed above using the object-oriented API is reproduced below using the functional API.\r\n\r\n```python\r\nfrom papyrus_scripts import (read_papyrus, read_protein_set,\r\n keep_quality, keep_source, keep_type,\r\n keep_organism, keep_accession, keep_protein_class,\r\n keep_match, keep_contains,\r\n consume_chunks)\r\n\r\nchunk_reader = read_papyrus(version='05.7', plusplus=True, is3d=False, chunksize=1_000_000)\r\nprotein_data = read_protein_set(version='05.7')\r\nfilter1 = keep_source(data=chunk_reader, source=['chembl', 'sharma'])\r\nfilter2 = keep_quality(data=filter1, min_quality='high')\r\ndata = consume_chunks(filter2, progress=False)\r\n\r\nprotein_data = protein_data.set_index('target_id').loc[data.target_id.unique()].reset_index()\r\n```\r\n\r\n## Versions of the Papyrus dataset\r\n\r\nDifferent online servers host the Papyrus data based on release and ChEMBL version (table below).\r\n\r\n \r\n| Papyrus version | ChEMBL version | Zenodo | 4TU |\r\n|:---------------:|:--------------:|:---------------------------------------------------------:|:---------------------------------------------------------:|\r\n| 05.4 | 29 | [:heavy_check_mark:](https://zenodo.org/records/10944245) | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) | \r\n| 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/records/10943207) | :x: |\r\n| 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/records/7821775) | :x: |\r\n| 05.7 | 34 | [:heavy_check_mark:](https://zenodo.org/records/13787634) | :x: |\r\n\r\nPrecomputed molecular and protein descriptors along with molecular structures (2D for default set and 3D for low quality set with stereochemistry) are not available for version 05.4 from 4TU but are from Google Drive.\r\n\r\nAs stated in the pre-print **we strongly encourage** the use of the dataset in which stereochemistry was not considered.\r\nThis corresponds to files containing the mention \"2D\" and/or \"without_stereochemistry\". \r\n\r\n## Interconversion of the compressed files\r\n\r\nThe available LZMA-compressed files (*.xz*) may not be supported by some software (e.g. Pipeline Pilot).\r\n<br/>**Decompressing the data is strongly discouraged!**<br/>\r\nThough Gzip files were made available at 4TU for version 05.4, we now provide a CLI option to locally interconvert from LZMA to Gzip and vice-versa.\r\n\r\nTo convert from LZMA to Gzip (or vice-versa) use the following command:\r\n```bash\r\npapyrus convert -v latest \r\n```\r\n\r\n## Removal of the data\r\n\r\nOne can remove the Papyrus data using either the CLI or the API.\r\n\r\nThe following exerts exemplify the removal of all Papyrus data files, including all versions utility files. \r\n```bash\r\npapyrus clean --remove_root\r\n```\r\n\r\n```python\r\nfrom papyrus_scripts import remove_papyrus\r\n\r\nremove_papyrus(papyrus_root=True)\r\n```\r\n\r\n\r\n## Easy handling of the dataset\r\n\r\nOnce installed the Papyrus-scripts allow for the easy filtering of the data.<br/>\r\n- Simple examples can be found in the <a href=\"https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/simple_examples.ipynb\">simple_examples.ipynb</a> notebook. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/simple_examples.ipynb)\r\n- An example on matching data with the Protein Data Bank can be found in the <a href=\"https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/matchRCSB.ipynb\">simple_examples.ipynb</a> notebook. [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/matchRCSB.ipynb)\r\n- More advanced examples will be added to the <a href=\"https://github.com/OlivierBeq/Papyrus-scripts/blob/master/notebook_examples/advanced_querying.ipynb\">advanced_querying.ipynb</a> notebook.\r\n## Reproducing results of the pre-print\r\n\r\nThe scripts used to extract subsets, generate models and obtain visualizations can be found <a href=\"https://github.com/OlivierBeq/Papyrus-modelling\">here</a>.\r\n\r\n## Features to come\r\n\r\n- [x] Substructure and similarity molecular searches\r\n- [x] ability to use DNN models\r\n- [x] ability to repeat model training over multiple seeds\r\n- [x] y-scrambling\r\n- [ ] adapt models to QSPRpred\r\n \r\n## Examples to come\r\n\r\n- Use of custom grouping schemes for training/test set splitting and cross-validation\r\n- Use custom molecular and protein descriptors (either Python function or file on disk) \r\n\r\n\r\n## Logos\r\n\r\nLogos can be found under <a href=\"https://github.com/OlivierBeq/Papyrus-scripts/tree/master/figures/logo\">**figures/logo**</a>\r\nTwo version exist depending on the background used.\r\n\r\n:warning: GitHub does not render the white logo properly in the table below but should not deter you from using it! \r\n\r\n<div class=\"colored-table\">\r\n\r\n| On white background | On colored background |\r\n|:--------------------------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------------------------------------------------------------------:|\r\n| <img src=\"https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/logo/Papyrus_trnsp-bg.svg\" width=200> | <img src=\"https://raw.githubusercontent.com/OlivierBeq/Papyrus-scripts/refs/heads/master/figures/logo/Papyrus_trnsp-bg-white.svg\" width=200> |\r\n\r\n</div>\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A collection of scripts to handle the Papyrus bioactivity dataset",
"version": "2.1.1",
"project_urls": {
"Homepage": "https://github.com/OlivierBeq/Papyrus-scripts"
},
"split_keywords": [
"bioactivity data",
" qsar",
" proteochemometrics",
" cheminformatics",
" modelling",
" machine learning"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5f64e4f6cfa478c47ad5556dd73cc3b0f410517711071ff29107907013a6ba3e",
"md5": "d7112cc31b170e59fa00c21625cf5252",
"sha256": "7e9a67bc59ed29f82d34d7c1619978e40573c8d7df176fd86403b7b9a1cfecf1"
},
"downloads": -1,
"filename": "papyrus_scripts-2.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d7112cc31b170e59fa00c21625cf5252",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 86269,
"upload_time": "2024-11-04T18:42:35",
"upload_time_iso_8601": "2024-11-04T18:42:35.464716Z",
"url": "https://files.pythonhosted.org/packages/5f/64/e4f6cfa478c47ad5556dd73cc3b0f410517711071ff29107907013a6ba3e/papyrus_scripts-2.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1e517384b55851506dee3ef93465a5e7150b29ec51102cdf997ea3c711217764",
"md5": "8efdb630765e70cc1dd80795d2a73839",
"sha256": "0b03d1602534559dfe986e3a70f9b9010952c6c116b84f2de9378c8f34765df2"
},
"downloads": -1,
"filename": "papyrus_scripts-2.1.1.tar.gz",
"has_sig": false,
"md5_digest": "8efdb630765e70cc1dd80795d2a73839",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 82962,
"upload_time": "2024-11-04T18:42:36",
"upload_time_iso_8601": "2024-11-04T18:42:36.952195Z",
"url": "https://files.pythonhosted.org/packages/1e/51/7384b55851506dee3ef93465a5e7150b29ec51102cdf997ea3c711217764/papyrus_scripts-2.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-04 18:42:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "OlivierBeq",
"github_project": "Papyrus-scripts",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "papyrus-scripts"
}