Skip to main content

🌟 PyMolinfo

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.

✨ 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 for a quick start.

📚 Binder

Test this package by launching our example notebooks on 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 1.6.0: Open In Colab

  • Version < 1.6.0: Open In Colab

🛠️ Installation

Install molinfo with pip

  pip install PyMolinfo

📖 Documentation

For detailed documentation, please visit molinfo.readthedocs.io/en/latest/.

💡 Examples

Import package as:

import pyMolinfo as mi

# check version

print(mi.__version__)
  • 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:
# plot_mode: Literal['plotly', 'matplotlib'] = 'plotly

# view graph

mi.view_graph(graph_1)
  • Display a compound:
# 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)

Creating Custom Functional Groups

To create custom functional groups, you need to define the bonds between atoms using the following format:

[atom1-element][atom1-number][bond-type][atom2-element][atom2-number]

Here are the formats for different bond types:

  • Single Bond: Represented as C1-C2 where C1 and C2 are the atoms connected by a single bond.

  • Double Bond: Represented as C1=C2 where C1 and C2 are the atoms connected by a double bond.

  • Triple Bond: Represented as C1#C2 where C1 and C2 are the atoms connected by a triple bond.

Examples

  1. Cyanide Group: A cyanide group can be represented as N1#C2.
custom_functional_group = [

    {'cyanide': ["N1#C2"]},

]
  1. Custom Functional Group: A custom functional group with a single and a double bond can be represented as N1-C2 and C2=O3.
custom_functional_group = [

    {'custom_fg': ["N1-C2", "C2=O3"]},

]
  1. Multiple Functional Groups: You can define multiple functional groups in a list.
custom_functional_group = [

    {'N#C': ["N1#C2"]},

    {'custom_fg': ["N1-C2", "C2-H3"]},

    {'NC=O': ["N1-C2", "C2=O3"]},

]

Once you have defined your custom functional groups, you can create and visualize them as follows:

# 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

@sinagilassi

Metadata

Release files for PyMolinfo 1.8.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PyMolinfo 1.8.9
File Size Uploaded
pymolinfo-1.8.9.tar.gz 53.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PyMolinfo 1.8.9
File Interpreter ABI Platform
pymolinfo-1.8.9-py3-none-any.whl Python 3 none any Details

Total release size: 112.0 kB

Release files / pymolinfo-1.8.9.tar.gz

Download URL pymolinfo-1.8.9.tar.gz
Size 53.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3576e458c56583915fdb729f097c1d9aa444380c380c0264480d6d96f37f01b0
BLAKE2b-256 checksum
How to use checksums
a788e0882874320790b04b5f64683d883ba048af864c4f10642ae46c677c271f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0

Release files / pymolinfo-1.8.9-py3-none-any.whl

Download URL pymolinfo-1.8.9-py3-none-any.whl
Size 58.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
faa167f888f014ec65798ce23496ca01b5a55e18c4bd3ce6feebac906adae356
BLAKE2b-256 checksum
How to use checksums
65d93a4a0f1c50cf3bb5e5fcebb5454cb62d21c87e53d2ca69433168ef72357c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.0

Release history Release notifications | RSS feed

This release

1.8.9 This release

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

1.8.5

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page