Skip to main content

PyMolinfo provides comprehensive molecular information and analysis.

Project description

PyMolinfo

Downloads PyPI Python Version License

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

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 |

| Visualize a compound | Launch Binder |

| Check and count functional groups | Launch Binder|

| Create custom functional groups | Launch Binder|

Google Colab

You can use the following code to run PyMolinfo in Google Colab:

| Version | Google Colab |

| --- | --- |

| 1.6.0 | Open In Colab |

| < 1.6.0 | Open In Colab |

Installation

Install molinfo with pip

  pip install PyMolinfo

Documentation

Import package as:

import pyMolinfo 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymolinfo-1.7.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

PyMolinfo-1.7.0-py3-none-any.whl (42.1 kB view details)

Uploaded Python 3

File details

Details for the file pymolinfo-1.7.0.tar.gz.

File metadata

  • Download URL: pymolinfo-1.7.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.5

File hashes

Hashes for pymolinfo-1.7.0.tar.gz
Algorithm Hash digest
SHA256 5963a0a47d94f2f6dea3cf2d94d661b55a4d07d2b89f2cd8e1f704a4a5c731b6
MD5 1c1f0ff890cf8a13453fa29be23fccb8
BLAKE2b-256 d876e531bfbab0e828b601a912f27a5b0fa7ba1c9140ebc3a1501a7dba5d215a

See more details on using hashes here.

File details

Details for the file PyMolinfo-1.7.0-py3-none-any.whl.

File metadata

  • Download URL: PyMolinfo-1.7.0-py3-none-any.whl
  • Upload date:
  • Size: 42.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.5

File hashes

Hashes for PyMolinfo-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e41fbbf6d36277bff6de48d743ac6131c09bab6fe2543d9124c904453859597
MD5 9deb0ca10119a2da77903b31f59cba66
BLAKE2b-256 b7fd77f056d245d9d53dcb616302e8368d0a908068b935d71fb2af923ace5f09

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page