Welcome to the Molecule Visualizer! This interactive GUI application allows you to visualize and manipulate molecules from an XYZ file. With this tool, you can translate and rotate selected molecules, adjust bond criteria, and save the modified configurations.
- Multiple Molecule Support: Visualize any number of molecules from an XYZ file.
- Selective Transformation: Choose which molecules to modify with translation and rotation.
- Interactive GUI: User-friendly interface built with Tkinter and Matplotlib.
- Bond Visualization: Bonds are drawn based on customizable bond length criteria.
- Save Configurations: Export the adjusted molecule structures to a new XYZ file.
- Resizable Window: The interface adapts to different screen sizes.
- Python 3.x
- pip package manager
Install the required packages using pip:
pip install numpy matplotlib
Note: Tkinter is included with most Python installations. If not, install it via your system's package manager.
git clone https://github.com/yourusername/molecule-visualizer.git
cd molecule-visualizer
xyz_file
: Path to the input XYZ file.--nMolecules
: Number of molecules in the XYZ file.--nAtoms
: Number of atoms in each molecule (space-separated list).
python molecule_visualizer.py molecule.xyz --nMolecules 3 --nAtoms 42 17 29
- Ensure your XYZ file is correctly formatted.
- Run the script with the appropriate arguments.
- The GUI window will appear, displaying the molecules.
- Default: Only Molecule 1 is selected for modification.
- Select Molecules to Modify: Use the checkboxes to select or unselect molecules.
- All Molecules: Select or unselect all molecules at once.
- Translation Controls:
- Translate X: Move selected molecules along the X-axis.
- Translate Y: Move selected molecules along the Y-axis.
- Translate Z: Move selected molecules along the Z-axis.
- Rotation Controls:
- Rotate X (ยฐ): Rotate selected molecules around the X-axis.
- Rotate Y (ยฐ): Rotate selected molecules around the Y-axis.
- Rotate Z (ยฐ): Rotate selected molecules around the Z-axis.
- Save Adjusted Molecule: Save the current configuration to
adjusted_molecule.xyz
. - Reset: Reset all sliders and selections to their default values.
- Atoms: Displayed as colored spheres. Each molecule has a unique color.
- Bonds: Lines drawn between atoms based on bond length criteria.
- Interactive Plot: Zoom, pan, and rotate the 3D visualization.
The bond_tolerance
variable in the script defines the ยฑ tolerance for bond lengths:
bond_tolerance = 0.3 # Adjust this value as needed
- Decrease: For stricter bond detection.
- Increase: To allow more variation in bond lengths.
Add more bond types to the average_bond_lengths
dictionary:
average_bond_lengths = {
# Existing bond types...
frozenset(['N', 'O']): 1.40, # Example average bond length
# Add other bond types as necessary
}
Ensure your XYZ file follows the standard format:
<Number of atoms>
<Comment line (can be empty)>
<Atom 1 symbol> <X> <Y> <Z>
<Atom 2 symbol> <X> <Y> <Z>
...
- Atoms: List all atoms with their symbols and coordinates.
- Molecules: Concatenate molecule data sequentially in the file.
A: Ensure that the sum of atoms specified in --nAtoms
equals the total number of atoms in your XYZ file.
A: Make sure all dependencies are installed, and you're running Python 3.x.
A: Adjust the bond_tolerance
or verify that the atom types are included in average_bond_lengths
.
Contributions are welcome! Please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
- Author: Your Name
- Email: your.email@example.com
- GitHub: yourusername
- Thanks to the open-source community for the tools and libraries.
- Inspired by molecular visualization tools in computational chemistry.
Feel free to reach out if you have any questions or need assistance. Happy visualizing!
Made with โค๏ธ by Ajay Khanna