Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct misspelling word botte to bottle :-) #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM debian:jessie-slim
FROM debian:bookworm-slim

ENV PYTHONUNBUFFERED 1

# install required ubuntu packages
RUN apt-get update --fix-missing && \
apt-get install -y --no-install-recommends ca-certificates libxrender1 libxext6 wget bzip2 libgraphicsmagick++3 libopenbabel4 libpotrace0 && \
apt-get install -y --no-install-recommends ca-certificates libxrender1 libxext6 wget bzip2 osra libopenbabel7 libpotrace0 && \
apt-get -qq -y autoremove && \
apt-get autoclean && \
rm -rf /var/lib/apt/lists/* /var/log/dpkg.log
Expand All @@ -27,10 +27,6 @@ RUN conda env create -n chembl-beaker -f /tmp/environment.yml
# activate env (add conda env bin to path)
ENV PATH /opt/conda/envs/chembl-beaker/bin:$PATH

# osra needs both files in the same bin dir
RUN cp /opt/conda/pkgs/osra-2.0.1-0/share/spelling.txt /opt/conda/envs/chembl-beaker/bin/spelling.txt && \
cp /opt/conda/pkgs/osra-2.0.1-0/share/superatom.txt /opt/conda/envs/chembl-beaker/bin/superatom.txt

# copy beaker and config file
COPY src/chembl_beaker chembl_beaker
COPY beaker.conf beaker.conf
Expand Down
241 changes: 241 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# chembl_beaker

这个是[molOCR化学结构式识别](https://github.com/def-fun/molOCR)
的后端,在[chembl_beaker](https://github.com/chembl/chembl_beaker)的基础上修改

部署方式如下:

```shell
# install docker on your linux machine
sudo snap install docker

# download
wget https://github.com/def-fun/chembl_beaker/archive/refs/heads/master.zip
unzip chembl_beaker-master.zip

# build and run
cd chembl_beaker-master
sudo docker build -f Dockerfile -t my_chembl_beaker:v1.2 .
sudo docker run -p 5000:5000 my_chembl_beaker:v1.2

# backup
#sudo docker save -o my_chembl_beaker-v1.2.tar my_chembl_beaker:v1.2
sudo docker save 722c1891ce36 > my_chembl_beaker-v1.2.tar
7z a -mx9 my_chembl_beaker-v1.2.tar.7z my_chembl_beaker-v1.2.tar

# check size and sha1sum
# my_chembl_beaker-v1.2.tar.7z 922M de78350d2db6c7a2a1f3f9a4b86195466a3437ef
# my_chembl_beaker-v1.2.tar 3.1G 338d26ab0ccee04e661d74c9975641e5adbaa592

# restore
sudo docker load -i my_chembl_beaker-v1.2.tar
```

在Ubuntu 22.04.3 LTS上测试通过

```shell
curl -v -X POST --data-binary @test/5.png http://127.0.0.1:5000/image2ctab
```

输出结果如下

```text
* Trying 127.0.0.1:5000...
* Connected to 127.0.0.1 (127.0.0.1) port 5000 (#0)
> POST /image2ctab HTTP/1.1
> Host: 127.0.0.1:5000
> User-Agent: curl/8.1.2
> Accept: */*
> Content-Length: 18716
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 200 OK
< Server: gunicorn/20.0.0
< Date: Tue, 09 Apr 2024 06:51:27 GMT
< Connection: close
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS
< Access-Control-Allow-Headers: Origin, Accept, Content-Type, X-Requested-With, X-CSRF-Token
< X-Chembl-In-Cache: False
< X-Chembl-Retrieval-Time: 0.5003535747528076
< Content-Length: 6474
< Content-Type: text/html; charset=UTF-8
<

OpenBabel04092406512D

11 11 0 0 0 0 0 0 0 0999 V2000
2.0160 -3.0171 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.4095 -3.8122 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4013 -3.9398 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2209 -2.4106 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9388 -2.6317 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9731 -1.0923 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2040 -0.4284 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.4751 -1.1245 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.7645 -0.4218 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2211 -3.3535 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.4656 -2.6188 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
1 4 1 0 0 0 0
1 5 1 0 0 0 0
5 6 2 0 0 0 0
5 10 1 0 0 0 0
6 7 1 0 0 0 0
7 8 2 0 0 0 0
8 9 1 0 0 0 0
10 11 2 0 0 0 0
11 8 1 0 0 0 0
M END
> <Surrounding_box>
42x13-139x64

$$$$

OpenBabel04092406512D

8 8 0 0 0 0 0 0 0 0999 V2000
1.6719 -7.1503 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.6742 -8.6782 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9791 -6.3822 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2481 -7.1202 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.5246 -6.4152 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.0302 -9.3472 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.3258 -9.4518 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2275 -8.6211 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0 0 0 0
1 3 1 0 0 0 0
2 6 1 0 0 0 0
2 7 1 0 0 0 0
3 4 2 0 0 0 0
4 5 1 0 0 0 0
6 8 2 0 0 0 0
8 4 1 0 0 0 0
M END
> <Surrounding_box>
41x104-120x151

$$$$

OpenBabel04092406512D

13 15 0 0 0 0 0 0 0 0999 V2000
0.4236 -13.7979 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.3447 -12.7275 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.0315 -12.1205 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8915 -13.1916 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.2364 -12.9836 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.6691 -12.6501 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.7117 -13.7852 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.2770 -14.4402 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.8242 -14.4049 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.3141 -15.6207 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.9035 -15.3204 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.1576 -15.1932 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.7654 -15.5325 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0 0 0 0
1 11 1 0 0 0 0
2 4 1 0 0 0 0
3 4 1 0 0 0 0
4 8 2 0 0 0 0
5 3 1 0 0 0 0
5 6 1 0 0 0 0
6 7 2 0 0 0 0
8 9 1 0 0 0 0
8 10 1 0 0 0 0
9 5 2 0 0 0 0
9 13 1 0 0 0 0
11 10 2 0 0 0 0
12 7 1 0 0 0 0
13 12 2 0 0 0 0
M END
> <Surrounding_box>
42x193-153x245

$$$$

OpenBabel04092406512D

10 11 0 0 0 0 0 0 0 0999 V2000
1.6178 -19.3401 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9426 -20.0320 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2246 -19.3403 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.5461 -20.0617 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.5608 -21.5790 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.3129 -22.2478 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.9618 -21.5744 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.6980 -22.2497 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.3691 -21.5768 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.3981 -20.0590 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0 0 0 0
2 3 1 0 0 0 0
3 4 1 0 0 0 0
5 6 1 0 0 0 0
5 4 1 0 0 0 0
7 6 1 0 0 0 0
7 2 1 0 0 0 0
8 7 2 0 0 0 0
8 9 1 0 0 0 0
9 10 2 0 0 0 0
10 1 1 0 0 0 0
M END
> <Surrounding_box>
40x303-121x348

$$$$

OpenBabel04092406512D

21 23 0 0 0 0 0 0 0 0999 V2000
2.1113 -33.6262 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1.9409 -34.6115 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.0499 -33.2811 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.0859 -31.7463 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.3295 -31.0534 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.5904 -31.7770 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.8705 -31.0132 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.8677 -29.5344 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.6449 -28.8224 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.6222 -27.2593 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.9136 -26.5218 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.1333 -27.2780 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.1496 -28.7533 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.2062 -31.7853 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.4346 -34.0029 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.7113 -33.2725 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.1704 -33.2844 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.2807 -33.9680 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.5347 -33.3323 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
10.6800 -31.7831 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
9.4253 -31.0646 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0 0 0 0
1 3 1 0 0 0 0
3 4 2 0 0 0 0
3 18 1 0 0 0 0
4 5 1 0 0 0 0
5 6 2 0 0 0 0
6 7 1 0 0 0 0
6 19 1 0 0 0 0
7 8 1 0 0 0 0
8 13 2 0 0 0 0
9 8 1 0 0 0 0
10 9 2 0 0 0 0
10 11 1 0 0 0 0
11 12 2 0 0 0 0
13 12 1 0 0 0 0
14 7 1 0 0 0 0
14 21 1 0 0 0 0
15 16 2 0 0 0 0
15 17 1 0 0 0 0
17 14 2 0 0 0 0
18 19 2 0 0 0 0
20 16 1 0 0 0 0
21 20 2 0 0 0 0
M END
> <Surrounding_box>
40x414-199x534

$$$$
* Closing connection 0
```
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,4 @@ Like every good software written in Python, beaker is self-documented. When you

Development - writing your own extentions
--------
Developing new app should be easy. The only required file is ``views.py`` where you should define your botte ``routes``.
Developing new app should be easy. The only required file is ``views.py`` where you should define your bottle ``routes``.
2 changes: 1 addition & 1 deletion beaker.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ BOTTLE_PORT = 5000
BOTTLE_HOST = 0.0.0.0
SERVER_MIDDLEWARE = gunicorn
WORKERS = 4
OSRA_BINARIES_LOCATION = /opt/conda/envs/chembl-beaker/bin/osra
OSRA_BINARIES_LOCATION = /usr/bin/osra
1 change: 0 additions & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies:
- lxml==4.4.1
- matplotlib==3.1.1
- pycairo==1.18.1
- osra==2.0.1
- chembl_structure_pipeline==1.0.0
- pip:
- bottle==0.12.18
Expand Down
1 change: 1 addition & 0 deletions src/chembl_beaker/beaker/core_apps/osra/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def _recogniseImage(img, osra, frmt=None, jaggy=False, adaptive=False, unpaper=0
arguments.extend(['-u', str(unpaper)])
if frmt and frmt in ('can', 'smi', 'sdf'):
arguments.extend(['-f', frmt])
arguments.append('-c') # add surrounding box coordinates
arguments.append(fpath)
p = Popen(arguments, stdin=PIPE, stdout=PIPE, stderr=PIPE)
result, err = p.communicate(input=img)
Expand Down
4 changes: 1 addition & 3 deletions src/chembl_beaker/beaker/core_apps/osra/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def image2ctabView(img, params):
kwargs['adaptive'] = _parseFlag(params.get('adaptive', False))
kwargs['unpaper'] = int(params.get('unpaper', 0))

known_location = '/usr/local/bin/osra'
if not os.path.exists(known_location):
known_location = '/usr/bin/osra'
known_location = '/usr/bin/osra'
return _image2ctab(img, config.get('osra_binaries_location', known_location), **kwargs)


Expand Down
Binary file added test/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.