Skip to main content

PyMolinfo provides comprehensive molecular information and analysis.

Project description

🌟 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:
# 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

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.8.7.tar.gz (50.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymolinfo-1.8.7-py3-none-any.whl (53.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymolinfo-1.8.7.tar.gz
Algorithm Hash digest
SHA256 2bb23a0b29a801751d4077dc65f40080ce48946dd79af10ee86180a6f350b391
MD5 0070db12140f898d554da2778bf71450
BLAKE2b-256 f0f24d6671d3061f71d4c23fa24137b0413768a2f6115ae939a3a1988789abd1

See more details on using hashes here.

File details

Details for the file pymolinfo-1.8.7-py3-none-any.whl.

File metadata

  • Download URL: pymolinfo-1.8.7-py3-none-any.whl
  • Upload date:
  • Size: 53.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for pymolinfo-1.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bd9c6151c24fe6333c69a2f7b355cfe0cdf426c3c9eba246de9ec9330c89cb4d
MD5 7550e2240a0293b45ebb4b2ec0453308
BLAKE2b-256 b984684c19060340d64f1ff61d110f8dc107c89281fc1f7b3d078f45c9ca1209

See more details on using hashes here.

Supported by

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