<jupyter_start><jupyter_text>Query local ChEMBL DB for speedGet your local copy from http://doi.org/10.6019/CHEMBL.database.27. You need `chembl_27_sqlite.tar.gz` for this notebook. Extract it and point `DATABASE` below to the `chembl_27.db` file.<jupyter_code>DATABASE = "chembl_27/chembl_27_sqlite/chembl_27.db"
conn = sql.connect(DATABASE, isolation_level=None)
db = conn.cursor()
q = "SELECT activities.activity_id FROM activities"
result = db.execute(q)
arr = np.array(list(result), dtype=int).reshape((-1,))
np.savez_compressed("chembl27_activities", activities=arr, allow_pickle=False)<jupyter_output><empty_output><jupyter_text>Load compressed `*.npz` file like this. Resulting `activities` is a `set` with fast membership tests!<jupyter_code>import numpy as np
with np.load("chembl27_activities.npz") as f:
    activities = set(f["activities"])
activities
18839065 in activities<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12104689203925845, 'fraction_numerical': 0.03380588876772083, 'mean_word_length': 7.123893805309734, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '127456', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 346, 'n_tokens_neox': 324, 'n_words': 73, 'path': 'teachopencadd/talktorials/T001_query_chembl/data/all_chembl_activities.ipynb', 'repo_name': 'PabloSoto1995/teachopencadd', 'size': '917'}