Skip to content

PyCAOS/CAOS

Repository files navigation

CAOS - Computer Assisted Organic Synthesis (in Python!)

Build status Coverage Status Documentation Status

CAOS is a useful tool for many organic chemists, but is often a hard one to use in practice. This library will seek to provide an easy method of predicting reactions.

Documentation

Is available at readthedocs.org.

Examples

Simple reactions can be performed in this way

from CAOS.dispatch import react
from CAOS.structures.molecule import Molecule

acid = Molecule(
    {'a1': 'H', 'a2': 'H', 'a3': 'H', 'a4': 'O'},
    {'b1': {'nodes': ('a1', 'a4'), 'order': 1},
     'b2': {'nodes': ('a2', 'a4'), 'order': 1},
     'b3': {'nodes': ('a3', 'a4'), 'order': 1}
    },
    **{'id': 'Hydronium'}
)

base = Molecule(
    {'a1': 'H', 'a2': 'O'},
    {'b1': {'nodes': ('a1', 'a2'), 'order': 1}},
    **{'id': 'Hydroxide'}
)

conditions = {
    'pkas': {'Hydronium': -1.74, 'Hydroxide': 15.7},
    'pka_points': {'Hydronium': 'a1', 'Hydroxide': 'a2'}
}

products = react([acid, base], conditions)

In this case, based on the information in the molecules and the conditions, the system will predict an acid base reaction that results in the creation of two water molecules and no salt.

Additionally, user-defined reaction mechanisms can be added to the system.

# aqueous_mechanism.py
from CAOS.dispatch import register_reaction_mechanism

def aqueous(reactants, conditions):
    return conditions.get('aqeuous', False)

@register_reaction_mechanism([aqueous])
def some_mechanism(reactants, conditions):
    # do something
    return products

# reaction.py
import aqueous_mechanism
from CAOS.dispatch import react
from CAOS.structures.molecule import Molecule

m1 = Molecule(...)
m2 = Molecule(...)
conditions = {'aqueous': True}

products = react([m1, m2], conditions)

Here the system would use the aqueous mechanism that you have defined, because the conditions match the aqueous requirement the mechanism was decorated with.

The system is under active development, and the goal is to eventually take as much of the work out of the hands of the user.

Todos:

  • [X] Add CI
  • [X] Add reaction registration and dispatch
  • [ ] Add loading molecules
  • [X] Add molecule inspection
  • [ ] Add common requirements functions
  • [ ] ???

CAOS is still in early stages of development. Information will be added as it becomes available.

Motivation

This is a project for my Fall 2015 DSLs class. It is loosely based off of a previous project however with the intent of being more modular, extensible, and language-like.

Licensing

CAOS is licensed using the MIT License.