#!/usr/bin/env python
# encoding: utf-8

name = "ketoenol/groups"
shortDesc = ""
longDesc = """
Sulfur was added to this family, and is treated the same as oxygen.
Ideally we would like to branch this into a new family "R=RSR <=> RRR=S"
once relevant kinetic data is available
"""

template(reactants=["Root"], products=["ketone"], ownReverse=False)

reverse = "Ketone_To_Enol"
reversible = True

reactantNum = 1

productNum = 1

autoGenerated = True

recipe(actions=[
    ['CHANGE_BOND', '*1', -1, '*2'],
    ['CHANGE_BOND', '*2', 1, '*3'],
    ['BREAK_BOND', '*3', 1, '*4'],
    ['FORM_BOND', '*4', 1, '*1'],
])

boundaryAtoms = ["*2", "*3"]

entry(
    index = 0,
    label = "Root",
    group = 
"""
1 *2 R!H   u0 {2,S} {3,D}
2 *3 [O,S] u0 {1,S} {4,S}
3 *1 R!H   u0 {1,D}
4 *4 R     u0 {2,S}
""",
    kinetics = None,
)

entry(
    index = 1,
    label = "Root_3R!H->C",
    group = 
"""
1 *2 C u0 {2,S} {3,D}
2 *3 O u0 {1,S} {4,S}
3 *1 C u0 {1,D}
4 *4 R u0 {2,S}
""",
    kinetics = None,
)

entry(
    index = 2,
    label = "Root_3R!H->C_4R->C",
    group = 
"""
1 *2 C u0 {2,S} {3,D}
2 *3 O u0 {1,S} {4,S}
3 *1 C u0 {1,D}
4 *4 C u0 {2,S}
""",
    kinetics = None,
)

entry(
    index = 3,
    label = "Root_3R!H->C_N-4R->C",
    group = 
"""
1 *2 C u0 {2,S} {3,D}
2 *3 O u0 {1,S} {4,S}
3 *1 C u0 {1,D}
4 *4 H u0 {2,S}
""",
    kinetics = None,
)

entry(
    index = 4,
    label = "Root_3R!H->C_N-4R->C_Ext-1R!H-R",
    group = 
"""
1 *2 C   u0 r0 {2,S} {3,D} {5,[S,D,T,B]}
2 *3 O   u0 r0 {1,S} {4,S}
3 *1 C   u0 r0 {1,D}
4 *4 H   u0 r0 {2,S}
5    R!H ux {1,[S,D,T,B]}
""",
    kinetics = None,
)

entry(
    index = 5,
    label = "Root_N-3R!H->C",
    group = 
"""
1 *2 C u0 {2,S} {3,D}
2 *3 O u0 {1,S} {4,S}
3 *1 S u0 {1,D}
4 *4 H u0 {2,S}
""",
    kinetics = None,
)

entry(
    index = 6,
    label = "Root_N-3R!H->C_Ext-1R!H-R",
    group = 
"""
1 *2 C u0 {2,S} {3,D} {5,S}
2 *3 O u0 {1,S} {4,S}
3 *1 S u0 {1,D}
4 *4 H u0 {2,S}
5    C u0 {1,S}
""",
    kinetics = None,
)

entry(
    index = 7,
    label = "Root_N-3R!H->C_Ext-1R!H-R_Ext-5R!H-R",
    group = 
"""
1 *2 C   u0 r0 {2,S} {3,D} {5,S}
2 *3 O   u0 r0 {1,S} {4,S}
3 *1 S   u0 r0 {1,D}
4 *4 H   u0 r0 {2,S}
5    C   u0 r0 {1,S} {6,[S,D,T,B]}
6    R!H ux {5,[S,D,T,B]}
""",
    kinetics = None,
)

tree(
"""
L1: Root
    L2: Root_3R!H->C
        L3: Root_3R!H->C_4R->C
        L3: Root_3R!H->C_N-4R->C
            L4: Root_3R!H->C_N-4R->C_Ext-1R!H-R
    L2: Root_N-3R!H->C
        L3: Root_N-3R!H->C_Ext-1R!H-R
            L4: Root_N-3R!H->C_Ext-1R!H-R_Ext-5R!H-R
"""
)

