-
Notifications
You must be signed in to change notification settings - Fork 118
[Feature] Molecule Meida Object3D Support. #920
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces the Molecule class, which is used to visualize 3D molecules. The class can be initialized with PDB data or from an RDKit Mol object. It includes methods for parsing the molecule data into a buffer and for returning metadata for visualization.
This commit introduces a test case for visualizing molecules using swanlab.data.modules.object3d.Molecule.
This commit introduces the Molecule class for handling molecule data from various formats using the RDKit library, and add it to `__all__` in `__init__.py`.
Adds from_pdb_file, from_sdf_file, from_smiles and from_mol_file methods to the Molecule class. These methods allow creating Molecule instances from various file formats (PDB, SDF, Mol) and SMILES strings, providing more flexibility in how molecule data is loaded and displayed.
Enable creation of Object3D from rdkit.Chem.Mol objects and add file handlers for common molecule file formats.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for visualizing 3D molecules in SwanLab by introducing a new Molecule class in the object3d module. It enables handling RDKit Mol objects and common molecule file formats while updating the Object3D dispatcher and exporting the Molecule class.
- Added test cases that demonstrate molecule visualization using both file paths and RDKit Mol objects.
- Updated Object3D to handle molecule input and added file handlers for various molecule file extensions.
- Introduced a new Molecule class that provides methods for creating molecule instances from Mol objects and molecule files.
Reviewed Changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
File | Description |
---|---|
test/metrics/molecule.py | Added tests demonstrating functionality with RDKit Mol objects and PDB files. |
swanlab/data/modules/object3d/object3d.py | Integrated molecule support into Object3D with proper file handlers and type checking. |
swanlab/data/modules/object3d/molecule.py | New Molecule class supporting multiple construction methods from molecule data. |
swanlab/data/modules/object3d/init.py | Updated exports to include the new Molecule class. |
Files not reviewed (1)
- test/metrics/molecule.example.pdb: Language not supported
Comments suppressed due to low confidence (1)
swanlab/data/modules/object3d/molecule.py:171
- The code references 'self.step' in the parse method, but there is no clear definition or initialization of 'step' in the Molecule class. Ensure that 'step' is properly defined, inherited, or provided to avoid runtime errors.
save_name = f"molecule-step{self.step}-{hash_name}.pdb"
This commit introduces a comprehensive test suite for the `Molecule` class within the `swanlab.data.modules.object3d` module. The tests cover various functionalities including: - Creating `Molecule` objects from different file formats (PDB, SDF, Mol) and SMILES strings. - Parsing `Molecule` objects. - Verifying metadata such as caption and chart type. - Ensures that `Object3D` correctly dispatches `Molecule` objects.
Description
This PR introduces support for visualizing 3D molecules within SwanLab. It adds a
Molecule
class to theobject3d
module, enabling users to display molecules from various sources. This includes reading from common molecule file formats (PDB, SDF, MOL) as well as directly from RDKitMol
objects. A test case is also included to demonstrate the functionality.Closes: #476
Supported Input Types
The
Object3D
class now supports the following input types for visualizing molecules:.pdb
,.sdf
,.sd
,.mol
rdkit.Chem.Mol
Dependencies
This functionality relies on the RDKit library. If RDKit is not already installed, please install it using:
Example