introvoyz041 commited on
Commit
be59fdd
·
verified ·
1 Parent(s): e258c10

Migrated from GitHub

Browse files
data/ClickReaction/BaseReaction.py ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import ClassVar, Dict, List, Iterable
2
+ import re
3
+
4
+ try:
5
+ from rdkit import Chem
6
+ from rdkit.Chem import AllChem
7
+ from rdkit.Chem.rdchem import Mol
8
+ from rdkit.Chem.rdChemReactions import ChemicalReaction
9
+ from rdkit.Chem import AllChem
10
+ except ModuleNotFoundError:
11
+ print("This module requires rdkit to run.")
12
+ exit(-1)
13
+
14
+ from . import Exceptions
15
+
16
+
17
+ Reactant = Mol
18
+ Reactants = Dict[str, Reactant]
19
+
20
+
21
+ class BaseReaction:
22
+ """
23
+ Abstract reaction class to provide common implementations for all reactions.
24
+ """
25
+
26
+ """ Dictionary of reactants """
27
+ _reactants: Reactants
28
+ """ Smarts used by the implementing class"""
29
+ _smarts: ClassVar[str]
30
+ """ rdkit ChemicalReaction instance created from the smarts. """
31
+ _rdReaction: ClassVar[ChemicalReaction]
32
+
33
+ reactant_names = ClassVar[List[str]]
34
+
35
+ def __runReaction__(self, reactants: Reactants) -> List[List[Mol]]:
36
+ """
37
+ Returns all products of all product sets.
38
+
39
+ :return: A list of all product sets.
40
+ """
41
+ raise NotImplementedError("You must implement __runReaction__")
42
+
43
+ @classmethod
44
+ def set_reaction_smarts(cls, smarts: str) -> None:
45
+ """
46
+ Sets the reaction smarts and creates the rdkit reaction from it.
47
+
48
+ :param smarts: A smarts string. All whitespace will be removed.
49
+ """
50
+ cls._smarts = re.sub(r'\s+', '', smarts)
51
+ cls._rdReaction = AllChem.ReactionFromSmarts(cls._smarts)
52
+
53
+ def set_reactants(self, reactants: Reactants):
54
+ """
55
+ Sets the reactants.
56
+
57
+ :param reactants: A dictionary where each key-value pair associates a reactant name with the corresponding mol.
58
+ :return:
59
+
60
+ Example:
61
+ AmideCoupling.set_reactants({"amine": amine_molecule, "acid": acid_molecule})
62
+ """
63
+ self._reactants = reactants
64
+
65
+ def get_reactants(self) -> Reactants:
66
+ """
67
+ Returns the reactants as a dictionary, where each key-value pair associates a reactant name with the
68
+ corresponding mol. See set_reactants.
69
+
70
+ :return:
71
+ """
72
+ return self._reactants
73
+
74
+ def get_products(self, symmetrical_as_one: bool = False) -> List[Mol]:
75
+ """
76
+ Returns a list of all possible products.
77
+
78
+ :param symmetrical_as_one: Set to true if symmetrical products should get reduced to one.
79
+ :return:
80
+ """
81
+ productSets = self.__runReaction__(self.get_reactants())
82
+
83
+ if productSets is None:
84
+ raise Exception("No product set was returned.")
85
+ elif len(productSets) == 0:
86
+ raise Exceptions.NoProductError("Reaction {} gave no product.".format(type(self)))
87
+
88
+ # Retrieve first product of all product sets
89
+ products = []
90
+ productSmiles = []
91
+ for p in productSets:
92
+ # Sanitize product from reaction fragments.
93
+ AllChem.SanitizeMol(p[0])
94
+
95
+ if symmetrical_as_one:
96
+ smiles = AllChem.MolToSmiles(p[0])
97
+
98
+ if smiles in productSmiles:
99
+ continue
100
+ else:
101
+ productSmiles.append(smiles)
102
+
103
+ products.append(p[0])
104
+
105
+ return products
106
+
107
+ def get_product(self, symmetrical_as_one: bool = False) -> Mol:
108
+ """
109
+ Returns one product and raises an exception if multiple products are possible.
110
+
111
+ :param symmetrical_as_one: Set to true to remove all but one instance of identical products.
112
+ :return:
113
+ """
114
+
115
+ # Get all possible products
116
+ products = self.get_products(symmetrical_as_one=symmetrical_as_one)
117
+
118
+ # More than one product is unexpected, raise an error to make the user aware.
119
+ if len(products) > 1:
120
+ raise Exceptions.AmbiguousProductError("Reaction {} gave more than one product sets: {}".format(type(self), [Chem.MolToSmiles(x) for x in products]))
121
+
122
+ return products[0]
data/ClickReaction/Exceptions.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ class ClickException(Exception):
3
+ """
4
+ Base exception for the ClickReaction package.he
5
+ """
6
+ pass
7
+
8
+
9
+ class NoProductError(ClickException):
10
+ """
11
+ Error raised if a reaction does not give any product.
12
+ """
13
+ pass
14
+
15
+
16
+ class AmbiguousProductError(ClickException):
17
+ """
18
+ Gets raised if a reaction leads unexpectedly to one or more products.
19
+ """
20
+ pass
data/ClickReaction/Reactions/AlkalineEsterHydrolysis.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class AlkalineEsterHydrolysis(BaseReaction):
5
+ """
6
+ Hydrolysis of typical esters that can be removed under alkaline conditions.
7
+
8
+ Hydrolyses:
9
+ - methyl esters
10
+ - ethyl esters
11
+
12
+ Does not hydrolyse:
13
+ - benzyl esters
14
+ - tBut esters
15
+
16
+ amine-boc -> amine
17
+ """
18
+
19
+ reactant_names = ["ester"]
20
+
21
+ def __init__(self, ester: Reactant):
22
+ self.set_reactants({
23
+ "ester": ester,
24
+ })
25
+
26
+ def __runReaction__(self, reactants: Reactants):
27
+ return self._rdReaction.RunReactants((reactants["ester"], ))
28
+
29
+
30
+ smarts = """
31
+ [CX3:1](=[OX1:2])
32
+ -[OX2:3]
33
+ -[$([CH3]),$([CH2]-[CH3])]
34
+
35
+ >>
36
+
37
+ [C:1](=[O:2])-[O:3]
38
+ """
39
+
40
+ AlkalineEsterHydrolysis.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/AmideCoupling.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class AmideCoupling(BaseReaction):
5
+ """
6
+ Amide coupling reaction to form amides.
7
+
8
+ Does not work with anilines.
9
+
10
+ amine + carboxylic acid -> Amide
11
+ """
12
+
13
+ reactant_names = ["amine", "acid"]
14
+
15
+ def __init__(self, amine: Reactant, acid: Reactant):
16
+ self.set_reactants({
17
+ "amine": amine,
18
+ "acid": acid,
19
+ })
20
+
21
+ def __runReaction__(self, reactants: Reactants):
22
+ return self._rdReaction.RunReactants((reactants["amine"], reactants["acid"]))
23
+
24
+
25
+ smarts = """
26
+ [
27
+ $([NX3H3]),
28
+ $([NX4H4]),
29
+ $([NX3H2]-[CX4]),
30
+ $([NX4H3]-[CX4]),
31
+ $([NX3H1](-[CX4])(-[CX4])),
32
+ $([NX4H2](-[CX4])(-[CX4]))
33
+ :1]
34
+
35
+ .
36
+
37
+ [C:2]
38
+ (=[OX1:3])
39
+ -[
40
+ $([OX2]-N1C(=O)CCC1(=O)),
41
+ $([OX2]-c1c(-F)c(-F)c(-F)c(-F)c1(-F)),
42
+ $([OX2]-c1ccc(-N(~O)(~O))cc1),
43
+ $([OX2H1]),
44
+ $([O-X1])
45
+ ]
46
+
47
+ >>
48
+
49
+ [*+0:1]-[*:2](=[*:3])
50
+ """
51
+
52
+ AmideCoupling.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/AmideCouplingWithAnilines.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class AmideCouplingWithAnilines(BaseReaction):
5
+ """
6
+ Amide coupling reaction to form amides, does also include anilines.
7
+
8
+ amine + carboxylic acid -> Amide
9
+ """
10
+
11
+ reactant_names = ["amine", "acid"]
12
+
13
+ def __init__(self, amine: Reactant, acid: Reactant):
14
+ self.set_reactants({
15
+ "amine": amine,
16
+ "acid": acid,
17
+ })
18
+
19
+ def __runReaction__(self, reactants: Reactants):
20
+ return self._rdReaction.RunReactants((reactants["amine"], reactants["acid"]))
21
+
22
+
23
+ smarts = """
24
+ [
25
+ $([NX3H3]),
26
+ $([NX4H4]),
27
+ $([NX3H2]-[CX4]),
28
+ $([NX4H3]-[CX4]),
29
+ $([NX3H1](-[CX4])(-[CX4])),
30
+ $([NX4H2](-[CX4])(-[CX4])),
31
+ $([NX3H2]-[cX3]),
32
+ $([NX4H3]-[cX3]),
33
+ $([NX3H1](-[cX3])(-[CX4])),
34
+ $([NX4H2](-[cX3])(-[CX4])),
35
+ $([NX3H1](-[cX3])(-[cx3])),
36
+ $([NX4H2](-[cX3])(-[cx3]))
37
+ :1]
38
+
39
+ .
40
+
41
+ [C:2]
42
+ (=[OX1:3])
43
+ -[
44
+ $([OX2]-N1C(=O)CCC1(=O)),
45
+ $([OX2]-c1c(-F)c(-F)c(-F)c(-F)c1(-F)),
46
+ $([OX2]-c1ccc(-N(~O)(~O))cc1),
47
+ $([OX2H1]),
48
+ $([O-X1])
49
+ ]
50
+
51
+ >>
52
+
53
+ [*+0:1]-[*:2](=[*:3])
54
+ """
55
+
56
+ AmideCouplingWithAnilines.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/BocRemoval.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class BocRemoval(BaseReaction):
5
+ """
6
+ Removal of Boc from amines
7
+
8
+ amine-boc -> amine
9
+ """
10
+
11
+ reactant_names = ["bocamine"]
12
+
13
+ def __init__(self, bocamine: Reactant):
14
+ self.set_reactants({
15
+ "bocamine": bocamine,
16
+ })
17
+
18
+ def __runReaction__(self, reactants: Reactants):
19
+ return self._rdReaction.RunReactants((reactants["bocamine"], ))
20
+
21
+
22
+ smarts = """
23
+ [#7:1]
24
+ -C(=O)
25
+ -O
26
+ -[$(C(-[CH3])(-[CH3])(-[CH3]))]
27
+
28
+ >>
29
+
30
+ [*:1]
31
+ """
32
+
33
+ BocRemoval.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/CuAAC.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class CuAAC(BaseReaction):
5
+ """
6
+ Copper-catalyzed alkyne azide cycloaddition to give the 1,4 regioisomer.
7
+
8
+ alkyne + azide -> 1,4-triazole
9
+ """
10
+
11
+ reactant_names = ["alkyne", "azide"]
12
+
13
+ def __init__(self, alkyne: Reactant, azide: Reactant):
14
+ self.set_reactants({
15
+ "alkyne": alkyne,
16
+ "azide": azide,
17
+ })
18
+
19
+ def __runReaction__(self, reactants: Reactants):
20
+ return self._rdReaction.RunReactants((reactants["alkyne"], reactants["azide"]))
21
+
22
+
23
+ smarts = """
24
+ [C:1]#[$([CH1]),$(C-[I]):2]
25
+
26
+ .
27
+
28
+ [$([#6]-N=[N+]=[-N]),$([#6]-[N-]-[N+]#N):3]-N~N~N
29
+
30
+ >>
31
+
32
+ [*:3]n1[c:2][c:1]nn1
33
+ """
34
+
35
+ CuAAC.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/FmocRemoval.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class FmocRemoval(BaseReaction):
5
+ """
6
+ Removal of Fmoc from amines
7
+
8
+ amine-fmoc -> amine
9
+ """
10
+
11
+ reactant_names = ["fmocamine"]
12
+
13
+ def __init__(self, fmocamine: Reactant):
14
+ self.set_reactants({
15
+ "fmocamine": fmocamine,
16
+ })
17
+
18
+ def __runReaction__(self, reactants: Reactants):
19
+ return self._rdReaction.RunReactants((reactants["fmocamine"], ))
20
+
21
+
22
+ smarts = """
23
+ [#7:1]
24
+ -C(=O)
25
+ -O
26
+ -C
27
+ -[$([C]1[cR2][cR2][cR2][cR2]1)]
28
+
29
+ >>
30
+
31
+ [*:1]
32
+ """
33
+
34
+ FmocRemoval.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/SulfonAmideFormation.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class SulfonAmideFormation(BaseReaction):
5
+ """
6
+ Formation of sulfon amides from sulfonyl halogenides and amines
7
+
8
+ amine + sulfonylhalogenide -> sulfonamide
9
+ """
10
+
11
+ reactant_names = ["amine", "sulfonylhalogenide"]
12
+
13
+ def __init__(self, amine: Reactant, sulfonylhalogenide: Reactant):
14
+ self.set_reactants({
15
+ "amine": amine,
16
+ "sulfonylhalogenide": sulfonylhalogenide,
17
+ })
18
+
19
+ def __runReaction__(self, reactants: Reactants):
20
+ return self._rdReaction.RunReactants((reactants["amine"], reactants["sulfonylhalogenide"]))
21
+
22
+
23
+ smarts = """
24
+ [
25
+ $([NX3H3]),
26
+ $([NX4H4]),
27
+ $([NX3H2]-[#6]),
28
+ $([NX4H3]-[#6]),
29
+ $([#7X3H1]([#6])([#6])),
30
+ $([#7X4H2]([#6])([#6]))
31
+ :1]
32
+
33
+ .
34
+
35
+ [#6:2]-[$([SX4](~[OX1H0])(~[OX1H0]))]-[F,Cl,Br,I;X1]
36
+
37
+ >>
38
+
39
+ [#7+0:1]-[S+2](-[O-])(-[O-])-[*:2]
40
+ """
41
+
42
+ SulfonAmideFormation.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/SuzukiMiyaura.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.BaseReaction import BaseReaction, Reactant, Reactants
2
+
3
+
4
+ class SuzukiMiyaura(BaseReaction):
5
+ """
6
+ Formation of C-C bonds from a boronic acid or ester and an aromatic halogenide (except fluorine).
7
+
8
+ boronic acid + arylhalogenide -> C-C bond formation
9
+ boronic ester + arylhalogenide -> C-C bond formation
10
+ trifluoroborates + arylhalogenide -> C-C bond formation
11
+ """
12
+
13
+ reactant_names = ["boronate", "halogenide"]
14
+
15
+ def __init__(self, boronate: Reactant, halogenide: Reactant):
16
+ self.set_reactants({
17
+ "boronate": boronate,
18
+ "halogenide": halogenide,
19
+ })
20
+
21
+ def __runReaction__(self, reactants: Reactants):
22
+ return self._rdReaction.RunReactants((reactants["boronate"], reactants["halogenide"]))
23
+
24
+
25
+ smarts = """
26
+ [#6:1]-[$([B](-O)(-O)),$([B](-F)(-F)(-F))]
27
+ .
28
+
29
+ [c:2]-[I,Br,Cl]
30
+
31
+ >>
32
+
33
+ [*:1]-[*:2]
34
+ """
35
+
36
+ SuzukiMiyaura.set_reaction_smarts(smarts)
data/ClickReaction/Reactions/__init__.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions.AmideCoupling import AmideCoupling
2
+ from ClickReaction.Reactions.AmideCouplingWithAnilines import AmideCouplingWithAnilines
3
+ from ClickReaction.Reactions.CuAAC import CuAAC
4
+ from ClickReaction.Reactions.SulfonAmideFormation import SulfonAmideFormation
5
+
6
+ # Cross couplings
7
+ from ClickReaction.Reactions.SuzukiMiyaura import SuzukiMiyaura
8
+
9
+ # Protecting group removals
10
+ from ClickReaction.Reactions.FmocRemoval import FmocRemoval
11
+ from ClickReaction.Reactions.BocRemoval import BocRemoval
12
+ from ClickReaction.Reactions.AlkalineEsterHydrolysis import AlkalineEsterHydrolysis
13
+
14
+ # All reactions as a dictionary.
15
+ all_reactions = {
16
+ "AmideCoupling": AmideCoupling,
17
+ "AmideCouplingWithAnilines": AmideCouplingWithAnilines,
18
+ "CuAAC": CuAAC,
19
+ "SulfonAmideFormation": SulfonAmideFormation,
20
+ "SuzukiMiyaura": SuzukiMiyaura,
21
+ "FmocRemoval": FmocRemoval,
22
+ "BocRemoval": BocRemoval,
23
+ "AlkalineEsterHydrolysis": AlkalineEsterHydrolysis,
24
+ }
data/ClickReaction/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from .Reactions import *
data/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2020 Basilius Sauter <basilius.sauter@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Click
2
+
3
+ Click is a collection of pre-made and tested reaction patterns to use with RDKit molecules.
4
+ The reactions can be used to sequentially modify a molecule, or to create combinatorial
5
+ libraries. Click is only doing the reaction as you've specified and does *not* check
6
+ if the reaction would work.
7
+
8
+ ## Requirements
9
+
10
+ * RDKit (version >= 2019.03)
11
+ * Python (version >= 3.6)
12
+
13
+ ## Installation
14
+ To install Click, run
15
+
16
+ `pip install ClickReaction`
17
+
18
+ ## Usage
19
+
20
+ Many examples can be found in the [tests folder](https://github.com/Gillingham-Lab/Click/tree/master/tests).
21
+
22
+ ### Boc removal
23
+
24
+ ```python
25
+ from rdkit import Chem
26
+ from ClickReaction import BocRemoval
27
+
28
+ boc_protected_amine = Chem.MolFromSmiles("CNC(OC(C)(C)C)=O")
29
+
30
+ reaction = BocRemoval(bocamine=boc_protected_amine)
31
+ product = reaction.get_product()
32
+
33
+ assert "CN" == Chem.MolToSmiles(product)
34
+ ```
35
+
36
+ ### Click Reaction
37
+
38
+ ```python
39
+ from rdkit import Chem
40
+ from ClickReaction import CuAAC
41
+
42
+ alkyne = Chem.MolFromSmiles("c1ccccc1C#C")
43
+ azide = Chem.MolFromSmiles("C-[N-]-[N+]#N")
44
+
45
+ reaction = CuAAC(alkyne=alkyne, azide=azide)
46
+ product = reaction.get_product()
47
+
48
+ assert "Cn1cc(-c2ccccc2)nn1" == Chem.MolToSmiles(product)
49
+ ```
50
+
51
+ ## Supported reactions
52
+
53
+ ### Simple transformations
54
+
55
+ * Boc removal
56
+ * Fmoc removal
57
+ * Alkaline ester hydrolysis
58
+
59
+ ### Bimolecular reactions
60
+
61
+ * Amide coupling (with or without anilines)
62
+ * CuAAC
63
+ * Sulfon amide formation from amines and sulfonyl chlorides
64
+ * Suzuki-Miyaura cross coupling
data/requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ rdkit
data/setup.py ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import setuptools
2
+
3
+ with open("README.md", "r") as fh:
4
+ long_description = fh.read()
5
+
6
+ setuptools.setup(
7
+ name="ClickReaction",
8
+ version="0.3.1",
9
+ author="Basilius Sauter",
10
+ author_email="basilius.sauter@gmail.com",
11
+ description="A collection of chemical reaction formulations for use with rdkit. Requires rdkit.",
12
+ long_description=long_description,
13
+ long_description_content_type="text/markdown",
14
+ url="https://github.com/Gillingham-Lab/Click",
15
+ packages=setuptools.find_packages(),
16
+ classifiers=[
17
+ "Programming Language :: Python :: 3",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ "Intended Audience :: Science/Research",
21
+ "Topic :: Scientific/Engineering :: Chemistry",
22
+ "Topic :: Scientific/Engineering :: Bio-Informatics",
23
+ "Topic :: Software Development :: Libraries :: Python Modules",
24
+ "Topic :: Utilities",
25
+ ],
26
+ python_requires='>=3.6',
27
+ )
data/testrun.sh ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ #/usr/bin/bash
2
+ python -m unittest discover -s tests
data/tests/TestHelper.py ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+ from rdkit.Chem import MolFromSmiles as fromSmiles
3
+ from rdkit.Chem import MolToSmiles as toSmiles
4
+ from typing import Sequence, Tuple, Union, Type
5
+
6
+ import ClickReaction
7
+ import ClickReaction.Exceptions
8
+ import ClickReaction.BaseReaction
9
+
10
+ Reactants = Sequence[str]
11
+ ReactantNames = Sequence[str]
12
+ NoProductTestCase = Reactants
13
+ OneProductTestCase = Tuple[Reactants, str]
14
+ MultipleProductTestCase = Tuple[Reactants, Sequence[str]]
15
+ AnyProductTestCase = Union[NoProductTestCase, OneProductTestCase, MultipleProductTestCase]
16
+
17
+
18
+ class ReactionTestCase(unittest.TestCase):
19
+ def set_reaction(self, reaction: Type):
20
+ self.reaction = reaction
21
+
22
+ def prepare_testcases(self,
23
+ case: AnyProductTestCase,
24
+ reactant_names: ReactantNames,
25
+ with_product: bool = True,
26
+ ):
27
+ product_expected = None
28
+
29
+ if with_product is True:
30
+ # Product is always the last one - we use here to canonicalize given smiles.
31
+
32
+ if isinstance(case[1], str):
33
+ product_expected = toSmiles(fromSmiles(case[1]))
34
+ else:
35
+ product_expected = [toSmiles(fromSmiles(x)) for x in case[1]]
36
+
37
+ reactants = case[0]
38
+ else:
39
+ reactants = case
40
+
41
+ # Convert reactants to objects from smiles
42
+ reactants = [fromSmiles(x) for x in reactants]
43
+
44
+ # create a dictonary
45
+ reactants = {reactant_names[x]: reactants[x] for x in range(len(reactants))}
46
+
47
+ return product_expected, reactants
48
+
49
+ def _test_one_product(self,
50
+ tests: Sequence[OneProductTestCase],
51
+ reactant_names: ReactantNames,
52
+ symmetrical_as_one: bool = False,
53
+ ):
54
+ """ Tests for giving exactly one expected product. """
55
+ for case in tests:
56
+ with self.subTest(case=case):
57
+ product_expected, reactants = self.prepare_testcases(case, reactant_names)
58
+
59
+ # Run the reaction
60
+ product = self.reaction(**reactants).get_product(symmetrical_as_one=symmetrical_as_one)
61
+
62
+ # Test if there was any product
63
+ self.assertIsNotNone(product)
64
+
65
+ # Test if the product is what we expected
66
+ product_smiles = toSmiles(product)
67
+ self.assertEqual(product_expected, product_smiles)
68
+
69
+ def _test_no_product(self,
70
+ tests: Sequence[NoProductTestCase],
71
+ reactant_names: ReactantNames,
72
+ symmetrical_as_one: bool = False,
73
+ ):
74
+ """ Tests for failing to give a product. """
75
+ for case in tests:
76
+ with self.subTest(case=case):
77
+ _, reactants = self.prepare_testcases(case, reactant_names, with_product=False)
78
+
79
+ with self.assertRaises(ClickReaction.Exceptions.NoProductError):
80
+ test_product = self.reaction(**reactants).get_product(symmetrical_as_one=symmetrical_as_one)
81
+
82
+ def _test_all_possible_products(self,
83
+ tests: Sequence[MultipleProductTestCase],
84
+ reactant_names: ReactantNames,
85
+ symmetrical_as_one: bool = False,
86
+ ):
87
+ """ Tests if all possible expected products are covered from one reaction. """
88
+ for case in tests:
89
+ with self.subTest(case=case):
90
+ products_expected, reactants = self.prepare_testcases(case, reactant_names)
91
+
92
+ # getProduct only expects 1 product - this must give an Exception
93
+ with self.assertRaises(ClickReaction.Exceptions.AmbiguousProductError):
94
+ product = self.reaction(**reactants).get_product()
95
+
96
+ # getProducts should be used instead.
97
+ products = self.reaction(**reactants).get_products(symmetrical_as_one=symmetrical_as_one)
98
+
99
+ products_found = 0
100
+ for p in products:
101
+ # Convert product to smiles
102
+ p_smiles = toSmiles(p)
103
+
104
+ self.assertIn(p_smiles, products_expected)
105
+ products_found += 1
106
+
107
+ self.assertEqual(products_found, len(products), "Not all products wer expected")
108
+ self.assertEqual(len(products), len(products_expected), "Mismatch between expected products and actual products.")
data/tests/test_AlkalineEsterHydrolysisTest.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions import AlkalineEsterHydrolysis
2
+ from tests import TestHelper
3
+
4
+
5
+ class AlkalineEsterHydrolysisTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["ester"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(AlkalineEsterHydrolysis)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Esters from formiates
14
+ (("C(=O)OC", ), "C(=O)O"),
15
+ (("C(=O)OCC", ), "C(=O)O"),
16
+
17
+ # acetates
18
+ (("CC(=O)OC", ), "CC(=O)O"),
19
+ (("CC(=O)OCC", ), "CC(=O)O"),
20
+ ]
21
+
22
+ self._test_one_product(reactants, self.reactant_names)
23
+
24
+ # Those tests should not give any product.
25
+ def test_no_product(self):
26
+ reactants = [
27
+ # tBu should not be removed
28
+ ("C(=O)OC(C)(C)C", ),
29
+
30
+ # Bn should not be removed
31
+ ("C(=O)OCc1ccccc1", ),
32
+ ]
33
+
34
+ self._test_no_product(reactants, self.reactant_names)
data/tests/test_AmideCoupling.py ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ClickReaction
2
+ from tests import TestHelper
3
+
4
+
5
+ class AmideCouplingTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["amine", "acid"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(ClickReaction.AmideCoupling)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Ammonia and ammonium with acetic acid
14
+ (("N", "OC(C)=O"), "O=C(C)N"),
15
+ (("[NH4+]", "OC(C)=O"), "O=C(C)N"),
16
+ (("N(-[H])(-[H])(-[H])", "OC(C)=O"), "O=C(C)N"),
17
+
18
+ # Primary amines with simple acids
19
+ (("CN", "OC=O"), "CNC=O"),
20
+ (("CCN", "OC(C)=O"), "O=C(C)NCC"),
21
+ (("CN", "OC(C1=CC=CC=C1)=O"), "O=C(C1=CC=CC=C1)NC"),
22
+ (("NC1=CC=CC(CN)=C1", "OC(C)=O"), "NC1=CC=CC(CNC(C)=O)=C1"),
23
+
24
+ # Secondary amines with simple acids
25
+ (("CNC", "OC(C)=O"), "O=C(C)N(C)C"),
26
+
27
+ # Primary ammonium with simple acids
28
+ (("CC[NH3+]", "OC(C)=O"), "O=C(C)NCC"),
29
+
30
+ # Secondary ammonium with simple acids
31
+ (("C[NH2+]C", "OC(C)=O"), "O=C(C)N(C)C"),
32
+
33
+ # Simple amine with carboxylate
34
+ (("CCN", "[O-]C(C)=O"), "O=C(C)NCC"),
35
+
36
+ # Secondary ammonium with carboxylate
37
+ (("C[NH2+]C", "[O-]C(C(C1=CC=CC=C1)(F)Cl)=O"), "O=C(C(C1=CC=CC=C1)(F)Cl)N(C)C"),
38
+
39
+ #
40
+ # Amine with active esters
41
+ #
42
+
43
+ # N-Hydroxysuccinimide
44
+ (("CCN", "CCC(ON1C(CCC1=O)=O)=O"), "CCC(NCC)=O"),
45
+ # N-Sulfo-Hydroxysuccinimide
46
+ (("CCN", "CCC(ON1C(CC(S(=O)(O)=O)C1=O)=O)=O"), "CCC(NCC)=O"),
47
+ # p-Nitrophenol
48
+ (("CCN", "CCC(OC1=CC=C([N+]([O-])=O)C=C1)=O"), "CCC(NCC)=O"),
49
+ # Pentafluorophenyl
50
+ (("CCN", "CCC(OC1=C(F)C(F)=C(F)C(F)=C1F)=O"), "CCC(NCC)=O"),
51
+
52
+ ]
53
+
54
+ self._test_one_product(reactants, self.reactant_names)
55
+
56
+ # Those tests should not give any product.
57
+ def test_no_product(self):
58
+ reactants = [
59
+ # No primary amide
60
+ ("NC(C)=O", "OC(C)=O"),
61
+ # No secondary amide
62
+ ("CC(NC)=O", "OC(C)=O"),
63
+ # No N-methyl urea
64
+ ("NC(NC)=O", "OC(C)=O"),
65
+ # No carbamates
66
+ ("O=C(OC)NC", "OC(C)=O"),
67
+ # No imides
68
+ ("CC(NC(C)=O)=O", "OC(C)=O"),
69
+ # No aniline
70
+ ("NC1=CC=CC=C1", "OC(C1=CC=CC=C1)=O"),
71
+ # No tertiary amines
72
+ ("CN(C)C", "OC(C)=O"),
73
+ # No guanosine
74
+ ("NC(=N)N", "OC(C)=O")
75
+ ]
76
+
77
+ self._test_no_product(reactants, self.reactant_names)
78
+
79
+ # This reactions should give multiple possible products
80
+ def test_if_get_products_returns_all_possible_products(self):
81
+ reactants = [
82
+ (("NCCNC", "OC(C)=O"), ("CNCCNC(C)=O", "NCCN(C(C)=O)C")),
83
+ (("CNCCNC", "OC(C)=O"), ("CNCCN(C)C(C)=O", "CNCCN(C)C(C)=O")),
84
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), ["OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"]*4),
85
+ ]
86
+
87
+ self._test_all_possible_products(reactants, self.reactant_names)
88
+
89
+ def test_if_get_products_returns_only_1_products_if_symmetrical_as_one_is_true(self):
90
+ reactants = [
91
+ (("NCCNC", "OC(C)=O"), ["CNCCNC(C)=O", "NCCN(C(C)=O)C"]),
92
+ (("CNCCNC", "OC(C)=O"), ["CNCCN(C)C(C)=O"]),
93
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), ["OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"]),
94
+ ]
95
+
96
+ self._test_all_possible_products(reactants, self.reactant_names, symmetrical_as_one=True)
97
+
98
+ def test_if_get_product_returns_the_symmetric_product_if_symmetrical_as_one_is_true(self):
99
+ reactants = [
100
+ (("CNCCNC", "OC(C)=O"), "CNCCN(C)C(C)=O"),
101
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), "OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"),
102
+ ]
103
+
104
+ self._test_one_product(reactants, self.reactant_names, symmetrical_as_one=True)
data/tests/test_AmideCouplingWithAnilines.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ClickReaction
2
+ from tests import TestHelper
3
+
4
+
5
+ class AmideCouplingWithAnilinesTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["amine", "acid"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(ClickReaction.AmideCouplingWithAnilines)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Ammonia and ammonium with acetic acid
14
+ (("N", "OC(C)=O"), "O=C(C)N"),
15
+ (("[NH4+]", "OC(C)=O"), "O=C(C)N"),
16
+ (("N(-[H])(-[H])(-[H])", "OC(C)=O"), "O=C(C)N"),
17
+
18
+ # Primary amines with simple acids
19
+ (("CN", "OC=O"), "CNC=O"),
20
+ (("CCN", "OC(C)=O"), "O=C(C)NCC"),
21
+ (("CN", "OC(C1=CC=CC=C1)=O"), "O=C(C1=CC=CC=C1)NC"),
22
+
23
+ # Secondary amines with simple acids
24
+ (("CNC", "OC(C)=O"), "O=C(C)N(C)C"),
25
+
26
+ # Primary ammonium with simple acids
27
+ (("CC[NH3+]", "OC(C)=O"), "O=C(C)NCC"),
28
+
29
+ # Secondary ammonium with simple acids
30
+ (("C[NH2+]C", "OC(C)=O"), "O=C(C)N(C)C"),
31
+
32
+ # Simple amine with carboxylate
33
+ (("CCN", "[O-]C(C)=O"), "O=C(C)NCC"),
34
+
35
+ # Secondary ammonium with carboxylate
36
+ (("C[NH2+]C", "[O-]C(C(C1=CC=CC=C1)(F)Cl)=O"), "O=C(C(C1=CC=CC=C1)(F)Cl)N(C)C"),
37
+
38
+ #
39
+ # Amine with active esters
40
+ #
41
+
42
+ # N-Hydroxysuccinimide
43
+ (("CCN", "CCC(ON1C(CCC1=O)=O)=O"), "CCC(NCC)=O"),
44
+ # N-Sulfo-Hydroxysuccinimide
45
+ (("CCN", "CCC(ON1C(CC(S(=O)(O)=O)C1=O)=O)=O"), "CCC(NCC)=O"),
46
+ # p-Nitrophenol
47
+ (("CCN", "CCC(OC1=CC=C([N+]([O-])=O)C=C1)=O"), "CCC(NCC)=O"),
48
+ # Pentafluorophenyl
49
+ (("CCN", "CCC(OC1=C(F)C(F)=C(F)C(F)=C1F)=O"), "CCC(NCC)=O"),
50
+
51
+ #
52
+ # Anilines
53
+ #
54
+
55
+ # No aniline
56
+ (("NC1=CC=CC=C1", "OC(C1=CC=CC=C1)=O"), "O=C(Nc1ccccc1)c1ccccc1"),
57
+ ]
58
+
59
+ self._test_one_product(reactants, self.reactant_names)
60
+
61
+ # Those tests should not give any product.
62
+ def test_no_product(self):
63
+ reactants = [
64
+ # No primary amide
65
+ ("NC(C)=O", "OC(C)=O"),
66
+ # No secondary amide
67
+ ("CC(NC)=O", "OC(C)=O"),
68
+ # No N-methyl urea
69
+ ("NC(NC)=O", "OC(C)=O"),
70
+ # No carbamates
71
+ ("O=C(OC)NC", "OC(C)=O"),
72
+ # No imides
73
+ ("CC(NC(C)=O)=O", "OC(C)=O"),
74
+ # No tertiary amines
75
+ ("CN(C)C", "OC(C)=O"),
76
+ # No guanosine
77
+ ("NC(=N)N", "OC(C)=O")
78
+ ]
79
+
80
+ self._test_no_product(reactants, self.reactant_names)
81
+
82
+ # This reactions should give multiple possible products
83
+ def test_if_get_products_returns_all_possible_products(self):
84
+ reactants = [
85
+ (("NCCNC", "OC(C)=O"), ("CNCCNC(C)=O", "NCCN(C(C)=O)C")),
86
+ (("CNCCNC", "OC(C)=O"), ("CNCCN(C)C(C)=O", "CNCCN(C)C(C)=O")),
87
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), ["OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"]*4),
88
+ ]
89
+
90
+ self._test_all_possible_products(reactants, self.reactant_names)
91
+
92
+ def test_if_get_products_returns_only_1_products_if_symmetrical_as_one_is_true(self):
93
+ reactants = [
94
+ (("NCCNC", "OC(C)=O"), ["CNCCNC(C)=O", "NCCN(C(C)=O)C"]),
95
+ (("CNCCNC", "OC(C)=O"), ["CNCCN(C)C(C)=O"]),
96
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), ["OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"]),
97
+ ]
98
+
99
+ self._test_all_possible_products(reactants, self.reactant_names, symmetrical_as_one=True)
100
+
101
+ def test_if_get_product_returns_the_symmetric_product_if_symmetrical_as_one_is_true(self):
102
+ reactants = [
103
+ (("CNCCNC", "OC(C)=O"), "CNCCN(C)C(C)=O"),
104
+ (("N", "OC(CN(CC(O)=O)CCN(CC(O)=O)CC(O)=O)=O"), "OC(CN(CC(O)=O)CCN(CC(N)=O)CC(O)=O)=O"),
105
+ ]
106
+
107
+ self._test_one_product(reactants, self.reactant_names, symmetrical_as_one=True)
data/tests/test_BocRemoval.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions import BocRemoval
2
+ from tests import TestHelper
3
+
4
+
5
+ class BocRemovalTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["bocamine"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(BocRemoval)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Boc from primary aliphatic amine
14
+ (("CNC(OC(C)(C)C)=O", ), "CN"),
15
+ # Boc from primary aniline
16
+ (("CC(OC(NC1=CC=CC=C1)=O)(C)C", ), "NC1=CC=CC=C1"),
17
+ # Boc from secondary aliphatic amines
18
+ (("CN(C)C(OC(C)(C)C)=O", ), "CNC"),
19
+ # Boc from secondary anilines
20
+ (("CC(OC(N(C1=CC=CC=C1)C2=CC=CC=C2)=O)(C)C", ), "C1(NC2=CC=CC=C2)=CC=CC=C1"),
21
+ # Boc from mixed anilines / aliphatic amines
22
+ (("CN(C(OC(C)(C)C)=O)C1=CC=CC=C1", ), "CNC1=CC=CC=C1"),
23
+ ]
24
+
25
+ self._test_one_product(reactants, self.reactant_names)
26
+
27
+ # Those tests should not give any product.
28
+ def test_no_product(self):
29
+ reactants = [
30
+ # Fmoc
31
+ ("CNC(OCC1C(C=CC=C2)=C2C3=C1C=CC=C3)=O", ),
32
+
33
+ # Benzyl
34
+ ("CNCC1=CC=CC=C1", ),
35
+
36
+ # Dimethylamine
37
+ ("CNC",),
38
+
39
+ # O-Methylcarbamates
40
+ ("CN(C(OC)=O)C", ),
41
+
42
+ # Ureas
43
+ ("CN(C(NC)=O)C", ),
44
+ ]
45
+
46
+ self._test_no_product(reactants, self.reactant_names)
data/tests/test_CuAAC.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ClickReaction
2
+ from tests import TestHelper
3
+
4
+
5
+ class CuAACTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["alkyne", "azide"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(ClickReaction.CuAAC)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # S
14
+ (("CC#C", "C-N=[N+]=[N-]"), "Cn1cc(C)nn1"),
15
+ (("CC#C", "C-[N-]-[N+]#N"), "Cn1cc(C)nn1"),
16
+ (("CC#CI", "C-[N-]-[N+]#N"), "Cn1c(I)c(C)nn1"),
17
+ (("c1ccccc1C#C", "C-[N-]-[N+]#N"), "Cn1cc(-c2ccccc2)nn1"),
18
+ ]
19
+
20
+ self._test_one_product(reactants, self.reactant_names)
21
+
22
+ def test_no_product(self):
23
+ reactants = [
24
+ # Non-terminal alkynes
25
+ ("CC#CC", "C-N=[N+]=[N-]"),
26
+ ("CC#Cc1ccccc1", "C-N=[N+]=[N-]"),
27
+ ("c1ccccc1C#Cc1ccccc1", "C-N=[N+]=[N-]"),
28
+ ("C1CCCC#CCC1", "C-N=[N+]=[N-]"),
29
+ ]
30
+
31
+ self._test_no_product(reactants, self.reactant_names)
32
+
33
+ def test_if_get_products_returns_all_possible_products(self):
34
+ reactants = [
35
+ (("C#CC#C", "C-N=[N+]=[N-]"), ("C#Cc1cn(C)nn1", "C#Cc1cn(C)nn1")),
36
+ (("C#CCC#CI", "C-N=[N+]=[N-]"), ("IC#CCc1cn(C)nn1", "C#CCC(N=NN1C)=C1I")),
37
+ ]
38
+
39
+ self._test_all_possible_products(reactants, self.reactant_names)
40
+
41
+ def test_if_get_products_returns_only_1_products_if_symmetrical_as_one_is_true(self):
42
+ reactants = [
43
+ (("C#C", "C-N=[N+]=[N-]"), ["Cn1ccnn1"]),
44
+ (("C#C", "C-[N-]-[N+]#N"), ["Cn1ccnn1"]),
45
+ ]
46
+
47
+ self._test_all_possible_products(reactants, self.reactant_names, symmetrical_as_one=True)
48
+
49
+ def test_if_get_product_returns_the_symmetric_product_if_symmetrical_as_one_is_true(self):
50
+ reactants = [
51
+ (("C#C", "C-N=[N+]=[N-]"), "Cn1ccnn1"),
52
+ (("C#C", "C-[N-]-[N+]#N"), "Cn1ccnn1"),
53
+ ]
54
+
55
+ self._test_one_product(reactants, self.reactant_names, symmetrical_as_one=True)
data/tests/test_FmocRemoval.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions import FmocRemoval
2
+ from tests import TestHelper
3
+
4
+
5
+ class FmocRemovalTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["fmocamine"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(FmocRemoval)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Fmoc from primary aliphatic amine
14
+ (("CNC(OCC1C(C=CC=C2)=C2C3=C1C=CC=C3)=O", ), "CN"),
15
+ # Fmoc from primary aniline
16
+ (("O=C(NC1=CC=CC=C1)OCC2C(C=CC=C3)=C3C4=C2C=CC=C4", ), "NC1=CC=CC=C1"),
17
+ # Fmoc from secondary aliphatic amines
18
+ (("CN(C)C(OCC1C(C=CC=C2)=C2C3=C1C=CC=C3)=O", ), "CNC"),
19
+ # Fmoc from secondary anilines
20
+ (("O=C(N(C1=CC=CC=C1)C2=CC=CC=C2)OCC3C(C=CC=C4)=C4C5=C3C=CC=C5", ), "C1(NC2=CC=CC=C2)=CC=CC=C1"),
21
+ # Fmoc from mixed anilines / aliphatic amines
22
+ (("CN(C(OCC1C(C=CC=C2)=C2C3=C1C=CC=C3)=O)C4=CC=CC=C4", ), "CNC1=CC=CC=C1"),
23
+ ]
24
+
25
+ self._test_one_product(reactants, self.reactant_names)
26
+
27
+ # Those tests should not give any product.
28
+ def test_no_product(self):
29
+ reactants = [
30
+ # Boc
31
+ ("CNC(OC(C)(C)C)=O", ),
32
+
33
+ # Benzyl
34
+ ("CNCC1=CC=CC=C1", ),
35
+
36
+ # Dimethylamine
37
+ ("CNC",),
38
+
39
+ # O-Methylcarbamates
40
+ ("CN(C(OC)=O)C", ),
41
+
42
+ # Ureas
43
+ ("CN(C(NC)=O)C", ),
44
+ ]
45
+
46
+ self._test_no_product(reactants, self.reactant_names)
data/tests/test_SulfonAmideFormation.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions import SulfonAmideFormation
2
+ from tests import TestHelper
3
+
4
+
5
+ class SulfonAmideFormationTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["amine", "sulfonylhalogenide"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(SulfonAmideFormation)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Ammonia and sulfonyl halogenides
14
+ (("N", "F[S+2]([O-])([O-])CC"), "N[S+2]([O-])([O-])CC"),
15
+ (("N", "Cl[S+2]([O-])([O-])CC"), "N[S+2]([O-])([O-])CC"),
16
+ (("N", "Br[S+2]([O-])([O-])CC"), "N[S+2]([O-])([O-])CC"),
17
+ (("N", "I[S+2]([O-])([O-])CC"), "N[S+2]([O-])([O-])CC"),
18
+
19
+ # Primary amines and sulfonyl chlorides
20
+ (("CN", "Cl[S+2]([O-])([O-])CC"), "CN[S+2]([O-])([O-])CC"),
21
+ (("C[NH3+]", "Cl[S+2]([O-])([O-])CC"), "CN[S+2]([O-])([O-])CC"),
22
+
23
+ # Secondary amine and sulfonyl chloride
24
+ (("CNC", "Cl[S+2]([O-])([O-])CC"), "CN(-C)[S+2]([O-])([O-])CC"),
25
+ (("C[NH2+]C", "Cl[S+2]([O-])([O-])CC"), "CN(-C)[S+2]([O-])([O-])CC"),
26
+
27
+ # Primary aniline and sulfonyl chlorides
28
+ (("c1ccccc1N", "Cl[S+2]([O-])([O-])CC"), "c1ccccc1N[S+2]([O-])([O-])CC"),
29
+ (("c1ccccc1[NH3+]", "Cl[S+2]([O-])([O-])CC"), "c1ccccc1N[S+2]([O-])([O-])CC"),
30
+
31
+ # Secondary aniline and sulfonyl chloride
32
+ (("c1ccccc1NC", "Cl[S+2]([O-])([O-])CC"), "c1ccccc1N(C)[S+2]([O-])([O-])CC"),
33
+
34
+ # Pyrrole or indole
35
+ (("C1=CC=CN1", "Cl[S+2]([O-])([O-])CC"), "c1cccn1[S+2]([O-])([O-])CC"),
36
+ (("C1=CC=CN1", "Cl[S+2]([O-])([O-])CC"), "c1cccn1[S+2]([O-])([O-])CC"),
37
+ (("C12=CC=CC=C1NC=C2", "Cl[S+2]([O-])([O-])CC"), "c12ccccc1n([S+2]([O-])([O-])CC)cc2"),
38
+ (("c1ccc2[nH]ccc2c1", "Cl[S+2]([O-])([O-])CC"), "c12ccccc1n([S+2]([O-])([O-])CC)cc2"),
39
+
40
+ # Special test: This is a standard sulfon amide directly from ChemDraw. The tests should be able to digest this.
41
+ (("CN", "ClS(CC)(=O)=O"), "CN[S+2]([O-])([O-])CC"),
42
+ ]
43
+
44
+ self._test_one_product(reactants, self.reactant_names)
45
+
46
+ # Those tests should not give any product.
47
+ def test_no_product(self):
48
+ reactants = [
49
+ # Ammonium and sulfonic acid
50
+ ("N", "O[S+2]([O-])([O-])CC"),
51
+
52
+ # Ammonium and sulfonate
53
+ ("N", "[O-][S+2]([O-])([O-])CC"),
54
+
55
+ # No tertiary amine
56
+ ("N(C)(C)(C)", "F[S+2]([O-])([O-])CC"),
57
+
58
+ # No tertiary pyrrole or indole
59
+ ("c1cccn(C)1", "F[S+2]([O-])([O-])CC"),
60
+ ("c1ccc2n(C)ccc2c1", "F[S+2]([O-])([O-])CC")
61
+ ]
62
+
63
+ self._test_no_product(reactants, self.reactant_names)
data/tests/test_SuzukiMiyaura.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from ClickReaction.Reactions import SuzukiMiyaura
2
+ from tests import TestHelper
3
+
4
+
5
+ class SuzukiMiyauraTest(TestHelper.ReactionTestCase):
6
+ reactant_names = ["boronate", "halogenide"]
7
+
8
+ def setUp(self):
9
+ self.set_reaction(SuzukiMiyaura)
10
+
11
+ def test_one_product(self):
12
+ reactants = [
13
+ # Test phenylhalogenides and phenylboronic acid
14
+ (("c1ccccc1B(O)O", "c1ccccc1Cl"), "c1ccccc1c1ccccc1"),
15
+ (("c1ccccc1B(O)O", "c1ccccc1Br"), "c1ccccc1c1ccccc1"),
16
+ (("c1ccccc1B(O)O", "c1ccccc1I"), "c1ccccc1c1ccccc1"),
17
+
18
+ # Check different esters for the boronic acid
19
+ # BPin
20
+ (("CC1(C)C(C)(C)OB(C2=CC=CC=C2)O1", "c1ccccc1Cl"), "c1ccccc1c1ccccc1"),
21
+ # Mida (open form)
22
+ (("CN1CC(=O)OB(OC(=O)C1)c2ccccc2", "c1ccccc1Cl"), "c1ccccc1c1ccccc1"),
23
+ # Mida (closed form)
24
+ (("C[N+]12CC(O[B-](c3ccccc3)1OC(C2)=O)=O", "c1ccccc1Cl"), "c1ccccc1c1ccccc1"),
25
+
26
+ # Check trifluoroboronates
27
+ (("F[B-](F)(F)C1=CC=CC=C1.[K+]", "c1ccccc1Cl"), "c1ccccc1c1ccccc1"),
28
+ ]
29
+
30
+ self._test_one_product(reactants, self.reactant_names)
31
+
32
+ # Those tests should not give any product.
33
+ def test_no_product(self):
34
+ reactants = [
35
+ # Arylfluorides should not work.
36
+ ("c1ccccc1B(O)O", "c1ccccc1F"),
37
+ # This should also not work.
38
+ ("c1ccccc1P(O)O", "c1ccccc1Cl"),
39
+ ]
40
+
41
+ self._test_no_product(reactants, self.reactant_names)