Skip to content

Commit

Permalink
Merge branch 'main' of github.com:klausweinbauer/FGUtils into github_…
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
klausweinbauer committed Dec 16, 2024
2 parents 41c63a3 + a9806f0 commit d4f64da
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
11 changes: 6 additions & 5 deletions doc/functional_groups.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions fgutils/fgconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]},
]


Expand Down
8 changes: 6 additions & 2 deletions fgutils/vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]),
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion test/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=""),
],
)
Expand Down

0 comments on commit d4f64da

Please sign in to comment.