Package: atomInSmiles
Atom-in-SMILES tokenization.Tokenization is an important preprocessing step in natural language processing
that may have a significant influence on prediction quality. This research showed
that the traditional SMILES tokenization has a certain limitation that results in
tokens failing to reflect the true nature of molecules. To address this issue, we
developed the atom-in-SMILES tokenization scheme that eliminates ambiguities
in the generic nature of SMILES tokens. Our results in multiple chemical
translation and molecular property prediction tasks demonstrate that proper
tokenization has a significant impact on prediction quality. In terms of prediction
accuracy and token degeneration, atom-in-SMILES is more effective method in
generating higher-quality SMILES sequences from AI-based chemical models
compared to other tokenization and representation schemes. We investigated the
degrees of token degeneration of various schemes and analyzed their adverse
effects on prediction quality. Additionally, token-level repetitions were quantified,
and generated examples were incorporated for qualitative examination. We
believe that the atom-in-SMILES tokenization has a great potential to be
adopted by broad related scientific communities, as it provides chemically
accurate, tailor-made tokens for molecular property prediction, chemical
translation, and molecular generative models.InstallationIt can be installed using pip.pipinstallatomInSmilesor clone it from the GitHub repository and install locally.gitclonehttps://github.com/snu-lcbc/atom-in-SMILEScdatom-in-SMILES
pythonsetup.pyinstallUsage & DemoBrief descriptions of the main functions:FunctionDescriptionatomInSmiles.encodeConverts a SMILES string into Atom-in-SMILES tokens.atomInSmiles.decodeConverts an Atom-in-SMILES tokens into SMILES string.atomInSmiles.similarityCalcuates Tanimoto coefficient of two Atom-inSMILSE tokens.importatomInSmilessmiles='NCC(=O)O'# SMILES -> atom-in-SMILESais_tokens=atomInSmiles.encode(smiles)# '[NH2;!R;C] [CH2;!R;CN] [C;!R;COO] ( = [O;!R;C] ) [OH;!R;C]'# atom-in-SMILES -> SMILESdecoded_smiles=atomInSmiles.decode(ais_tokens)#'NCC(=O)O'assertsmiles==decoded_smilesNOTE:By default, it first canonicalizes the input SMILES. In order to get atom-in-Smiles tokens with the same order of SMILES, the input SMILES should be provided with atom map numbers.fromrdkit.ChemimportMolFromSmiles,MolToSmilesimportatomInSmilesimportatomInSmiles# ensuring the order of SMILES in atom-in-SMILES.smiles='NCC(=O)O'mol=MolFromSmiles(smiles)random_smiles=MolToSmiles(mol,doRandom=True)# e.g 'C(C(=O)O)N'# mapping atomID into SMILES srtingtmp=MolFromSmiles(random_smiles)foratomintmp.GetAtoms():atom.SetAtomMapNum(atom.GetIdx())smiles_1=MolToSmiles(tmp)# 'C([C:1](=[O:2])[OH:3])[NH2:4]'# SMILES -> atom-in-SMILESais_tokens_1=atomInSmiles.encode(smiles_1,with_atomMap=True)# '[CH2;!R;CN] ( [C;!R;COO] ( = [O;!R;C] ) [OH;!R;C] ) [NH2;!R;C]'# atom-in-SMILES -> SMILESdecoded_smiles_1=atomInSmiles.decode(ais_tokens_1)# 'C(C(=O)O)N'assertrandom_smiles==decoded_smiles_1Implementations & ResultsImplementationItemsDescriptionSingle-step retrosynthesispython src/predict.pyto conduct an inference with the trained model--model_type(SMILES,SELFIES,DeepSmiles,SmilesPE,AIS)--checkpoint_namename of the checkpoint filecheckpoints files--inputTokenized input sequenceMolecular Property PredictionMolecular-property-prediction.ipynbMoleculeNet: Classification (ESOL, FreeSolv, Lipo.), Regression (BBBP, BACE, HIV)Normalized repetition rateNormalized-Repetition-Rates.ipynbNatural products, drugs, metal complexes, lipids, stereoids, isomersFingerprint nature of AISAIS-as-fingerprint.ipynbAIS fingerprint resolutionSingle-token repetition (rep-l)rep-l_USPTO50k.ipynbUSPTO-50K, retrosynthetic translationsinput-output equivalent mappingGDB13-results.ipynbAugmented subset ofGDB-13, noncanon-2-canon translationsFor example, in retrosynthesis task:pythonsrc/predict.py--model_typeAIS--checkpoint_nameAIS_checkpoint.pth--input='[CH3;!R;O] [O;!R;CC] [C;!R;COO] ( = [O;!R;C] ) [c;R;CCS] 1 [cH;R;CC] [c;R;CCC] ( [CH2;!R;CC] [CH2;!R; CC] [CH2;!R;CC] [c;R;CCN] 2 [cH;R;CC] [c;R;CCC] 3 [c;R;CNO] ( = [O;!R;C] ) [nH;R;CC] [c;R;NNN] ( [NH2 ;!R;C] ) [n;R;CC] [c;R;CNN] 3 [nH;R;CC] 2 ) [cH;R;CS] [s;R;CC] 1'LicenseThis work is licensed under aCreative Commons Attribution-ShareAlike 4.0 International License.