![PyMolinfo](https://drive.google.com/uc?export=view&id=1VZz79YQbWXMosfUwGBeTrTdHIiOXt_Ps)
![Downloads](https://img.shields.io/pypi/dm/PyMolinfo) ![PyPI](https://img.shields.io/pypi/v/PyMolinfo) ![Python Version](https://img.shields.io/pypi/pyversions/PyMolinfo.svg) ![License](https://img.shields.io/pypi/l/PyMolinfo)
**PyMolInfo** (previously molinfo) is a Python package designed for advanced molecular analysis by converting molecular structures into graph representations. This package enables researchers and chemists to load various molecular file formats, transform them into graphs, and extract valuable information through graph-based methods.
[Watch the demo](https://molinfopy.streamlit.app/)
**Features**
* `File Format Support`: Load molecular data from multiple file formats, including SDF and JSON (soon).
* `Graph Conversion`: Transform molecular structures into graph representations for detailed analysis.
* `Functional Group Identification`: Detect and analyze functional groups within the molecular graph.
* `Distance Measurement`: Compute distances between atoms and bonds in the molecular graph.
* `Bond Angle Calculation`: Measure angles between bonds using graph-based methods.
**Getting Started:**
To use PyMolinfo, simply install the package and import it into your Python script. Refer to the example code snippets above for a quick start.
## Binder
Test this package by launching our example notebooks on Binder:
| Description | Launch Binder |
| --- | --- |
| Load a sdf file | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-1.ipynb) |
| Visualize a compound | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-2.ipynb) |
| Check and count functional groups | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-3.ipynb)|
| Create custom functional groups | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-4.ipynb)|
## Google Colab
You can use the following code to run `PyMolinfo` in Google Colab:
| Version | Google Colab |
| --- | --- |
| 1.6.0 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1-mkVbXbznEJGeKWdQKtJT8xkWb2Bcvw_?usp=sharing) |
| < 1.6.0 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1rQXg92p_jxviVfKJFf_-1qQwmOgrMLUD?usp=sharing) |
## Installation
Install molinfo with pip
```python
pip install PyMolinfo
```
## Documentation
Import package as:
```python
import pyMolinfo as mi
# check version
print(mi.__version__)
```
## Examples
* Create a graph
```python
# sdf file
sdf_file_name_1 = 'test\Structure2D_COMPOUND_CID_261.sdf'
sdf_file = os.path.join(os.getcwd(), sdf_file_name_1)
# create graph
res = mi.create_graph(sdf_file)
print(type(res))
print(res)
```
* Display a graph:
```python
# visualize compound by sdf file
mi.g3d(sdf_file)
```
* Check the availability of functional groups:
```python
# check functional groups
res, comp1 = mi.check_functional_group(sdf_file, res_format='dataframe')
print(res)
```
* Calculate angle/distance between atoms
```python
# distance matrix
res_distance = comp1.distance_matrix(dataframe=True)
print(res_distance)
# distance between two atoms
distance = comp1.distance_atoms(['O1', 'C2'])
print(distance)
# angle between atoms
angle = comp1.angle_atoms(['O1', 'C2', 'H3'])
print(angle)
# dihedral angle
dihedral = comp1.d_angle_atoms(['H6', 'O1', 'C2', 'H3'])
print(dihedral)
```
* Create custom functional groups:
[`atom1-element`][`atom1-number`][`bond-type`][`atom2-element`][`atom2-number`]
| Bond Types | Format |
|:----------|:----------|
| single bond CC | C1-C2 |
| double bond CC | C1=C2 |
| triple bond CC | C1#C2 |
**How to create a custom functional group?**
| Name | Symbol | Format |
|:-----------|:------------:|-------------:|
| cyanide-1 | CCN | ["N1#C2"] |
| custom_fg | NCH | ["N1-C2", "C2-H3"] |
| NC=O | NC=O | ["N1-C2", "C2=O3"] |
And coded as:
```python
# C1-C2#N3
custom_functional_group = [
{'cyanide': ["C1-C2", "C2#N3"]},
]
# define different custom functional groups as:
# N#C
# NCH
# NCO
custom_functional_group = [
{'N#C': ["N1#C2"]},
{'custom_fg': ["N1-C2", "C2-H3"]},
{'NC=O': ["N1-C2", "C2=O3"]},
]
# create custom graph
custom_g = mi.create_custom_functional_groups(custom_functional_group)
# visualize custom graph
# custom_g.d("cyanide")
# find custom functional groups in a compound
res = mi.check_functional_group(
sdf_file, functional_groups=[custom_g])
print(res)
```
## FAQ
For any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/)
## Authors
- [@sinagilassi](https://www.github.com/sinagilassi)
Raw data
{
"_id": null,
"home_page": null,
"name": "PyMolinfo",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "python, chemistry, chemistry-visualization, PyMolinfo, molecular-graph",
"author": "Sina Gilassi",
"author_email": "<sina.gilassi@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/d8/76/e531bfbab0e828b601a912f27a5b0fa7ba1c9140ebc3a1501a7dba5d215a/pymolinfo-1.7.0.tar.gz",
"platform": null,
"description": "\r\n![PyMolinfo](https://drive.google.com/uc?export=view&id=1VZz79YQbWXMosfUwGBeTrTdHIiOXt_Ps)\r\n\r\n\r\n\r\n![Downloads](https://img.shields.io/pypi/dm/PyMolinfo) ![PyPI](https://img.shields.io/pypi/v/PyMolinfo) ![Python Version](https://img.shields.io/pypi/pyversions/PyMolinfo.svg) ![License](https://img.shields.io/pypi/l/PyMolinfo)\r\n\r\n\r\n\r\n**PyMolInfo** (previously molinfo) is a Python package designed for advanced molecular analysis by converting molecular structures into graph representations. This package enables researchers and chemists to load various molecular file formats, transform them into graphs, and extract valuable information through graph-based methods.\r\n\r\n\r\n\r\n[Watch the demo](https://molinfopy.streamlit.app/)\r\n\r\n\r\n\r\n**Features**\r\n\r\n\r\n\r\n* `File Format Support`: Load molecular data from multiple file formats, including SDF and JSON (soon).\r\n\r\n* `Graph Conversion`: Transform molecular structures into graph representations for detailed analysis.\r\n\r\n* `Functional Group Identification`: Detect and analyze functional groups within the molecular graph.\r\n\r\n* `Distance Measurement`: Compute distances between atoms and bonds in the molecular graph.\r\n\r\n* `Bond Angle Calculation`: Measure angles between bonds using graph-based methods.\r\n\r\n\r\n\r\n**Getting Started:**\r\n\r\n\r\n\r\nTo use PyMolinfo, simply install the package and import it into your Python script. Refer to the example code snippets above for a quick start.\r\n\r\n\r\n\r\n## Binder\r\n\r\n\r\n\r\nTest this package by launching our example notebooks on Binder:\r\n\r\n\r\n\r\n| Description | Launch Binder | \r\n\r\n| --- | --- |\r\n\r\n| Load a sdf file | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-1.ipynb) |\r\n\r\n| Visualize a compound | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-2.ipynb) |\r\n\r\n| Check and count functional groups | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-3.ipynb)|\r\n\r\n| Create custom functional groups | [![Launch Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/sinagilassi/Molinfo/cb4f3c4b58501786da3dc5a2413a67720f01d579?urlpath=lab%2Ftree%2Fnotebook%2Fdoc-4.ipynb)|\r\n\r\n\r\n\r\n## Google Colab\r\n\r\n\r\n\r\nYou can use the following code to run `PyMolinfo` in Google Colab:\r\n\r\n\r\n\r\n| Version | Google Colab |\r\n\r\n| --- | --- |\r\n\r\n| 1.6.0 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1-mkVbXbznEJGeKWdQKtJT8xkWb2Bcvw_?usp=sharing) |\r\n\r\n| < 1.6.0 | [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1rQXg92p_jxviVfKJFf_-1qQwmOgrMLUD?usp=sharing) |\r\n\r\n\r\n\r\n## Installation\r\n\r\n\r\n\r\nInstall molinfo with pip\r\n\r\n\r\n\r\n```python\r\n\r\n pip install PyMolinfo\r\n\r\n```\r\n\r\n\r\n\r\n## Documentation\r\n\r\n\r\n\r\nImport package as:\r\n\r\n\r\n\r\n```python\r\n\r\nimport pyMolinfo as mi\r\n\r\n# check version\r\n\r\nprint(mi.__version__)\r\n\r\n```\r\n\r\n\r\n\r\n## Examples\r\n\r\n\r\n\r\n* Create a graph\r\n\r\n\r\n\r\n```python\r\n\r\n# sdf file\r\n\r\nsdf_file_name_1 = 'test\\Structure2D_COMPOUND_CID_261.sdf'\r\n\r\nsdf_file = os.path.join(os.getcwd(), sdf_file_name_1)\r\n\r\n# create graph\r\n\r\nres = mi.create_graph(sdf_file)\r\n\r\nprint(type(res))\r\n\r\nprint(res)\r\n\r\n```\r\n\r\n\r\n\r\n* Display a graph:\r\n\r\n\r\n\r\n```python\r\n\r\n# visualize compound by sdf file\r\n\r\nmi.g3d(sdf_file)\r\n\r\n```\r\n\r\n\r\n\r\n* Check the availability of functional groups:\r\n\r\n\r\n\r\n```python\r\n\r\n# check functional groups\r\n\r\nres, comp1 = mi.check_functional_group(sdf_file, res_format='dataframe')\r\n\r\nprint(res)\r\n\r\n```\r\n\r\n\r\n\r\n* Calculate angle/distance between atoms\r\n\r\n\r\n\r\n```python\r\n\r\n# distance matrix\r\n\r\nres_distance = comp1.distance_matrix(dataframe=True)\r\n\r\nprint(res_distance)\r\n\r\n\r\n\r\n# distance between two atoms\r\n\r\ndistance = comp1.distance_atoms(['O1', 'C2'])\r\n\r\nprint(distance)\r\n\r\n\r\n\r\n# angle between atoms\r\n\r\nangle = comp1.angle_atoms(['O1', 'C2', 'H3'])\r\n\r\nprint(angle)\r\n\r\n\r\n\r\n# dihedral angle\r\n\r\ndihedral = comp1.d_angle_atoms(['H6', 'O1', 'C2', 'H3'])\r\n\r\nprint(dihedral)\r\n\r\n```\r\n\r\n\r\n\r\n* Create custom functional groups:\r\n\r\n\r\n\r\n[`atom1-element`][`atom1-number`][`bond-type`][`atom2-element`][`atom2-number`]\r\n\r\n\r\n\r\n| Bond Types | Format | \r\n\r\n|:----------|:----------|\r\n\r\n| single bond CC | C1-C2 | \r\n\r\n| double bond CC | C1=C2 | \r\n\r\n| triple bond CC | C1#C2 | \r\n\r\n\r\n\r\n**How to create a custom functional group?**\r\n\r\n\r\n\r\n| Name | Symbol | Format |\r\n\r\n|:-----------|:------------:|-------------:|\r\n\r\n| cyanide-1 | CCN | [\"N1#C2\"] |\r\n\r\n| custom_fg | NCH | [\"N1-C2\", \"C2-H3\"] |\r\n\r\n| NC=O | NC=O | [\"N1-C2\", \"C2=O3\"] |\r\n\r\n\r\n\r\nAnd coded as:\r\n\r\n\r\n\r\n```python\r\n\r\n# C1-C2#N3\r\n\r\ncustom_functional_group = [\r\n\r\n {'cyanide': [\"C1-C2\", \"C2#N3\"]},\r\n\r\n]\r\n\r\n\r\n\r\n# define different custom functional groups as:\r\n\r\n# N#C\r\n\r\n# NCH\r\n\r\n# NCO\r\n\r\ncustom_functional_group = [\r\n\r\n {'N#C': [\"N1#C2\"]},\r\n\r\n {'custom_fg': [\"N1-C2\", \"C2-H3\"]},\r\n\r\n {'NC=O': [\"N1-C2\", \"C2=O3\"]},\r\n\r\n]\r\n\r\n\r\n\r\n# create custom graph\r\n\r\ncustom_g = mi.create_custom_functional_groups(custom_functional_group)\r\n\r\n\r\n\r\n# visualize custom graph\r\n\r\n# custom_g.d(\"cyanide\")\r\n\r\n\r\n\r\n# find custom functional groups in a compound\r\n\r\nres = mi.check_functional_group(\r\n\r\n sdf_file, functional_groups=[custom_g])\r\n\r\nprint(res)\r\n\r\n```\r\n\r\n\r\n\r\n## FAQ\r\n\r\n\r\n\r\nFor any question, contact me on [LinkedIn](https://www.linkedin.com/in/sina-gilassi/) \r\n\r\n\r\n\r\n\r\n\r\n## Authors\r\n\r\n\r\n\r\n- [@sinagilassi](https://www.github.com/sinagilassi)\r\n\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "PyMolinfo provides comprehensive molecular information and analysis.",
"version": "1.7.0",
"project_urls": null,
"split_keywords": [
"python",
" chemistry",
" chemistry-visualization",
" pymolinfo",
" molecular-graph"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b7fd77f056d245d9d53dcb616302e8368d0a908068b935d71fb2af923ace5f09",
"md5": "9deb0ca10119a2da77903b31f59cba66",
"sha256": "2e41fbbf6d36277bff6de48d743ac6131c09bab6fe2543d9124c904453859597"
},
"downloads": -1,
"filename": "PyMolinfo-1.7.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9deb0ca10119a2da77903b31f59cba66",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 42124,
"upload_time": "2024-10-31T02:01:57",
"upload_time_iso_8601": "2024-10-31T02:01:57.605379Z",
"url": "https://files.pythonhosted.org/packages/b7/fd/77f056d245d9d53dcb616302e8368d0a908068b935d71fb2af923ace5f09/PyMolinfo-1.7.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d876e531bfbab0e828b601a912f27a5b0fa7ba1c9140ebc3a1501a7dba5d215a",
"md5": "1c1f0ff890cf8a13453fa29be23fccb8",
"sha256": "5963a0a47d94f2f6dea3cf2d94d661b55a4d07d2b89f2cd8e1f704a4a5c731b6"
},
"downloads": -1,
"filename": "pymolinfo-1.7.0.tar.gz",
"has_sig": false,
"md5_digest": "1c1f0ff890cf8a13453fa29be23fccb8",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 39799,
"upload_time": "2024-10-31T02:01:59",
"upload_time_iso_8601": "2024-10-31T02:01:59.296359Z",
"url": "https://files.pythonhosted.org/packages/d8/76/e531bfbab0e828b601a912f27a5b0fa7ba1c9140ebc3a1501a7dba5d215a/pymolinfo-1.7.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-31 02:01:59",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "pymolinfo"
}