Skip to content

Commit 853adf1

Browse files
authored
iterables
* allow any kind of iterables * sqlalchemy not needed anymore * test on python3.8
1 parent 025fd3f commit 853adf1

File tree

6 files changed

+17
-40
lines changed

6 files changed

+17
-40
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ matrix:
66
env: CONDA=3.6
77
- os: linux
88
env: CONDA=3.7
9+
- os: linux
10+
env: CONDA=3.8
911
- os: osx
1012
env: CONDA=3.6
1113
- os: osx
1214
env: CONDA=3.7
15+
- os: osx
16+
env: CONDA=3.8
1317

1418
before_install:
1519
- |

FPSim2/io/FPSim2_io.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import rdkit
22
from rdkit import Chem
3-
from sqlalchemy.engine.result import ResultProxy
43
from FPSim2.FPSim2lib import py_popcount
54
from rdkit.Chem import rdMolDescriptors
65
from rdkit.Avalon import pyAvalonTools
76
from collections import namedtuple
7+
from collections.abc import Iterable
88
import tables as tb
99
import numpy as np
1010
import textwrap
@@ -336,21 +336,21 @@ def get_mol_suplier(io_source):
336336
"""Returns a mol supplier depending on the object type and file extension.
337337
338338
Args:
339-
io_source: source of molecules, smi or sdf filenames,
340-
SQLA ResultProxy or python list.
339+
io_source: source of molecules; smi or sdf filenames,
340+
or any iterable object.
341341
Returns:
342342
molecule supplier generator.
343343
"""
344344
supplier = None
345-
if isinstance(io_source, list) or isinstance(io_source, ResultProxy):
346-
supplier = it_supplier
347-
else:
345+
if isinstance(io_source, str):
348346
input_type = io_source.split(".")[-1]
349347
if input_type == "smi":
350348
supplier = smi_mol_supplier
351349
elif input_type == "sdf":
352350
supplier = sdf_mol_supplier
353-
if not supplier:
351+
elif isinstance(io_source, Iterable):
352+
supplier = it_supplier
353+
else:
354354
raise Exception("No valid input molecules input.")
355355
return supplier
356356

README.md

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@ From source:
2424
- clone the repo
2525
- `pip install ./FPSim2`
2626

27-
From a conda environment. Builds available for:
28-
- linux:
29-
- Python 3.6
30-
- Python 3.7
31-
- mac:
32-
- Python 3.6
33-
- Python 3.7
34-
- windows:
35-
- Python 3.6
36-
- Python 3.7
27+
From a conda environment:
3728

3829
```bash
3930
conda install -c efelix fpsim2
@@ -55,7 +46,7 @@ create_db_file('chembl.sdf', 'chembl.h5', 'Morgan', {'radius': 2, 'nBits': 2048}
5546
# from Python list
5647
create_db_file([['CC', 1], ['CCC', 2], ['CCCC', 3]], 'test/10mols.h5', 'Morgan', {'radius': 2, 'nBits': 2048})
5748

58-
# from sqlalchemy ResulProxy
49+
# or any other iterable like sqlalchemy ResultProxy
5950
from sqlalchemy.orm import Session
6051
from sqlalchemy import create_engine
6152

@@ -97,7 +88,7 @@ In case RDKit is not able to load a molecule, the id assigned to the molecule wi
9788
```python
9889
from FPSim2 import FPSim2Engine
9990

100-
fp_filename = 'chembl_25.h5'
91+
fp_filename = 'chembl_27.h5'
10192
query = 'CC(=O)Oc1ccccc1C(=O)O'
10293

10394
fpe = FPSim2Engine(fp_filename)
@@ -114,7 +105,7 @@ If you're searching against a huge dataset or you have small RAM, you can still
114105
```python
115106
from FPSim2 import FPSim2Engine
116107

117-
fp_filename = 'chembl_25.h5'
108+
fp_filename = 'chembl_27.h5'
118109
query = 'CC(=O)Oc1ccccc1C(=O)O'
119110

120111
fpe = FPSim2Engine(fp_filename, in_memory_fps=False)

conda.recipe/meta.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ requirements:
2222
- python
2323
- numpy>=1.14
2424
- pytables>=3.4.4
25-
- sqlalchemy>=1.2
2625
- rdkit>=2018.09
2726
- vs2015_runtime # [win]
2827

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import platform
44
import sys
55

6-
__version__ = "0.1.5"
6+
__version__ = "0.1.6"
77

88

99
class get_pybind_include(object):
@@ -121,6 +121,7 @@ def build_extensions(self):
121121
"License :: OSI Approved :: MIT License",
122122
"Programming Language :: Python :: 3.6",
123123
"Programming Language :: Python :: 3.7",
124+
"Programming Language :: Python :: 3.8",
124125
"Topic :: Scientific/Engineering :: Chemistry",
125126
],
126127
)

test/test_fpsim.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
sort_db_file,
1313
)
1414
from rdkit import Chem, DataStructs
15-
from sqlalchemy import create_engine
16-
from sqlalchemy.orm import Session
1715
import unittest
1816
import os
1917

@@ -100,22 +98,6 @@ def test_d_create_db_file_list(self):
10098
assert config[1]["nBits"] == fp_params["nBits"]
10199
assert fp_file.root.fps.shape[0] == 3
102100

103-
def test_e_create_db_file_sqla(self):
104-
in_file = os.path.join(TESTS_DIR, 'data/test.db')
105-
out_file = os.path.join(TESTS_DIR, 'data/10mols_sqla.h5')
106-
engine = create_engine("sqlite:///{}".format(in_file))
107-
s = Session(engine)
108-
sql_query = "select mol_string, mol_id from structure"
109-
resprox = s.execute(sql_query)
110-
111-
create_db_file(resprox, out_file, fp_type, fp_params)
112-
with tb.open_file(out_file, mode="r") as fp_file:
113-
config = fp_file.root.config
114-
assert config[0] == fp_type
115-
assert config[1]["radius"] == fp_params["radius"]
116-
assert config[1]["nBits"] == fp_params["nBits"]
117-
assert fp_file.root.fps.shape[0] == 10
118-
119101
def test_f_load_fps(self):
120102
in_file = os.path.join(TESTS_DIR, 'data/10mols.h5')
121103
fps = load_fps(in_file)

0 commit comments

Comments
 (0)