Skip to content

LegoGram: optimized molecular grammars for new molecules discovery

License

Notifications You must be signed in to change notification settings

sailfish009/LegoGram

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegoGram - molecular grammars for the generation of chemical structures by deep learning

Molecular grammar is a new chemical representation designed to provide faultless generation of organic structures

Installation

pip install git+https://github.com/sergsb/LegoGram.git

Quick Start

from legogram import LegoGram, pretrained
model = LegoGram(load=pretrained.M_250k)

Encode and decode

mol = 'COC(=O)Cc1csc(NC(=O)Cc2coc3cc(C)ccc23)n1'
encoded = model.encode(mol)`
model.decode(encoded) == "COC(=O)Cc1csc(NC(=O)Cc2coc3cc(C)ccc23)n1" #It's a toy example. In production compare by InChI
>>True

Encode with compression

mol = 'COC(=O)Cc1csc(NC(=O)Cc2coc3cc(C)ccc23)n1'
noncompressed = model.encode(mol)
compressed    = model.encode(mol,optimize=True)
print("SMILES len = {}, uncomressed grammar = {}, comressed grammar = {}".format(len(mol),len(noncompressed),len(compressed))
>> SMILES len = 40, uncomressed grammar = 26, comressed grammar = 14

Create you own grammar

model = legogram.LegoGram(smiles="legogram/data/250k_rndm_zinc_drugs_clean.smi", optimize_limit=100)

Check source code for documentation: "legogram.py" for base interface, "apps/" for usage plugins.

Docs and Citation

This library was described in my PhD Thesis (Chapter 6). Sosnin, Sergey (2021): Exploration of Chemical Space by Machine Learning. figshare. Thesis. https://doi.org/10.6084/m9.figshare.14160683.v1

About

LegoGram: optimized molecular grammars for new molecules discovery

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%