Skip to content

Add small molecule converters: MOL2/SDF/PDB → SMILES#359

Merged
cokelaer merged 3 commits intomainfrom
copilot/add-pdb-to-fasta-feature
Mar 7, 2026
Merged

Add small molecule converters: MOL2/SDF/PDB → SMILES#359
cokelaer merged 3 commits intomainfrom
copilot/add-pdb-to-fasta-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 6, 2026

Adds support for converting small molecule structure formats (MOL2, SDF, PDB) to SMILES, addressing the requested feature for cheminformatics format interconversion.

Changes

  • New converters

    • mol22smiles.py (MOL22SMILES) — Tripos MOL2 → SMILES
    • sdf2smiles.py (SDF2SMILES) — MDL SDF → SMILES (handles multi-molecule files)
    • pdb2smiles.py (PDB2SMILES) — PDB (small molecule/ligand) → SMILES

    Each converter exposes two methods: rdkit (default) and openbabel.

  • Extensions — Added mol2, sdf, and smiles entries to core/extensions.py

  • Test data — Added aspirin in MOL2, SDF, and PDB formats under test/data/

Usage

from bioconvert.mol22smiles import MOL22SMILES
from bioconvert.sdf2smiles import SDF2SMILES
from bioconvert.pdb2smiles import PDB2SMILES

MOL22SMILES("ligand.mol2", "out.smi")()
SDF2SMILES("compounds.sdf", "out.smi")()
PDB2SMILES("ligand.pdb", "out.smi")()
# or specify method explicitly:
SDF2SMILES("compounds.sdf", "out.smi")(method="openbabel")

Naming note: The MOL2 converter follows the existing BZ22GZ convention — double 2 in class/filename (MOL22SMILES) so the metaclass correctly parses MOL2 as the input format rather than splitting on the first 2.

Original prompt

This section details on the original issue you should resolve

<issue_title>PDB to FASTA or small molecules (MOL2, PDB, SDF to SMILES)</issue_title>
<issue_description>Request from a user. Could be nice indeed to have this feature

  • pdb to FAA in 0.6.2</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 6, 2026 15:08
… openbabel methods

Co-authored-by: cokelaer <778821+cokelaer@users.noreply.github.com>
… pdb2smiles

Co-authored-by: cokelaer <778821+cokelaer@users.noreply.github.com>
Copilot AI changed the title [WIP] Add PDB to FASTA conversion feature Add small molecule converters: MOL2/SDF/PDB → SMILES Mar 6, 2026
@cokelaer cokelaer marked this pull request as ready for review March 7, 2026 21:00
@cokelaer cokelaer merged commit 3454191 into main Mar 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDB to FASTA or small molecules (MOL2, PDB, SDF to SMILES)

2 participants