Molinfo
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.
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 Molinfo, 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 |
| --- | --- |
| Check and count functional groups | |
| Create custom functional groups | |
Google Colab
You can use the following code to run Molinfo in Google Colab:
Installation
Install molinfo with pip
pip install molinfo
Documentation
Import package as:
import molinfo as mi
# check version
print(mi.__version__)
Examples
- Create a graph
# 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:
# visualize compound by sdf file
mi.g3d(sdf_file)
- Check the availability of functional groups:
# check functional groups
res, comp1 = mi.check_functional_group(sdf_file, res_format='dataframe')
print(res)
- Calculate angle/distance between atoms
# 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:
# 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
Authors
Metadata
Release files for Molinfo 1.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| molinfo-1.5.4.tar.gz | 38.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| Molinfo-1.5.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.0 kB
Release files / molinfo-1.5.4.tar.gz
| Download URL | molinfo-1.5.4.tar.gz |
|---|---|
| Size | 38.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
57b27252dcb7b3e7b6fa14ed1e3fce32b2f8df45ede9044197f16d0b0e5139c7
|
|
BLAKE2b-256 checksum How to use checksums |
458d26069a8d8c4d7c32c7ae71d7abd6726f0dec8d340c4c319356798d1c346b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.5
|
Release files / Molinfo-1.5.4-py3-none-any.whl
| Download URL | Molinfo-1.5.4-py3-none-any.whl |
|---|---|
| Size | 40.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78980fff106f6f6bc22966a4366485a64656857713a49db1c56ef7ecd0e8c146
|
|
BLAKE2b-256 checksum How to use checksums |
ad0fc8cfc7f806ff8a5005ae1a8a5671d8d161a115f031c7f1b191f1cf9d41b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.5
|