Views
No views yet
1git lfs install # Only once if not done already
2git clone https://huggingface.co/lamthuy/MorganGens = [12][184][1200]1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2from utils import MorganFingerprint, morgan_fingerprint_to_text
3
4
5# Load the checkpoint and the tokenizer
6checkpoint_path = "lamthuy/MorganGen"
7model = AutoModelForSeq2SeqLM.from_pretrained(checkpoint_path)
8tokenizer = AutoTokenizer.from_pretrained(checkpoint_path)
9
10# Given a SMILES, get its fingerpint
11smiles = "CC(=O)OC1=CC=CC=C1C(=O)O"
12m = MorganFingerprint()
13mf = m.smiles_to_morgan(smiles)
14
15# convert it to the indices text format
16s = morgan_fingerprint_to_text(mf)
17
18# encode
19input_ids = tokenizer.encode(s, return_tensors="pt")
20# Generate output sequence
21output_ids = model.generate(input_ids, max_length=64, num_beams=5)
22
23# Decode the generated output
24output_smiles = tokenizer.decode(output_ids[0], skip_special_tokens=True)
25print(output_smiles)
26@inproceedings{hoang2024morgangen,
title={MorganGen: Generative Modeling of SMILES Using Morgan Fingerprint Features},
author={Hoang, Lam Thanh and D{\'\i}az, Ra{\'u}l Fern{\'a}ndez and Lopez, Vanessa},
booktitle={American Chemical Society (ACS) Fall Meeting},
year={2024}
}