
[](https://colab.research.google.com/github/ipqa-research/ugropy/blob/main/docs/source/tutorial/easy_way.ipynb)
[](https://tldrlegal.com/license/mit-license)

[](https://salvadorbrandolin.github.io/ugropy/)
[](https://badge.fury.io/py/ugropy)
[](https://www.rdkit.org/)
`ugropy` is a `Python` library to obtain subgroups from different thermodynamic
group contribution models using both the name or the SMILES representation of a
molecule. If the name is given, the library uses the
[PubChemPy](https://github.com/mcs07/PubChemPy) library to obtain the SMILES
representation from PubChem. In both cases, `ugropy` uses the
[RDKit](https://github.com/rdkit/rdkit) library to search the functional groups
in the molecule.
`ugropy` is in an early development stage, leaving issues of examples of
molecules that `ugropy` fails solving the subgroups of a model is very helpful.
`ugropy` is tested for `Python` 3.10, 3.11 and 3.12 on Linux, Windows and Mac
OS.
# Try ugropy now
You can try `ugropy` without installing it by clicking on the Colab badge.
# Models implemented
## Gibbs / EoS models
- Classic liquid-vapor UNIFAC
- Predictive Soave-Redlich-Kwong (PSRK)
## Property estimators
- Joback
- Abdulelah-Gani (beta)
# Writers
`ugropy` allows you to convert the obtained functional groups or estimated
properties to the input format required by the following thermodynamic
libraries:
- [Clapeyron.jl](https://github.com/ClapeyronThermo/Clapeyron.jl)
- [Thermo](https://github.com/CalebBell/thermo)
# Example of use
Here is a little taste of `ugropy`, please, check the full tutorial
[here](https://ipqa-research.github.io/ugropy/tutorial/tutorial.html) to see
all it has to offer!
Get groups from the molecule's name:
```python
from ugropy import Groups
hexane = Groups("hexane")
print(hexane.unifac.subgroups)
print(hexane.psrk.subgroups)
print(hexane.joback.subgroups)
print(hexane.agani.primary.subgroups)
```
{'CH3': 2, 'CH2': 4}
{'CH3': 2, 'CH2': 4}
{'-CH3': 2, '-CH2-': 4}
{'CH3': 2, 'CH2': 4}
Get groups from molecule's SMILES:
```python
propanol = Groups("CCCO", "smiles")
print(propanol.unifac.subgroups)
print(propanol.psrk.subgroups)
print(propanol.joback.subgroups)
print(propanol.agani.primary.subgroups)
```
{'CH3': 1, 'CH2': 2, 'OH': 1}
{'CH3': 1, 'CH2': 2, 'OH': 1}
{'-CH3': 1, '-CH2-': 2, '-OH (alcohol)': 1}
{'CH3': 1, 'CH2': 2, 'OH': 1}
Estimate properties with the Joback and Abdulelah-Gani models!
```python
limonene = Groups("limonene")
print(limonene.joback.subgroups)
print(f"{limonene.joback.critical_temperature} K")
print(f"{limonene.joback.vapor_pressure(176 + 273.15)} bar")
```
{'-CH3': 2, '=CH2': 1, '=C<': 1, 'ring-CH2-': 3, 'ring>CH-': 1, 'ring=CH-': 1, 'ring=C<': 1}
657.4486692170663 kelvin
1.0254019428522743 bar
```python
print(limonene.agani.primary.subgroups)
print(limonene.agani.secondary.subgroups)
print(limonene.agani.tertiary.subgroups)
print(f"{limonene.agani.critical_temperature}")
print(limonene.agani.molecular_weight / limonene.agani.liquid_molar_volume)
```
{'CH3': 2, 'CH2=C': 1, 'CH2 (cyclic)': 3, 'CH (cyclic)': 1, 'CH=C (cyclic)': 1}
{'CH3-CHm=CHn (m,n in 0..2)': 1, '(CHn=C)cyc-CH3 (n in 0..2)': 1, 'CHcyc-C=CHn (n in 1..2)': 1}
{}
640.1457030826214 kelvin
834.8700605718585 gram / liter
Visualize your results! (The next code creates the `ugropy` logo)
```Python
mol = Groups("CCCC1=C(COC(C)(C)COC(=O)OCC)C=C(CC2=CC=CC=C2)C=C1", "smiles")
mol.unifac.draw(
title="ugropy",
width=800,
height=450,
title_font_size=50,
legend_font_size=14
)
```
Write down the [Clapeyron.jl](https://github.com/ClapeyronThermo/Clapeyron.jl)
.csv input files.
```python
from ugropy import writers
names = ["limonene", "adrenaline", "Trinitrotoluene"]
grps = [Groups(n) for n in names]
# Write the csv files into a database directory
writers.to_clapeyron(
molecules_names=names,
unifac_groups=[g.unifac.subgroups for g in grps],
psrk_groups=[g.psrk.subgroups for g in grps],
joback_objects=[g.joback for g in grps],
path="database"
)
```
Obtain the [Caleb Bell's Thermo](https://github.com/CalebBell/thermo) subgroups
```python
from ugropy import unifac
names = ["hexane", "ethanol"]
grps = [Groups(n) for n in names]
[writers.to_thermo(g.unifac.subgroups, unifac) for g in grps]
```
```
[{1: 2, 2: 4}, {1: 1, 2: 1, 14: 1}]
```
## Installation
```
pip install ugropy
```
Raw data
{
"_id": null,
"home_page": null,
"name": "ugropy",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "UNIFAC, functional group, thermodynamics, chemical engineering",
"author": null,
"author_email": "\"Brandol\u00edn, Salvador Eduardo\" <salvadorebrandolin@mi.unc.edu.ar>",
"download_url": "https://files.pythonhosted.org/packages/d0/d6/1fddc77298f08ad0972045164288988a42fc76092c850c9a2af9836ce971/ugropy-3.0.0.tar.gz",
"platform": null,
"description": "\n\n[](https://colab.research.google.com/github/ipqa-research/ugropy/blob/main/docs/source/tutorial/easy_way.ipynb)\n[](https://tldrlegal.com/license/mit-license)\n\n[](https://salvadorbrandolin.github.io/ugropy/)\n[](https://badge.fury.io/py/ugropy)\n[](https://www.rdkit.org/)\n \n\n`ugropy` is a `Python` library to obtain subgroups from different thermodynamic\ngroup contribution models using both the name or the SMILES representation of a\nmolecule. If the name is given, the library uses the\n[PubChemPy](https://github.com/mcs07/PubChemPy) library to obtain the SMILES\nrepresentation from PubChem. In both cases, `ugropy` uses the\n[RDKit](https://github.com/rdkit/rdkit) library to search the functional groups\nin the molecule.\n\n`ugropy` is in an early development stage, leaving issues of examples of\nmolecules that `ugropy` fails solving the subgroups of a model is very helpful.\n\n`ugropy` is tested for `Python` 3.10, 3.11 and 3.12 on Linux, Windows and Mac\nOS.\n\n# Try ugropy now\nYou can try `ugropy` without installing it by clicking on the Colab badge.\n\n# Models implemented\n\n## Gibbs / EoS models\n- Classic liquid-vapor UNIFAC\n- Predictive Soave-Redlich-Kwong (PSRK)\n\n## Property estimators\n- Joback\n- Abdulelah-Gani (beta)\n\n# Writers\n`ugropy` allows you to convert the obtained functional groups or estimated\nproperties to the input format required by the following thermodynamic\nlibraries:\n\n- [Clapeyron.jl](https://github.com/ClapeyronThermo/Clapeyron.jl)\n- [Thermo](https://github.com/CalebBell/thermo)\n\n\n# Example of use\nHere is a little taste of `ugropy`, please, check the full tutorial\n[here](https://ipqa-research.github.io/ugropy/tutorial/tutorial.html) to see\nall it has to offer!\n\nGet groups from the molecule's name:\n\n\n```python\nfrom ugropy import Groups\n\n\nhexane = Groups(\"hexane\")\n\nprint(hexane.unifac.subgroups)\nprint(hexane.psrk.subgroups)\nprint(hexane.joback.subgroups)\nprint(hexane.agani.primary.subgroups)\n```\n\n {'CH3': 2, 'CH2': 4}\n {'CH3': 2, 'CH2': 4}\n {'-CH3': 2, '-CH2-': 4}\n {'CH3': 2, 'CH2': 4}\n\nGet groups from molecule's SMILES:\n\n```python\npropanol = Groups(\"CCCO\", \"smiles\")\n\nprint(propanol.unifac.subgroups)\nprint(propanol.psrk.subgroups)\nprint(propanol.joback.subgroups)\nprint(propanol.agani.primary.subgroups)\n```\n\n {'CH3': 1, 'CH2': 2, 'OH': 1}\n {'CH3': 1, 'CH2': 2, 'OH': 1}\n {'-CH3': 1, '-CH2-': 2, '-OH (alcohol)': 1}\n {'CH3': 1, 'CH2': 2, 'OH': 1}\n\nEstimate properties with the Joback and Abdulelah-Gani models!\n\n```python\nlimonene = Groups(\"limonene\")\n\nprint(limonene.joback.subgroups)\nprint(f\"{limonene.joback.critical_temperature} K\")\nprint(f\"{limonene.joback.vapor_pressure(176 + 273.15)} bar\")\n```\n\n {'-CH3': 2, '=CH2': 1, '=C<': 1, 'ring-CH2-': 3, 'ring>CH-': 1, 'ring=CH-': 1, 'ring=C<': 1}\n 657.4486692170663 kelvin\n 1.0254019428522743 bar\n\n```python\nprint(limonene.agani.primary.subgroups)\nprint(limonene.agani.secondary.subgroups)\nprint(limonene.agani.tertiary.subgroups)\nprint(f\"{limonene.agani.critical_temperature}\")\nprint(limonene.agani.molecular_weight / limonene.agani.liquid_molar_volume)\n```\n\n {'CH3': 2, 'CH2=C': 1, 'CH2 (cyclic)': 3, 'CH (cyclic)': 1, 'CH=C (cyclic)': 1}\n {'CH3-CHm=CHn (m,n in 0..2)': 1, '(CHn=C)cyc-CH3 (n in 0..2)': 1, 'CHcyc-C=CHn (n in 1..2)': 1}\n {}\n 640.1457030826214 kelvin\n 834.8700605718585 gram / liter\n\nVisualize your results! (The next code creates the `ugropy` logo)\n\n```Python\nmol = Groups(\"CCCC1=C(COC(C)(C)COC(=O)OCC)C=C(CC2=CC=CC=C2)C=C1\", \"smiles\")\n\nmol.unifac.draw(\n title=\"ugropy\",\n width=800,\n height=450,\n title_font_size=50,\n legend_font_size=14\n)\n```\n\nWrite down the [Clapeyron.jl](https://github.com/ClapeyronThermo/Clapeyron.jl)\n.csv input files.\n\n```python\nfrom ugropy import writers\n\nnames = [\"limonene\", \"adrenaline\", \"Trinitrotoluene\"]\n\ngrps = [Groups(n) for n in names]\n\n# Write the csv files into a database directory\nwriters.to_clapeyron(\n molecules_names=names,\n unifac_groups=[g.unifac.subgroups for g in grps],\n psrk_groups=[g.psrk.subgroups for g in grps],\n joback_objects=[g.joback for g in grps],\n path=\"database\"\n)\n```\nObtain the [Caleb Bell's Thermo](https://github.com/CalebBell/thermo) subgroups\n\n```python\nfrom ugropy import unifac\n\nnames = [\"hexane\", \"ethanol\"]\n\ngrps = [Groups(n) for n in names]\n\n[writers.to_thermo(g.unifac.subgroups, unifac) for g in grps]\n```\n\n```\n[{1: 2, 2: 4}, {1: 1, 2: 1, 14: 1}]\n```\n\n## Installation\n```\npip install ugropy\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Get UNIFAC functional groups of PubChem compounds or SMILES representation.",
"version": "3.0.0",
"project_urls": {
"Homepage": "https://github.com/ipqa-research/ugropy"
},
"split_keywords": [
"unifac",
" functional group",
" thermodynamics",
" chemical engineering"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d6c9a21ada0a253adc000084016e8e319aa97ca397fc6d5e5f6e56586e8f46a3",
"md5": "33f8c3777bf4d3330c9cfd2769252420",
"sha256": "64abf1d7b58498bbb6bc4941ec44fd0cb8f20452dcd23a041bd754c0d5dcbccb"
},
"downloads": -1,
"filename": "ugropy-3.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "33f8c3777bf4d3330c9cfd2769252420",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 111716,
"upload_time": "2025-02-20T17:41:51",
"upload_time_iso_8601": "2025-02-20T17:41:51.708498Z",
"url": "https://files.pythonhosted.org/packages/d6/c9/a21ada0a253adc000084016e8e319aa97ca397fc6d5e5f6e56586e8f46a3/ugropy-3.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "d0d61fddc77298f08ad0972045164288988a42fc76092c850c9a2af9836ce971",
"md5": "e2c00f61552b1f0794b7b1c28782c62d",
"sha256": "47857eb54111395fab375102e4481b2d05fafcc7c5e7179eb513374df9e6f067"
},
"downloads": -1,
"filename": "ugropy-3.0.0.tar.gz",
"has_sig": false,
"md5_digest": "e2c00f61552b1f0794b7b1c28782c62d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 94052,
"upload_time": "2025-02-20T17:41:53",
"upload_time_iso_8601": "2025-02-20T17:41:53.604234Z",
"url": "https://files.pythonhosted.org/packages/d0/d6/1fddc77298f08ad0972045164288988a42fc76092c850c9a2af9836ce971/ugropy-3.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-20 17:41:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ipqa-research",
"github_project": "ugropy",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "ugropy"
}