decimer 2.2.2__tar.gz → 2.3.0__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.
- decimer-2.3.0/.github/ISSUE_TEMPLATE/Bug_Report.yml +113 -0
- decimer-2.3.0/.github/workflows/Check_errors.yml +37 -0
- decimer-2.3.0/.gitignore +132 -0
- decimer-2.3.0/.readthedocs.yml +19 -0
- decimer-2.3.0/Benchmark/README.md +32 -0
- decimer-2.3.0/Benchmark/TEST.txt +3 -0
- decimer-2.3.0/Benchmark/distort_images.py +64 -0
- decimer-2.3.0/Benchmark/evaluate_benchmarks.py +90 -0
- decimer-2.3.0/Benchmark/run_decimer_save_results.py +33 -0
- decimer-2.3.0/Benchmark/test_images/DECIMER_test_0.png +0 -0
- decimer-2.3.0/Benchmark/test_images/DECIMER_test_1.png +0 -0
- decimer-2.3.0/Benchmark/test_images/github_issue_test.png +0 -0
- decimer-2.3.0/CITATION.cff +18 -0
- decimer-2.3.0/CODE_OF_CONDUCT.md +128 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Repack_model.py +15 -4
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/__init__.py +2 -2
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/config.py +55 -56
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/decimer.py +2 -2
- decimer-2.3.0/DECIMER_V2.png +0 -0
- decimer-2.3.0/ISSUES.md +16 -0
- {decimer-2.2.2/decimer.egg-info → decimer-2.3.0}/PKG-INFO +7 -4
- decimer-2.3.0/Python_Requirements.txt +5 -0
- decimer-2.3.0/Tests/caffeine.png +0 -0
- {decimer-2.2.2/tests → decimer-2.3.0/Tests}/test_functions.py +1 -1
- {decimer-2.2.2 → decimer-2.3.0/decimer.egg-info}/PKG-INFO +7 -4
- {decimer-2.2.2 → decimer-2.3.0}/decimer.egg-info/SOURCES.txt +28 -1
- {decimer-2.2.2 → decimer-2.3.0}/decimer.egg-info/requires.txt +1 -1
- decimer-2.3.0/docs/DECIMER.rst +29 -0
- decimer-2.3.0/docs/Makefile +20 -0
- decimer-2.3.0/docs/_static/DECIMER.gif +0 -0
- decimer-2.3.0/docs/conf.py +90 -0
- decimer-2.3.0/docs/index.rst +38 -0
- decimer-2.3.0/docs/make.bat +35 -0
- decimer-2.3.0/docs/modules.rst +7 -0
- decimer-2.3.0/docs/requirements.txt +9 -0
- {decimer-2.2.2 → decimer-2.3.0}/setup.py +13 -5
- decimer-2.3.0/tox.ini +46 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/DECIMER_EfficinetNetV2_Transfomer_Trainer.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Efficient_Net_encoder.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Predictor_EfficientNet2.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Transformer_decoder.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Utils/Create_TFrecord_From_pickles.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/Utils/Create_image_tokenizer.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/efficientnetv2/effnetv2_configs.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/efficientnetv2/effnetv2_model.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/efficientnetv2/hparams.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/efficientnetv2/utils.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/DECIMER/utils.py +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/LICENSE +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/README.md +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/decimer.egg-info/dependency_links.txt +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/decimer.egg-info/top_level.txt +0 -0
- {decimer-2.2.2 → decimer-2.3.0}/setup.cfg +0 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
name: DECIMER issue template
|
|
2
|
+
description: >-
|
|
3
|
+
To report any DECIMER Image Transformer related issue please use this
|
|
4
|
+
template. Please report data/security related issue by directly sending us an
|
|
5
|
+
email.
|
|
6
|
+
body:
|
|
7
|
+
- type: markdown
|
|
8
|
+
attributes:
|
|
9
|
+
value: |
|
|
10
|
+
Thanks for taking the time to fill out this bug report!
|
|
11
|
+
- type: markdown
|
|
12
|
+
attributes:
|
|
13
|
+
value: >
|
|
14
|
+
Please make sure that this is a bug. As per our [GitHub
|
|
15
|
+
Policy](https://github.com/Kohulan/DECIMER-Image_Transformer/blob/master/ISSUES.md).
|
|
16
|
+
- type: dropdown
|
|
17
|
+
id: issue-type
|
|
18
|
+
attributes:
|
|
19
|
+
label: Issue Type
|
|
20
|
+
description: What type of issue would you like to report?
|
|
21
|
+
multiple: false
|
|
22
|
+
options:
|
|
23
|
+
- Bug
|
|
24
|
+
- Build/Install
|
|
25
|
+
- Performance
|
|
26
|
+
- Support
|
|
27
|
+
- Feature Request
|
|
28
|
+
- Documentation Feature Request
|
|
29
|
+
- Questions
|
|
30
|
+
validations:
|
|
31
|
+
required: true
|
|
32
|
+
- type: dropdown
|
|
33
|
+
id: source
|
|
34
|
+
attributes:
|
|
35
|
+
label: Source
|
|
36
|
+
description: DECIMER Image Transformer installed from
|
|
37
|
+
options:
|
|
38
|
+
- GitHub (source)
|
|
39
|
+
- PyPi
|
|
40
|
+
validations:
|
|
41
|
+
required: true
|
|
42
|
+
- type: input
|
|
43
|
+
id: decimerversion
|
|
44
|
+
attributes:
|
|
45
|
+
label: DECIMER Image Transformer Version
|
|
46
|
+
description: null
|
|
47
|
+
placeholder: 'ex,. 2.0.0'
|
|
48
|
+
validations:
|
|
49
|
+
required: true
|
|
50
|
+
- type: input
|
|
51
|
+
id: OS
|
|
52
|
+
attributes:
|
|
53
|
+
label: OS Platform and Distribution
|
|
54
|
+
description: null
|
|
55
|
+
placeholder: 'e.g., Linux Ubuntu 16.04'
|
|
56
|
+
validations:
|
|
57
|
+
required: false
|
|
58
|
+
- type: input
|
|
59
|
+
id: Python
|
|
60
|
+
attributes:
|
|
61
|
+
label: Python version
|
|
62
|
+
description: null
|
|
63
|
+
placeholder: 'e.g., 3.9'
|
|
64
|
+
validations:
|
|
65
|
+
required: false
|
|
66
|
+
- type: textarea
|
|
67
|
+
id: what-happened
|
|
68
|
+
attributes:
|
|
69
|
+
label: Current Behaviour?
|
|
70
|
+
description: 'Also tell us, what did you expect to happen?'
|
|
71
|
+
placeholder: Tell us what you see!
|
|
72
|
+
value: A bug happened!
|
|
73
|
+
validations:
|
|
74
|
+
required: true
|
|
75
|
+
- type: textarea
|
|
76
|
+
id: screenshot
|
|
77
|
+
attributes:
|
|
78
|
+
label: Which images caused the issue? (This is mandatory for images related issues)
|
|
79
|
+
description: Please ensure that an image depicting the cause of the bug or the inaccuracy of the prediction is included.
|
|
80
|
+
placeholder: Attach the image
|
|
81
|
+
validations:
|
|
82
|
+
required: false
|
|
83
|
+
- type: textarea
|
|
84
|
+
id: code-to-reproduce
|
|
85
|
+
attributes:
|
|
86
|
+
label: Standalone code to reproduce the issue
|
|
87
|
+
description: >-
|
|
88
|
+
Provide a reproducible test case that is the bare minimum necessary to
|
|
89
|
+
generate the problem. If possible, please share a link to
|
|
90
|
+
Colab/Jupyter/any notebook.
|
|
91
|
+
placeholder: Tell us what you see!
|
|
92
|
+
value: null
|
|
93
|
+
render: shell
|
|
94
|
+
validations:
|
|
95
|
+
required: true
|
|
96
|
+
- type: textarea
|
|
97
|
+
id: logs
|
|
98
|
+
attributes:
|
|
99
|
+
label: Relevant log output
|
|
100
|
+
description: >-
|
|
101
|
+
Please copy and paste any relevant log output. This will be
|
|
102
|
+
automatically formatted into code, so no need for backticks.
|
|
103
|
+
render: shell
|
|
104
|
+
- type: checkboxes
|
|
105
|
+
id: terms
|
|
106
|
+
attributes:
|
|
107
|
+
label: Code of Conduct
|
|
108
|
+
description: >-
|
|
109
|
+
By submitting this issue, you agree to follow our [Code of
|
|
110
|
+
Conduct](https://github.com/Kohulan/DECIMER-Image_Transformer/blob/master/CODE_OF_CONDUCT.md)
|
|
111
|
+
options:
|
|
112
|
+
- label: I agree to follow this project's Code of Conduct
|
|
113
|
+
required: true
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# This is a basic workflow to help you get started with Actions
|
|
2
|
+
|
|
3
|
+
name: Error checking and testing
|
|
4
|
+
|
|
5
|
+
# Controls when the workflow will run
|
|
6
|
+
on:
|
|
7
|
+
# Triggers the workflow on push or pull request events but only for the main branch
|
|
8
|
+
push:
|
|
9
|
+
branches: [ master ]
|
|
10
|
+
pull_request:
|
|
11
|
+
branches: [ master ]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
|
15
|
+
jobs:
|
|
16
|
+
|
|
17
|
+
build:
|
|
18
|
+
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
matrix:
|
|
22
|
+
python-version: ['3.10']
|
|
23
|
+
|
|
24
|
+
steps:
|
|
25
|
+
- uses: actions/checkout@v2
|
|
26
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
27
|
+
uses: actions/setup-python@v1
|
|
28
|
+
with:
|
|
29
|
+
python-version: ${{ matrix.python-version }}
|
|
30
|
+
- name: Install basic dependencies
|
|
31
|
+
run: |
|
|
32
|
+
python -m pip install --upgrade pip
|
|
33
|
+
- name: Test with tox
|
|
34
|
+
run: |
|
|
35
|
+
pip install -e .
|
|
36
|
+
pip install tox
|
|
37
|
+
tox
|
decimer-2.3.0/.gitignore
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
.vscode
|
|
12
|
+
build/
|
|
13
|
+
develop-eggs/
|
|
14
|
+
dist/
|
|
15
|
+
downloads/
|
|
16
|
+
eggs/
|
|
17
|
+
.eggs/
|
|
18
|
+
lib/
|
|
19
|
+
lib64/
|
|
20
|
+
parts/
|
|
21
|
+
sdist/
|
|
22
|
+
var/
|
|
23
|
+
wheels/
|
|
24
|
+
pip-wheel-metadata/
|
|
25
|
+
share/python-wheels/
|
|
26
|
+
*.egg-info/
|
|
27
|
+
.installed.cfg
|
|
28
|
+
*.egg
|
|
29
|
+
MANIFEST
|
|
30
|
+
|
|
31
|
+
# PyInstaller
|
|
32
|
+
# Usually these files are written by a python script from a template
|
|
33
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
34
|
+
*.manifest
|
|
35
|
+
*.spec
|
|
36
|
+
|
|
37
|
+
# Installer logs
|
|
38
|
+
pip-log.txt
|
|
39
|
+
pip-delete-this-directory.txt
|
|
40
|
+
|
|
41
|
+
# Unit test / coverage reports
|
|
42
|
+
htmlcov/
|
|
43
|
+
.tox/
|
|
44
|
+
.nox/
|
|
45
|
+
.coverage
|
|
46
|
+
.coverage.*
|
|
47
|
+
.cache
|
|
48
|
+
nosetests.xml
|
|
49
|
+
coverage.xml
|
|
50
|
+
*.cover
|
|
51
|
+
*.py,cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
db.sqlite3-journal
|
|
64
|
+
|
|
65
|
+
# Flask stuff:
|
|
66
|
+
instance/
|
|
67
|
+
.webassets-cache
|
|
68
|
+
|
|
69
|
+
# Scrapy stuff:
|
|
70
|
+
.scrapy
|
|
71
|
+
|
|
72
|
+
# Sphinx documentation
|
|
73
|
+
docs/_build/
|
|
74
|
+
|
|
75
|
+
# PyBuilder
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
.python-version
|
|
87
|
+
|
|
88
|
+
# pipenv
|
|
89
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
90
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
91
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
92
|
+
# install all needed dependencies.
|
|
93
|
+
#Pipfile.lock
|
|
94
|
+
|
|
95
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
96
|
+
__pypackages__/
|
|
97
|
+
|
|
98
|
+
# Celery stuff
|
|
99
|
+
celerybeat-schedule
|
|
100
|
+
celerybeat.pid
|
|
101
|
+
|
|
102
|
+
# SageMath parsed files
|
|
103
|
+
*.sage.py
|
|
104
|
+
|
|
105
|
+
# Environments
|
|
106
|
+
.env
|
|
107
|
+
.venv
|
|
108
|
+
env/
|
|
109
|
+
venv/
|
|
110
|
+
ENV/
|
|
111
|
+
env.bak/
|
|
112
|
+
venv.bak/
|
|
113
|
+
|
|
114
|
+
# Spyder project settings
|
|
115
|
+
.spyderproject
|
|
116
|
+
.spyproject
|
|
117
|
+
|
|
118
|
+
# Rope project settings
|
|
119
|
+
.ropeproject
|
|
120
|
+
|
|
121
|
+
# mkdocs documentation
|
|
122
|
+
/site
|
|
123
|
+
|
|
124
|
+
# mypy
|
|
125
|
+
.mypy_cache/
|
|
126
|
+
.dmypy.json
|
|
127
|
+
dmypy.json
|
|
128
|
+
|
|
129
|
+
# Pyre type checker
|
|
130
|
+
.pyre/
|
|
131
|
+
|
|
132
|
+
.DS_Store
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Read the Docs configuration file
|
|
2
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
3
|
+
|
|
4
|
+
# Required
|
|
5
|
+
version: 2
|
|
6
|
+
|
|
7
|
+
# Build documentation in the docs/ directory with Sphinx
|
|
8
|
+
sphinx:
|
|
9
|
+
configuration: docs/conf.py
|
|
10
|
+
|
|
11
|
+
# Optionally build your docs in additional formats such as PDF
|
|
12
|
+
formats:
|
|
13
|
+
- pdf
|
|
14
|
+
|
|
15
|
+
# Optionally set the version of Python and requirements required to build your docs
|
|
16
|
+
python:
|
|
17
|
+
version: "3.8"
|
|
18
|
+
install:
|
|
19
|
+
- requirements: docs/requirements.txt
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Benchmark results
|
|
2
|
+
|
|
3
|
+
This is a collection of scripts for running the benchmarks described in our publication.
|
|
4
|
+
|
|
5
|
+
_________________
|
|
6
|
+
|
|
7
|
+
## In order to replicate the benchmark results, it is necessary to install RDKit.
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
conda install -c rdkit rdkit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## The slight distortions (shearing, rotation) are applied to the benchmark images by running:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
python distort_images $input_directory $output_directory
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Run DECIMER and save the results in a file:
|
|
20
|
+
```
|
|
21
|
+
python run_decimer_save_results.py $image_dir $benchmark_ID
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- The results of the benchmark run are going to be save in $benchmark_ID.txt which contains the image names and the results (SMILES representation of the depicted molecule)
|
|
25
|
+
- Per line: $image_name \t $SMILES
|
|
26
|
+
|
|
27
|
+
## Evaluate the benchmark results:
|
|
28
|
+
```
|
|
29
|
+
python evaluate_benchmarks.py $benchmark_ID.txt $reference_file_directory
|
|
30
|
+
```
|
|
31
|
+
- $benchmark_ID.txt is the output generated by run_decimer_save_results.py
|
|
32
|
+
- $reference_file_directory is the path of a directory that contains SD- or mol-files as provided in the benchmark datasets
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
from multiprocessing import Pool
|
|
4
|
+
import numpy as np
|
|
5
|
+
from skimage.io import imread, imsave
|
|
6
|
+
import imgaug.augmenters as iaa
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def distort_image(input_image_path: str, output_image_path: str) -> None:
|
|
10
|
+
"""
|
|
11
|
+
This function takes the path of an input image and the desired output image path (both str).
|
|
12
|
+
It rotates the input image randomly (-5° or +5°) and applies shearing (in x or y-direction with an
|
|
13
|
+
angle of -9° or 9°) as described by Clevert et al (Img2Mol (preprint)).
|
|
14
|
+
I was a bit confused about the "shearing factor" of +/- 0.1 described by Clevert et al. Normally the transformation
|
|
15
|
+
is done with a shearing angle. I assume here that the correponding angle is 0.1*90° = 9° as 90° is the extreme case
|
|
16
|
+
where the image turns into a horizontal or vertical line.
|
|
17
|
+
This seems reasonable as it results in a mild distortion as described by the authors.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
input_image_path (str): Path of input image
|
|
21
|
+
output_image_path (str): Path where the output image is saved
|
|
22
|
+
"""
|
|
23
|
+
image = imread(input_image_path)
|
|
24
|
+
# Add a one-pixel-layer of white pixels so that we can simply take that as a reference what to fill
|
|
25
|
+
# the blank space with when we apply the transformations
|
|
26
|
+
image = np.pad(image, pad_width=1, mode="constant", constant_values=255)
|
|
27
|
+
augmentation = iaa.Sequential(
|
|
28
|
+
[
|
|
29
|
+
iaa.Affine(rotate=[-5, 5], mode="edge", fit_output=True),
|
|
30
|
+
iaa.OneOf(
|
|
31
|
+
[
|
|
32
|
+
iaa.geometric.ShearX([-9, 9], mode="edge", fit_output=True),
|
|
33
|
+
iaa.geometric.ShearY([-9, 9], mode="edge", fit_output=True),
|
|
34
|
+
]
|
|
35
|
+
),
|
|
36
|
+
]
|
|
37
|
+
)
|
|
38
|
+
image = augmentation(images=[image])[0]
|
|
39
|
+
imsave(fname=output_image_path, arr=image)
|
|
40
|
+
return
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def main():
|
|
44
|
+
"""This script takes an input directory with images of chemical structure depictions, applies a random
|
|
45
|
+
rotation (-5° or +5°) as well as shearing (angle drawn from [-0.1, 0.1]) to every input image. These
|
|
46
|
+
distortions are supposed to imitate the image modifications described by Clevert et al (Img2Mol (preprint))"""
|
|
47
|
+
input_dir = os.path.abspath(sys.argv[1])
|
|
48
|
+
output_dir = os.path.abspath(sys.argv[2])
|
|
49
|
+
if not os.path.exists(output_dir):
|
|
50
|
+
os.mkdir(output_dir)
|
|
51
|
+
starmap_iterable = [
|
|
52
|
+
(os.path.join(input_dir, image_name), os.path.join(output_dir, image_name))
|
|
53
|
+
for image_name in os.listdir(input_dir)
|
|
54
|
+
if image_name[-3:].lower() == "png"
|
|
55
|
+
]
|
|
56
|
+
with Pool(5) as p:
|
|
57
|
+
_ = p.starmap(distort_image, starmap_iterable)
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
if len(sys.argv) != 3:
|
|
62
|
+
print("Usage: {} input_dir output_dir".format(sys.argv[0]))
|
|
63
|
+
else:
|
|
64
|
+
main()
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
from rdkit import Chem, DataStructs
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def compare_molecules_inchi_match(
|
|
7
|
+
input_file_path: str, reference_directory: str
|
|
8
|
+
) -> None:
|
|
9
|
+
"""
|
|
10
|
+
This function checks if the molecules in the DECIMER results to a set of reference
|
|
11
|
+
mol-files using Standard InChI.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
input_file (str): Path of file that contains image names and SMILES as created by run_decimer_save_results.py
|
|
15
|
+
reference_directory (str): Path of directory with mol/sd files as they come with the benchmark datasets
|
|
16
|
+
"""
|
|
17
|
+
""""""
|
|
18
|
+
# We assume that the input file has the structure $img_name\t$smiles\n per line
|
|
19
|
+
tanimoto_list = []
|
|
20
|
+
perfect_match_count = 0
|
|
21
|
+
with open(input_file_path, "r") as input_file:
|
|
22
|
+
lines = input_file.readlines()
|
|
23
|
+
# assert len(os.listdir(reference_directory)) == len(lines)
|
|
24
|
+
for line in lines:
|
|
25
|
+
ID, smiles = line.split("\t")
|
|
26
|
+
smiles = smiles[:-1] # Delete \n at the end
|
|
27
|
+
# Generate mol objects
|
|
28
|
+
input_mol = Chem.MolFromSmiles(smiles)
|
|
29
|
+
if input_mol:
|
|
30
|
+
for format in [".mol", ".sdf", ".MOL"]:
|
|
31
|
+
if os.path.exists(
|
|
32
|
+
os.path.join(reference_directory, ID[:-4] + format)
|
|
33
|
+
):
|
|
34
|
+
reference_mol_suppl = Chem.SDMolSupplier(
|
|
35
|
+
os.path.join(reference_directory, ID[:-4] + format)
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Generate Inchi
|
|
39
|
+
input_inchi = Chem.inchi.MolToInchi(
|
|
40
|
+
input_mol
|
|
41
|
+
) # rdmolfiles.MolToSmiles(input_mol, True)
|
|
42
|
+
for reference_mol in reference_mol_suppl:
|
|
43
|
+
if reference_mol:
|
|
44
|
+
reference_inchi = Chem.inchi.MolToInchi(
|
|
45
|
+
reference_mol
|
|
46
|
+
) # .rdmolfiles.MolToSmiles(reference_mol, True)#
|
|
47
|
+
|
|
48
|
+
# Count perfect InChI string match
|
|
49
|
+
if input_inchi == reference_inchi:
|
|
50
|
+
perfect_match_count += 1
|
|
51
|
+
|
|
52
|
+
# Generate fingerprints and Tanimoto similarity
|
|
53
|
+
reference_fp = Chem.RDKFingerprint(reference_mol)
|
|
54
|
+
input_fp = Chem.RDKFingerprint(input_mol)
|
|
55
|
+
tanimoto = DataStructs.FingerprintSimilarity(
|
|
56
|
+
reference_fp, input_fp
|
|
57
|
+
)
|
|
58
|
+
tanimoto_list.append(tanimoto)
|
|
59
|
+
break
|
|
60
|
+
|
|
61
|
+
print(
|
|
62
|
+
"{} out of {} ({}%)".format(
|
|
63
|
+
perfect_match_count, len(lines), perfect_match_count / len(lines) * 100
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
print("Average Tanimoto: {}".format(sum(tanimoto_list) / len(tanimoto_list)))
|
|
67
|
+
tanimoto_one_count = len(
|
|
68
|
+
[tanimoto for tanimoto in tanimoto_list if tanimoto == 1.0]
|
|
69
|
+
)
|
|
70
|
+
print(
|
|
71
|
+
"Tanimoto 1.0 count: {} out of {} ({}%)".format(
|
|
72
|
+
tanimoto_one_count, len(lines), tanimoto_one_count / len(lines)
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main():
|
|
78
|
+
if len(sys.argv) != 3:
|
|
79
|
+
print(
|
|
80
|
+
'"Usage of this function: {} decimer_benchmark_results_file directory-with-reference-molfiles'.format(
|
|
81
|
+
sys.argv[0]
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
if len(sys.argv) == 3:
|
|
85
|
+
compare_molecules_inchi_match(sys.argv[1], sys.argv[2])
|
|
86
|
+
sys.exit(1)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
main()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from DECIMER import predict_SMILES
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
"""
|
|
9
|
+
This script runs Decimer on every image in a given directory (first argument) and saves the
|
|
10
|
+
results in a text file with a given ID (second argument).
|
|
11
|
+
"""
|
|
12
|
+
im_path = sys.argv[1]
|
|
13
|
+
save_ID = sys.argv[2]
|
|
14
|
+
|
|
15
|
+
# Don't start from beginning if a benchmark run aborted for some reason
|
|
16
|
+
with open("{}.txt".format(save_ID), "a+") as output:
|
|
17
|
+
lines = output.readlines()
|
|
18
|
+
already_processed = list([line.split("\t")[0] for line in lines])
|
|
19
|
+
|
|
20
|
+
for im in os.listdir(im_path):
|
|
21
|
+
if im not in already_processed:
|
|
22
|
+
with open("{}.txt".format(save_ID), "a") as output:
|
|
23
|
+
smiles = predict_SMILES(os.path.join(im_path, im))
|
|
24
|
+
output.write("{}\t{}\n".format(im, smiles))
|
|
25
|
+
already_processed.append(im)
|
|
26
|
+
print(im)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if __name__ == "__main__":
|
|
30
|
+
if len(sys.argv) == 3:
|
|
31
|
+
main()
|
|
32
|
+
else:
|
|
33
|
+
print("Usage: {} image_dir benchmark_ID".format(sys.argv[0]))
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
authors:
|
|
4
|
+
- family-names: "Rajan"
|
|
5
|
+
given-names: "Kohulan"
|
|
6
|
+
orcid: "https://orcid.org/0000-0003-1066-7792"
|
|
7
|
+
- family-names: "Zielesny"
|
|
8
|
+
given-names: "Achim"
|
|
9
|
+
orcid: "https://orcid.org/0000-0003-0722-4229"
|
|
10
|
+
- family-names: "Steinbeck"
|
|
11
|
+
given-names: "Christoph"
|
|
12
|
+
orcid: "https://orcid.org/0000-0001-6966-0814"
|
|
13
|
+
title: "DECIMER-V2"
|
|
14
|
+
version: 2.2.0
|
|
15
|
+
doi: 10.5281/zenodo.7655952
|
|
16
|
+
date-released: 2022.05.18
|
|
17
|
+
url: "https://github.com/Kohulan/DECIMER-Image_Transformer-2"
|
|
18
|
+
license: MIT
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# DECIMER Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
+
and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
+
overall community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
+
advances of any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email
|
|
35
|
+
address, without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official e-mail address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
kohulan.rajan@uni-jena.de or otto.brinkhaus@uni-jena.de.
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series
|
|
86
|
+
of actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or
|
|
93
|
+
permanent ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
+
the community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.0, available at
|
|
119
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
+
|
|
124
|
+
[homepage]: https://www.contributor-covenant.org
|
|
125
|
+
|
|
126
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
+
https://www.contributor-covenant.org/translations.
|