MolPy is a modular Python toolkit for molecular modeling, simulation setup, and structural analysis. It provides a unified framework for manipulating atomic structures, generating force field inputs, and analyzing simulation data.
- ๐๏ธ Modular Architecture: Clean, composable design with composition-over-inheritance philosophy
- ๐ Flexible Data Structures: Frame/Block system for atomic data, Trajectory for time series
- ๐ฏ Advanced Selection System: Boolean algebra for atom selection with custom predicates
- ๐ง Force Field Management: Comprehensive typing and parameter management
- ๐ Multi-format I/O: Support for PDB, XYZ, LAMMPS, AMBER, GROMACS formats
- ๐งฎ Analysis Tools: Built-in analysis for diffusion, clustering, and molecular properties
- ๐๏ธ Molecular Building: Polymer construction, bulk system generation, reaction modeling
- ๐ฆ Packing Algorithms: Molecular packing with Packmol integration and optimization
- ๐ Extensible Design: Custom wrappers, selections, and I/O components
- โก High Performance: Memory-mapped trajectory reading, efficient data structures
# Clone the repository
git clone https://github.com/MolCrafts/molpy.git
cd molpy
# Install in development mode
pip install -e .
import molpy as mp
import numpy as np
# Create a simulation box
box = mp.Box.cubic(10.0)
# Create atoms with coordinates and properties
atoms_data = {
'x': [0.0, 1.0, 2.0],
'y': [0.0, 0.0, 0.0],
'z': [0.0, 0.0, 0.0],
'element': ['C', 'C', 'C'],
'type': [1, 1, 1]
}
# Create a frame with atoms and box
frame = mp.Frame(data={'atoms': atoms_data}, box=box)
# Select specific atoms using the selection system
carbon_atoms = frame['atoms'][mp.AtomTypeSelection(1)]
print(f"Selected {len(carbon_atoms)} carbon atoms")
# Save to file
frame.save('system.pdb')
Comprehensive documentation is available at https://molcrafts.github.io/molpy
- Quickstart Guide: Basic concepts and first steps
- Installation: Setup and configuration
- FAQ: Common questions and solutions
- Core Concepts: Frame/Block system, Selection algebra, Systems
- Data Structures: Atoms, Bonds, Topology, Force Fields
- Analysis: Trajectory analysis, MSD calculations, Clustering
- Building: Molecular construction, Polymer building, Packing
- I/O Workflows: Reading/writing various formats
- Molecular Building: Creating complex systems
- Potential Calculations: Energy and force computations
- Molecular Packing: System generation and optimization
- Custom Wrappers: Extending MolPy with custom functionality
- Custom Selections: Building new selection predicates
- Custom I/O: Adding new file format support
- Core Modules: Fundamental data structures and classes
- I/O Modules: File format support and trajectory handling
- Analysis Modules: Property calculation tools
- Builder Modules: Molecular construction tools
- Operations Modules: Transformation and manipulation
- Potential Modules: Energy and force calculations
- Packing Modules: System generation algorithms
- Typifier Modules: Automatic atom typing
- Engine Modules: Simulation engine interfaces
MolPy is built around several core design principles:
- Composition over Inheritance: Flexible wrapper system for extending functionality
- Selection Algebra: Boolean logic for atom selection with custom predicates
- Memory Efficiency: Lazy loading and memory mapping for large trajectories
- Type Safety: Comprehensive type hints and validation
- Modular Design: Clean separation of concerns across modules
- Frame/Block: Container system for atomic data with flexible indexing
- Selection System: Boolean algebra for atom selection with custom predicates
- Wrapper System: Composition-based extension mechanism
- Trajectory I/O: Memory-mapped reading with lazy loading
- Force Field System: Comprehensive typing and parameter management
Core Dependencies:
- numpy - Numerical computing
- python-igraph - Graph analysis
- lark - SMARTS/SMILES parsing
- pint - Physical quantities and units
- freud-analysis - Analysis algorithms
Optional Dependencies:
- mkdocs - Documentation generation
- mkdocs-material - Documentation theme
- mkdocstrings - API documentation
MolNex - Universal potential training platform
- Neural network potential development
- Transfer learning for molecular systems
- Integration with popular ML frameworks
MolVis - Production-level visualization
- WebGL-accelerated rendering
- Real-time molecular manipulation
- Interactive debugging and analysis tools
MolCPP - C++ backend for performance-critical operations
We welcome contributions from the community! Here's how you can help:
- ๐ Bug Reports: Use GitHub Issues to report bugs
- ๐ก Feature Requests: Suggest new features and improvements
- ๐ Documentation: Help improve documentation and examples
- ๐ง Code Contributions: Submit pull requests with new features or fixes
# Clone and setup development environment
git clone https://github.com/MolCrafts/molpy.git
cd molpy
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks (automatically formats code)
pre-commit install
# Run tests
pytest tests/
# Manual formatting (if needed)
black src/
isort src/
This project uses pre-commit hooks to ensure code quality:
- Black: Automatic code formatting (line length: 88)
- isort: Import sorting and organization
- Pre-commit hooks: Run automatically on every commit
See DEVELOPMENT.md for detailed development guidelines.
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
Built with โค๏ธ by the MolCrafts team