diff --git a/doc/functional_groups.rst b/doc/functional_groups.rst index 1f7a30c..7dfcb98 100644 --- a/doc/functional_groups.rst +++ b/doc/functional_groups.rst @@ -50,16 +50,17 @@ Functional Group Tree .. code-block:: Functional Group Parents Pattern - -------------------------------------------------------------------------- + ---------------------------------------------------------------------------- ether [ROOT] ROR ├── ketal [ether] RC(OR)(OR)R │ ├── acetal [ketal] RC(OC)(OC)H │ └── hemiketal [ketal, alcohol] RC(OH)(OR)R │ └── hemiacetal [hemiketal] RC(OC)(OH)H + ├── epoxid [ether] RC(R)1C(R)(R)O1 ├── ester [ketone, ether] RC(=O)OR │ ├── anhydride [ester] RC(=O)OC(=O)R │ ├── peroxy_acid [ester, peroxide] RC(=O)OOH - │ ├── carbamate [ester, amide] ROC(=O)N(R)R + │ ├── carbamate [amide, ester] ROC(=O)N(R)R │ └── carboxylic_acid [ester, alcohol] RC(=O)OH ├── alcohol [ether] COH │ ├── hemiketal [ketal, alcohol] RC(OH)(OR)R @@ -76,18 +77,18 @@ Functional Group Tree └── thioester [ketone, thioether] RC(=O)SR amine [ROOT] RN(R)R ├── amide [ketone, amine] RC(=O)N(R)R - │ └── carbamate [ester, amide] ROC(=O)N(R)R + │ └── carbamate [amide, ester] ROC(=O)N(R)R └── anilin [amine] C:CN(R)R carbonyl [ROOT] C(=O) ├── ketene [carbonyl] RC(R)=C=O └── ketone [carbonyl] RC(=O)R ├── amide [ketone, amine] RC(=O)N(R)R - │ └── carbamate [ester, amide] ROC(=O)N(R)R + │ └── carbamate [amide, ester] ROC(=O)N(R)R ├── thioester [ketone, thioether] RC(=O)SR ├── ester [ketone, ether] RC(=O)OR │ ├── anhydride [ester] RC(=O)OC(=O)R │ ├── peroxy_acid [ester, peroxide] RC(=O)OOH - │ ├── carbamate [ester, amide] ROC(=O)N(R)R + │ ├── carbamate [amide, ester] ROC(=O)N(R)R │ └── carboxylic_acid [ester, alcohol] RC(=O)OH ├── acyl_chloride [ketone] RC(=O)Cl └── aldehyde [ketone] RC(=O)H diff --git a/fgutils/fgconfig.py b/fgutils/fgconfig.py index 3f85c5d..73edb13 100644 --- a/fgutils/fgconfig.py +++ b/fgutils/fgconfig.py @@ -67,6 +67,7 @@ {"name": "ketene", "pattern": "RC(R)=C=O", "group_atoms": [1, 3, 4]}, {"name": "carbamate", "pattern": "ROC(=O)N(R)R", "group_atoms": [1, 2, 3, 4]}, {"name": "acyl_chloride", "pattern": "RC(=O)Cl", "group_atoms": [1, 2, 3]}, + {"name": "epoxid", "pattern": "RC(R)1C(R)(R)O1", "group_atoms": [1, 3, 6]}, ] diff --git a/fgutils/vis.py b/fgutils/vis.py index 12e2065..88af71e 100644 --- a/fgutils/vis.py +++ b/fgutils/vis.py @@ -111,8 +111,12 @@ def plot_as_mol(g: nx.Graph, ax, use_mol_coords=True): nx.draw_networkx_edge_labels(g, positions, edge_labels=edge_labels, ax=ax) -def get_rxn_img(smiles): +def get_rxn_img(smiles, background_colour=None): drawer = rdMolDraw2D.MolDraw2DCairo(1600, 900) + opts = drawer.drawOptions() + if background_colour is None: + background_colour = (0.0, 0.0, 0.0, 0.0) + opts.setBackgroundColour(background_colour) if ">>" in smiles: rxn = rdChemReactions.ReactionFromSmarts(smiles, useSmiles=True) drawer.DrawReaction(rxn) @@ -127,7 +131,7 @@ def get_rxn_img(smiles): (x, y) for x in range(img.size[0]) for y in range(img.size[1]) - if img.getdata()[x + y * img.size[0]] != (255, 255, 255) # type: ignore + if img.getdata()[x + y * img.size[0]] != background_colour # type: ignore ] rect = ( min([x - 10 for x, _ in nonwhite_positions]), diff --git a/pyproject.toml b/pyproject.toml index 878669a..87fafec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "fgutils" -version = "0.1.2" +version = "0.1.3" authors = [{name="Klaus Weinbauer", email="klaus@bioinf.uni-leipzig.de"}] description = "Library to get functional groups from molecular graphs." readme = "README.md" diff --git a/test/test_query.py b/test/test_query.py index 2ba080d..e41cbb1 100644 --- a/test/test_query.py +++ b/test/test_query.py @@ -84,7 +84,8 @@ def test_get_functional_group_once(): pytest.param( "C(O)(O)C=CO", ["hemiketal", "enol"], [[0, 1, 2], [3, 4, 5]], id="Hemiketal" ), - pytest.param("C=CO", ["enol"], [[0, 1, 2]], id="Enol") + pytest.param("C=CO", ["enol"], [[0, 1, 2]], id="Enol"), + pytest.param("C1CO1", ["epoxid"], [[0, 1, 2]], id="Epoxid") # pytest.param("", [""], [[]], id=""), ], )