papyrus-scripts 1.0.1__tar.gz → 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/PKG-INFO +23 -15
  2. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/README.md +22 -14
  3. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/__init__.py +1 -1
  4. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/cli.py +22 -11
  5. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/download.py +23 -13
  6. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/fingerprint.py +14 -9
  7. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/matchRCSB.py +3 -1
  8. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/modelling.py +163 -92
  9. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/neuralnet.py +17 -16
  10. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/preprocess.py +29 -19
  11. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/reader.py +5 -3
  12. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/utils/IO.py +53 -48
  13. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/utils/UniprotMatch.py +1 -0
  14. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/utils/mol_reader.py +1 -1
  15. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/PKG-INFO +23 -15
  16. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/SOURCES.txt +0 -1
  17. papyrus_scripts-1.0.1/src/papyrus_scripts/version.py +0 -5
  18. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/LICENSE +0 -0
  19. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/setup.cfg +0 -0
  20. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/setup.py +0 -0
  21. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/__main__.py +0 -0
  22. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/subsim_search.py +0 -0
  23. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/utils/__init__.py +0 -0
  24. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts/utils/links.json +0 -0
  25. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/dependency_links.txt +0 -0
  26. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/entry_points.txt +0 -0
  27. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/requires.txt +0 -0
  28. {papyrus_scripts-1.0.1 → papyrus_scripts-1.0.3}/src/papyrus_scripts.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: papyrus_scripts
3
- Version: 1.0.1
3
+ Version: 1.0.3
4
4
  Summary: A collection of scripts to handle the Papyrus bioactivity dataset
5
5
  Home-page: https://github.com/OlivierBeq/Papyrus-scripts
6
6
  Author: Olivier J. M. Béquignon - Brandon J. Bongers - Willem Jespers
@@ -28,6 +28,13 @@ Collection of scripts to interact with the Papyrus bioactivity dataset.
28
28
 
29
29
  <br/>
30
30
 
31
+ **Associated Article:** <a href="https://doi.org/10.1186/s13321-022-00672-x">10.1186/s13321-022-00672-x</a>
32
+ ```
33
+ Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
34
+ Papyrus - A large scale curated dataset aimed at bioactivity predictions.
35
+ J Cheminform 15, 3 (2023). https://doi.org/10.1186/s13321-022-00672-x
36
+ ```
37
+
31
38
  **Associated Preprint:** <a href="https://doi.org/10.33774/chemrxiv-2021-1rxhk">10.33774/chemrxiv-2021-1rxhk</a>
32
39
  ```
33
40
  Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
@@ -55,7 +62,7 @@ python -m pip install papyrus-scripts
55
62
  Additional dependencies can be installed to allow:
56
63
  - similarity and substructure searches
57
64
  ```bash
58
- conda install FPSim2 openbabel "h5py<3.2" cupy
65
+ conda install FPSim2 openbabel h5py cupy -c conda-forge
59
66
  ```
60
67
 
61
68
  - training DNN models:
@@ -111,18 +118,18 @@ download_papyrus(version='latest', only_pp=False, structures=True, descriptors='
111
118
  Different online servers host the Papyrus data based on release and ChEMBL version (table below).
112
119
 
113
120
 
114
- | Papyrus version | ChEMBL version | Zenodo | 4TU | Google Drive |
115
- |:---------------:|:--------------:|:--------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:|
116
- | 05.4 | 29 | :x: | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) | [:heavy_check_mark:](https://drive.google.com/drive/folders/1Lhw5G6gu_nLzHQoGmnl02uhFsmOgEZ5a?usp=sharing) |
117
- | 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/record/7019874#.Y2lECL3MKUk) | :x: | [:heavy_check_mark:](https://drive.google.com/drive/folders/1BrCx0lN1YVvjgXOOaJZHJ7DBrLqFAbWV?usp=sharing) |
118
- | 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/record/7377161#.Y5BvrHbMKUk) | :x: | :x: |
121
+ | Papyrus version | ChEMBL version | Zenodo | 4TU | Google Drive |
122
+ |:---------------:|:--------------:|:--------------------------------------------------------------------:|:---------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:|
123
+ | 05.4 | 29 | :x: | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) | [:heavy_check_mark:](https://drive.google.com/drive/folders/1Lhw5G6gu_nLzHQoGmnl02uhFsmOgEZ5a?usp=sharing) |
124
+ | 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/record/7019874#.Y2lECL3MKUk) | :x: | [:heavy_check_mark:](https://drive.google.com/drive/folders/1BrCx0lN1YVvjgXOOaJZHJ7DBrLqFAbWV?usp=sharing) |
125
+ | 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/record/7377161#.Y5BvrHbMKUk) | :x: | :x: |
119
126
 
120
127
  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.
121
128
 
122
129
  As stated in the pre-print **we strongly encourage** the use of the dataset in which stereochemistry was not considered.
123
130
  This corresponds to files containing the mention "2D" and/or "without_stereochemistry".
124
131
 
125
- ## Inter-conversion of the compressed files
132
+ ## Interconversion of the compressed files
126
133
 
127
134
  The available LZMA-compressed files (*.xz*) may not be supported by some software (e.g. Pipeline Pilot).
128
135
  <br/>**Decompressing the data is strongly discouraged!**<br/>
@@ -161,10 +168,11 @@ The scripts used to extract subsets, generate models and obtain visualizations c
161
168
 
162
169
  ## Features to come
163
170
 
164
- - ~~Substructure and similarity molecular searches~~
165
- - ~~ability to use DNN models~~
166
- - ~~ability to repeat model training over multiple seeds~~
167
- - y-scrambling
171
+ - [x] Substructure and similarity molecular searches
172
+ - [x] ability to use DNN models
173
+ - [x] ability to repeat model training over multiple seeds
174
+ - [x] y-scrambling
175
+ - [ ] adapt models to QSPRpred
168
176
 
169
177
  ## Examples to come
170
178
 
@@ -181,9 +189,9 @@ Two version exist depending on the background used.
181
189
 
182
190
  <div class="colored-table">
183
191
 
184
- | On white background | On colored background |
185
- |:---------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:|
186
- | <img src="figures/logo/Papyrus_trnsp-bg.svg" width=200> | <img src="figures/logo/Papyrus_trnsp-bg-white.svg" width=200> |
192
+ | On white background | On colored background |
193
+ |:---------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------:|
194
+ | <img src="figures/logo/Papyrus_trnsp-bg.svg" width=200> | <img src="figures/logo/Papyrus_trnsp-bg-white.svg" width=200> |
187
195
 
188
196
  </div>
189
197
 
@@ -6,6 +6,13 @@ Collection of scripts to interact with the Papyrus bioactivity dataset.
6
6
 
7
7
  <br/>
8
8
 
9
+ **Associated Article:** <a href="https://doi.org/10.1186/s13321-022-00672-x">10.1186/s13321-022-00672-x</a>
10
+ ```
11
+ Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
12
+ Papyrus - A large scale curated dataset aimed at bioactivity predictions.
13
+ J Cheminform 15, 3 (2023). https://doi.org/10.1186/s13321-022-00672-x
14
+ ```
15
+
9
16
  **Associated Preprint:** <a href="https://doi.org/10.33774/chemrxiv-2021-1rxhk">10.33774/chemrxiv-2021-1rxhk</a>
10
17
  ```
11
18
  Béquignon OJM, Bongers BJ, Jespers W, IJzerman AP, van de Water B, van Westen GJP.
@@ -33,7 +40,7 @@ python -m pip install papyrus-scripts
33
40
  Additional dependencies can be installed to allow:
34
41
  - similarity and substructure searches
35
42
  ```bash
36
- conda install FPSim2 openbabel "h5py<3.2" cupy
43
+ conda install FPSim2 openbabel h5py cupy -c conda-forge
37
44
  ```
38
45
 
39
46
  - training DNN models:
@@ -89,18 +96,18 @@ download_papyrus(version='latest', only_pp=False, structures=True, descriptors='
89
96
  Different online servers host the Papyrus data based on release and ChEMBL version (table below).
90
97
 
91
98
 
92
- | Papyrus version | ChEMBL version | Zenodo | 4TU | Google Drive |
93
- |:---------------:|:--------------:|:--------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:|
94
- | 05.4 | 29 | :x: | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) | [:heavy_check_mark:](https://drive.google.com/drive/folders/1Lhw5G6gu_nLzHQoGmnl02uhFsmOgEZ5a?usp=sharing) |
95
- | 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/record/7019874#.Y2lECL3MKUk) | :x: | [:heavy_check_mark:](https://drive.google.com/drive/folders/1BrCx0lN1YVvjgXOOaJZHJ7DBrLqFAbWV?usp=sharing) |
96
- | 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/record/7377161#.Y5BvrHbMKUk) | :x: | :x: |
99
+ | Papyrus version | ChEMBL version | Zenodo | 4TU | Google Drive |
100
+ |:---------------:|:--------------:|:--------------------------------------------------------------------:|:---------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------:|
101
+ | 05.4 | 29 | :x: | [:heavy_check_mark:](https://doi.org/10.4121/16896406.v2) | [:heavy_check_mark:](https://drive.google.com/drive/folders/1Lhw5G6gu_nLzHQoGmnl02uhFsmOgEZ5a?usp=sharing) |
102
+ | 05.5 | 30 | [:heavy_check_mark:](https://zenodo.org/record/7019874#.Y2lECL3MKUk) | :x: | [:heavy_check_mark:](https://drive.google.com/drive/folders/1BrCx0lN1YVvjgXOOaJZHJ7DBrLqFAbWV?usp=sharing) |
103
+ | 05.6 | 31 | [:heavy_check_mark:](https://zenodo.org/record/7377161#.Y5BvrHbMKUk) | :x: | :x: |
97
104
 
98
105
  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.
99
106
 
100
107
  As stated in the pre-print **we strongly encourage** the use of the dataset in which stereochemistry was not considered.
101
108
  This corresponds to files containing the mention "2D" and/or "without_stereochemistry".
102
109
 
103
- ## Inter-conversion of the compressed files
110
+ ## Interconversion of the compressed files
104
111
 
105
112
  The available LZMA-compressed files (*.xz*) may not be supported by some software (e.g. Pipeline Pilot).
106
113
  <br/>**Decompressing the data is strongly discouraged!**<br/>
@@ -139,10 +146,11 @@ The scripts used to extract subsets, generate models and obtain visualizations c
139
146
 
140
147
  ## Features to come
141
148
 
142
- - ~~Substructure and similarity molecular searches~~
143
- - ~~ability to use DNN models~~
144
- - ~~ability to repeat model training over multiple seeds~~
145
- - y-scrambling
149
+ - [x] Substructure and similarity molecular searches
150
+ - [x] ability to use DNN models
151
+ - [x] ability to repeat model training over multiple seeds
152
+ - [x] y-scrambling
153
+ - [ ] adapt models to QSPRpred
146
154
 
147
155
  ## Examples to come
148
156
 
@@ -159,9 +167,9 @@ Two version exist depending on the background used.
159
167
 
160
168
  <div class="colored-table">
161
169
 
162
- | On white background | On colored background |
163
- |:---------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------:|
164
- | <img src="figures/logo/Papyrus_trnsp-bg.svg" width=200> | <img src="figures/logo/Papyrus_trnsp-bg-white.svg" width=200> |
170
+ | On white background | On colored background |
171
+ |:---------------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------:|
172
+ | <img src="figures/logo/Papyrus_trnsp-bg.svg" width=200> | <img src="figures/logo/Papyrus_trnsp-bg-white.svg" width=200> |
165
173
 
166
174
  </div>
167
175
 
@@ -16,4 +16,4 @@ from .modelling import qsar, pcm
16
16
  from .utils.mol_reader import MolSupplier
17
17
  from .utils import IO, UniprotMatch
18
18
 
19
- __version__ = '1.0.1'
19
+ __version__ = '1.0.3'
@@ -1,8 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ """Command line interface of the Papyrus-scripts"""
4
+
3
5
  import sys
4
6
  import os
5
7
  import inspect
8
+ from collections import defaultdict
6
9
 
7
10
  import click
8
11
  import pystow
@@ -20,6 +23,7 @@ CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])
20
23
 
21
24
  @click.group(context_settings=CONTEXT_SETTINGS)
22
25
  def main():
26
+ """Group allowing subcommands to be defined"""
23
27
  pass
24
28
 
25
29
 
@@ -58,6 +62,7 @@ def main():
58
62
  show_default=True, help='Force download if disk space is low'
59
63
  '(default: False for 10% disk space margin).')
60
64
  def download(output_directory, version, more, stereo, structs, descs, force):
65
+ """CLI to download the Papyrus datas."""
61
66
  if isinstance(version, tuple):
62
67
  version = list(version)
63
68
  if isinstance(descs, tuple):
@@ -92,8 +97,8 @@ def download(output_directory, version, more, stereo, structs, descs, force):
92
97
  show_default=True, help='Should bioactivities be removed (TSV file).')
93
98
  @click.option('-S', '--structures', 'structs', is_flag=True, required=False, default=False, nargs=1,
94
99
  show_default=True, help='Should structures be removed (SD file).')
95
- @click.option('-d', '--descriptors', 'descs', type=click.Choice(['mold2', 'cddd', 'mordred', 'fingerprint',
96
- 'unirep', 'prodec', 'all', 'none']),
100
+ @click.option('-d', '--descriptors', 'descs',
101
+ type=click.Choice(['mold2', 'cddd', 'mordred', 'fingerprint', 'unirep', 'prodec', 'all', 'none']),
97
102
  required=False, default=['none'], nargs=1,
98
103
  show_default=True, multiple=True,
99
104
  help=('Type of descriptors to be removed: mold2 (777 2D Mold2 descriptors), '
@@ -116,6 +121,7 @@ def download(output_directory, version, more, stereo, structs, descs, force):
116
121
  show_default=True, help='Skip confirmation when removing the root directory.')
117
122
  def clean(output_directory, version, papyruspp, stereo, bioactivities, proteins,structs,
118
123
  descs, other_files, remove_version, remove_root, force):
124
+ """CLI to remove the Papyrus data."""
119
125
  if isinstance(version, tuple):
120
126
  version = list(version)
121
127
  if isinstance(descs, tuple):
@@ -234,6 +240,7 @@ class Mutex(click.Option):
234
240
  @click.option('--fhelp', 'fingerprint_help', is_flag=True, default=False, required=False,
235
241
  help='Show advanced help about fingerprints.')
236
242
  def fpsubsim2(indir, output, version, is3D, fingerprint, verbose, njobs, fingerprint_help):
243
+ """CLI to create a database for similarity and substructure searches."""
237
244
  # Switch to advanced fingerprint help
238
245
  if fingerprint_help:
239
246
  fp_name_list = [] # Names of avaliable fingerprints
@@ -242,12 +249,15 @@ def fpsubsim2(indir, output, version, is3D, fingerprint, verbose, njobs, fingerp
242
249
  for fp_type in Fingerprint.derived():
243
250
  fp_name = fp_type().name # Obtain fp name
244
251
  # Obtain argument names and default values
245
- fp_params = [(key, value._default) for key, value in inspect.signature(fp_type.__init__).parameters.items() if key != 'self']
252
+ fp_params = [(key, value._default)
253
+ for key, value in inspect.signature(fp_type.__init__).parameters.items()
254
+ if key != 'self']
246
255
  # Format fp names and arguments
247
256
  fp_name_list.append(f" {fp_name}")
248
257
  if len(fp_params): # Fp has arguments
249
258
  fp_parameter_list.append(f" {fp_name}")
250
- fp_parameter_list.extend(f" {param_name} = {default_value}" for param_name, default_value in fp_params)
259
+ fp_parameter_list.extend(f" {param_name} = {default_value}"
260
+ for param_name, default_value in fp_params)
251
261
  else: # Fp has no argument
252
262
  fp_no_parameter_list.append(f" {fp_name}")
253
263
  # Format the entire lists
@@ -310,13 +320,13 @@ Fingerprint:
310
320
  # Convert type of parameter values
311
321
  try:
312
322
  fp_param[param_name] = eval(param_value)
313
- except:
323
+ except Exception as e:
314
324
  print(f'Parameters were wrongly formatted: {param_value}')
315
325
  sys.exit()
316
326
  fingerprints.append(get_fp_from_name(fp_name, **fp_param))
317
327
  for version_ in version:
318
- fpss.create_from_papyrus(is3d=is3D, version=version_, outfile=output, fingerprint=fingerprints, root_folder=indir,
319
- progress=verbose, njobs=njobs)
328
+ fpss.create_from_papyrus(is3d=is3D, version=version_, outfile=output, fingerprint=fingerprints,
329
+ root_folder=indir, progress=verbose, njobs=njobs)
320
330
 
321
331
 
322
332
  @main.command(help='Transform the compression of Papyrus files from LZMA to Gzip and vice-versa.',
@@ -328,21 +338,22 @@ Fingerprint:
328
338
  metavar='XX.X', help='Version of the Papyrus data to be transformed (default: latest).')
329
339
  @click.option('-f', '--format', 'format', type=click.Choice(['xz', 'gzip']),
330
340
  required=False, default=None, nargs=1, show_default=True, multiple=False,
331
- help=('Compression type to transform the data to. Is inferred if not specified.'))
341
+ help='Compression type to transform the data to. Is inferred if not specified.')
332
342
  @click.option('-l', '--level', 'level', type=click.IntRange(0, 9),
333
343
  required=False, default=None, nargs=1, show_default=True, multiple=False,
334
- help=('Compression level of output files.'))
344
+ help='Compression level of output files.')
335
345
  @click.option('-e', '--extreme', 'extreme', is_flag=True, required=False, default=False, nargs=1,
336
346
  show_default=True, help='Should extreme compression be toggled on.')
337
347
  def convert(indir, version, format, level, extreme):
348
+ """CLI to interconvert Papyrus data from/to GZIP from/to XZ."""
338
349
  if isinstance(version, tuple):
339
350
  version = list(version)
340
351
  if indir is None:
341
352
  indir = str(pystow.utils.get_base(''))
342
353
  version = process_data_version(version, indir)
343
354
  if format is None:
344
- # Infer from the most abundant file type
345
- formats = {'xz': [], 'gzip': []}
355
+ format = defaultdict(list)
356
+ # Infer from name
346
357
  for root, _, files in os.walk(os.path.join(indir, 'papyrus', version)):
347
358
  for name in files:
348
359
  if name.lower().endswith('xz'):
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ """Download utilities of the Papyrus scripts."""
4
+
3
5
  import os
4
6
  import zipfile
5
7
  import shutil
@@ -9,14 +11,15 @@ import requests
9
11
  import pystow
10
12
  from tqdm.auto import tqdm
11
13
 
12
- from .utils.IO import get_disk_space, enough_disk_space, assert_sha256sum, read_jsonfile, write_jsonfile, get_papyrus_links
14
+ from .utils.IO import (get_disk_space, enough_disk_space, assert_sha256sum,
15
+ read_jsonfile, write_jsonfile, get_papyrus_links)
13
16
 
14
17
 
15
18
  def download_papyrus(outdir: Optional[str] = None,
16
19
  version: Union[str, List[str]] = 'latest',
17
20
  nostereo: bool = True,
18
21
  stereo: bool = False,
19
- only_pp: bool =True,
22
+ only_pp: bool = True,
20
23
  structures: bool = False,
21
24
  descriptors: Optional[Union[str, List[str]]] = 'all',
22
25
  progress: bool = True,
@@ -50,7 +53,7 @@ def download_papyrus(outdir: Optional[str] = None,
50
53
  version = latest_version
51
54
  if progress:
52
55
  print(f'Latest version: {version}')
53
- elif (isinstance(version, list) and 'latest' in version):
56
+ elif isinstance(version, list) and 'latest' in version:
54
57
  for i in range(len(version)):
55
58
  if version[i] == 'latest':
56
59
  version[i] = latest_version
@@ -79,9 +82,11 @@ def download_papyrus(outdir: Optional[str] = None,
79
82
  downloads.add('2D_papyrus')
80
83
  elif progress:
81
84
  # Ensure this warning is printed when donwloading the Papyrus++ dataset with progress on
82
- print('You are downloading the high-quality Papyrus++ dataset.\n'
85
+ print('########## DISCLAIMER ##########\n'
86
+ 'You are downloading the high-quality Papyrus++ dataset.\n'
83
87
  'Should you want to access the entire, though of lower quality, Papyrus dataset,\n'
84
- 'look into additional switches of this command.')
88
+ 'look into additional switches of this command.\n'
89
+ '################################')
85
90
  if structures:
86
91
  downloads.add('2D_structures')
87
92
  if 'mold2' in descriptors or 'all' in descriptors:
@@ -115,19 +120,23 @@ def download_papyrus(outdir: Optional[str] = None,
115
120
  for subfile in files[_version][ftype]:
116
121
  total += subfile['size']
117
122
  else:
118
- raise ValueError(f'Papyrus versioning file corrupted: {files[_version][ftype]} '
123
+ raise ValueError('########## ERROR ##########\n'
124
+ f'Papyrus versioning file corrupted: {files[_version][ftype]} '
119
125
  'is neither a dict or a list.\nThis is most likely due to bad formatting '
120
126
  'of the underlying parsed JSON files. If you are not the maintainer, please '
121
127
  'remove the Papyrus data and enforce root folder removal and download '
122
- 'the data before trying again.')
128
+ 'the data before trying again.\n'
129
+ '################################')
123
130
  if progress:
124
131
  print(f'Number of files to be downloaded: {len(downloads)}\n'
125
132
  f'Total size: {tqdm.format_sizeof(total)}B')
126
133
  # Verify enough disk space
127
134
  if not enough_disk_space(papyrus_version_root.base.as_posix(), total, disk_margin):
128
- print(f'Not enough disk space ({disk_margin:.0%} kept for safety)\n'
135
+ print('########## ERROR ##########\n'
136
+ f'Not enough disk space ({disk_margin:.0%} kept for safety)\n'
129
137
  f'Available: {tqdm.format_sizeof(get_disk_space(papyrus_version_root.base.as_posix()))}B\n'
130
- f'Required: {tqdm.format_sizeof(total)}B')
138
+ f'Required: {tqdm.format_sizeof(total)}B\n'
139
+ '################################')
131
140
  return
132
141
  # Download files
133
142
  if progress:
@@ -144,7 +153,8 @@ def download_papyrus(outdir: Optional[str] = None,
144
153
  for subfile in download:
145
154
  dname, durl, dsize, dhash = subfile['name'], subfile['url'], subfile['size'], subfile['sha256']
146
155
  # Determine path
147
- if ftype in ['papyrus++', '2D_papyrus', '3D_papyrus', 'proteins', 'data_types', 'data_size', 'readme', 'license', 'requirements']:
156
+ if ftype in ['papyrus++', '2D_papyrus', '3D_papyrus', 'proteins', 'data_types', 'data_size',
157
+ 'readme', 'license', 'requirements']:
148
158
  fpath = papyrus_version_root.join(name=dname).as_posix()
149
159
  elif ftype in ['2D_structures', '3D_structures']:
150
160
  fpath = papyrus_version_root.join('structures', name=dname).as_posix()
@@ -154,7 +164,7 @@ def download_papyrus(outdir: Optional[str] = None,
154
164
  if os.path.isfile(fpath) and assert_sha256sum(fpath, dhash):
155
165
  if progress:
156
166
  pbar.update(dsize)
157
- continue # skip
167
+ continue # skip
158
168
  # Download file
159
169
  correct = False # ensure file is not corrupted
160
170
  retries = RETRIES
@@ -249,7 +259,7 @@ def remove_papyrus(outdir: Optional[str] = None,
249
259
  version = latest_version
250
260
  if progress:
251
261
  print(f'Latest version: {version}')
252
- elif (isinstance(version, list) and 'latest' in version):
262
+ elif isinstance(version, list) and 'latest' in version:
253
263
  for i in range(len(version)):
254
264
  if version[i] == 'latest':
255
265
  version[i] = latest_version
@@ -350,7 +360,7 @@ def remove_papyrus(outdir: Optional[str] = None,
350
360
  os.remove('data_size.json')
351
361
  os.remove('LICENSE.txt')
352
362
  # Handle other files
353
- if os.path.isfile(fpath): # file exists
363
+ if os.path.isfile(fpath): # file exists
354
364
  total += dsize # add size to be removed
355
365
  else: # file does not exist
356
366
  del removal[i]
@@ -40,7 +40,11 @@ class Fingerprint(ABC):
40
40
  self.length = 307
41
41
  if not self.length:
42
42
  raise Exception("fingerprint size is not specified")
43
- self._hash = f'{hex(abs(np.sum(np.frombuffer(hashlib.sha256((self.name + json.dumps(self.params, sort_keys=True)).encode()).digest(), dtype=np.int64))) % 65537)}'
43
+ self._hash = self.name + json.dumps(self.params, sort_keys=True)
44
+ self._hash = hashlib.sha256((self._hash).encode()).digest()
45
+ self._hash = np.frombuffer(self._hash, dtype=np.int64)
46
+ self._hash = abs(np.sum(self._hash)) % 65537
47
+ self._hash = f'{hex(self._hash)}'
44
48
 
45
49
  def __repr__(self):
46
50
  return f'{self.name}_{self.length}bits_{self._hash}'
@@ -105,14 +109,15 @@ class MorganFingerprint(RDKitFingerprint):
105
109
  class TopologicalTorsionFingerprint(RDKitFingerprint):
106
110
  def __init__(self, nBits: int = 2048, targetSize: int = 4, fromAtoms: List = 0,
107
111
  ignoreAtoms: List = 0, atomInvariants: List = 0, includeChirality: bool = False):
108
- super(TopologicalTorsionFingerprint, self).__init__('TopologicalTorsion',
109
- {"nBits": nBits,
110
- "targetSize": targetSize,
111
- "fromAtoms": fromAtoms,
112
- "ignoreAtoms": ignoreAtoms,
113
- "atomInvariants": atomInvariants,
114
- "includeChirality": includeChirality, },
115
- rdMolDescriptors.GetHashedTopologicalTorsionFingerprintAsBitVect)
112
+ super(TopologicalTorsionFingerprint, self
113
+ ).__init__('TopologicalTorsion',
114
+ {"nBits": nBits,
115
+ "targetSize": targetSize,
116
+ "fromAtoms": fromAtoms,
117
+ "ignoreAtoms": ignoreAtoms,
118
+ "atomInvariants": atomInvariants,
119
+ "includeChirality": includeChirality, },
120
+ rdMolDescriptors.GetHashedTopologicalTorsionFingerprintAsBitVect)
116
121
 
117
122
 
118
123
  class AtomPairFingerprint(RDKitFingerprint):
@@ -1,5 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ """Match data of the Papyrus dataset with that of the Protein Data Bank."""
4
+
3
5
  import os
4
6
  import time
5
7
  from typing import Iterator, Generator, Optional, Union
@@ -18,7 +20,7 @@ from .utils import UniprotMatch
18
20
  def update_rcsb_data(root_folder: Optional[str] = None,
19
21
  overwrite: bool = False,
20
22
  verbose: bool = True
21
- ) -> pd.DataFrame:
23
+ ) -> pd.DataFrame:
22
24
  """Update the local data of the RCSB.
23
25
 
24
26
  :param root_folder: Directory where Papyrus bioactivity data is stored (default: pystow's home folder)