Git Product home page Git Product logo

legogram's Introduction

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_kekulized_grammar)

Encode and decode

encoded = model.encode("COC(=O)CC1=CSC(NC(=O)CC2=COC3=CC(C)=CC=C23)=N1")
model.decode(encoded) == "COC(=O)CC1=CSC(NC(=O)CC2=COC3=CC(C)=CC=C23)=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

legogram's People

Contributors

sergsb avatar

Stargazers

Jeff Carpenter avatar  avatar Abdullah Ahmad avatar François Bérenger avatar Mikhail Andronov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.