Skip to content
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
3 changes: 1 addition & 2 deletions rxnfp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import logging
import random
import warnings
import pkg_resources
import sklearn

from transformers import (
Expand Down Expand Up @@ -562,4 +561,4 @@ def __init__(
continue
elif 'pooler' in name:
continue
param.requires_grad = False
param.requires_grad = False
12 changes: 4 additions & 8 deletions rxnfp/tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
import re
import numpy as np
from rdkit import Chem

import pkg_resources
from importlib.resources import files

from typing import List

Expand All @@ -21,11 +20,8 @@
SMI_REGEX_PATTERN = r"(\%\([0-9]{3}\)|\[[^\]]+]|Br?|Cl?|N|O|S|P|F|I|b|c|n|o|s|p|\||\(|\)|\.|=|#|-|\+|\\|\/|:|~|@|\?|>>?|\*|\$|\%[0-9]{2}|[0-9])"

def get_default_tokenizer():
default_vocab_path = (
pkg_resources.resource_filename(
"rxnfp",
"models/transformers/bert_ft_10k_25s/vocab.txt"
)
default_vocab_path = str(
files("rxnfp") / "models/transformers/bert_ft_10k_25s/vocab.txt"
)
return SmilesTokenizer(default_vocab_path, do_lower_case=False)

Expand Down Expand Up @@ -150,4 +146,4 @@ def process_reaction(rxn):

joined_precursors = ".".join(sorted(precursors))
joined_products = ".".join(sorted(products))
return f"{joined_precursors}>>{joined_products}"
return f"{joined_precursors}>>{joined_products}"
16 changes: 5 additions & 11 deletions rxnfp/transformer_fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

# Cell
import torch
import pkg_resources
import numpy as np
from importlib.resources import files
from typing import List
from tqdm import tqdm
from itertools import islice
Expand Down Expand Up @@ -109,16 +109,10 @@ def convert_batch(self, rxn_smiles_list: List[str]):

def get_default_model_and_tokenizer(model='bert_ft', force_no_cuda=False):

model_path = pkg_resources.resource_filename(
"rxnfp",
f"models/transformers/{model}"
)
model_path = str(files("rxnfp") / f"models/transformers/{model}")

tokenizer_vocab_path = (
pkg_resources.resource_filename(
"rxnfp",
f"models/transformers/{model}/vocab.txt"
)
tokenizer_vocab_path = str(
files("rxnfp") / f"models/transformers/{model}/vocab.txt"
)
device = torch.device("cuda" if (torch.cuda.is_available() and not force_no_cuda) else "cpu")

Expand All @@ -142,4 +136,4 @@ def generate_fingerprints(rxns: List[str], fingerprint_generator:FingerprintGene
fps_batch = fingerprint_generator.convert_batch(batch)

fps += fps_batch
return np.array(fps)
return np.array(fps)
4 changes: 2 additions & 2 deletions settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ author_email = phs@zurich.ibm.com
copyright = RXN for Chemistry team / University of Bern
branch = master
version = 0.1.0
min_python = 3.6
min_python = 3.9
audience = Developers
language = English
custom_sidebar = True
license = mit
status = 2
requirements = transformers>=4.5.0 torch>=1.6 scipy==1.4.1 scikit-learn==0.23.1 matplotlib==3.2.2 faerun==0.3.20
requirements = transformers torch scipy scikit-learn matplotlib faerun
nbs_path = nbs
doc_path = docs
doc_host = https://rxn4chemistry.github.io
Expand Down
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pkg_resources import parse_version
from packaging.version import Version
from configparser import ConfigParser
import setuptools
assert parse_version(setuptools.__version__)>=parse_version('36.2')
assert Version(setuptools.__version__) >= Version("36.2")

# note: all settings are in settings.ini; edit there, not here
config = ConfigParser(delimiters=['='])
Expand All @@ -19,7 +19,7 @@
}
statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
'4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
py_versions = '2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8'.split()
py_versions = "2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 3.12".split()

requirements = cfg.get('requirements','').split()
lic = licenses[cfg['license']]
Expand All @@ -45,4 +45,3 @@
zip_safe = False,
entry_points = { 'console_scripts': cfg.get('console_scripts','').split() },
**setup_cfg)