Metadata-Version: 2.4
Name: lmp2gro
Version: 1.0.0
Summary: A tool to convert LAMMPS data files to GROMACS topologies
Author-email: Alexandre M Pereira <amoni@id.uff.br>
License: MIT License
        
        Copyright (c) 2026 Alexandre Moni Pereira
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/AlexandreMoniPereira/lmp2gro
Keywords: chemistry,molecular-dynamics,LAMMPS,GROMACS,conversion
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Chemistry
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: scipy
Dynamic: license-file


<img src="lmp2gro_logo.png" align="right" width="200">

# lmp2gro

## Author
 - Alexandre Moni Pereira

## Motivation
**lmp2gro** is a Python-based utility designed to facilitate the topological conversion of [Large-scale Atomic/Molecular Massively Parallel Simulator (LAMMPS)](https://www.lammps.org/#gsc.tab=0) data files into [GROMACS](https://www.gromacs.org/)-compatible formats.

While LAMMPS provides several internal tools for topology generation (such as `msi2lmp`, `amber2lmp`, and `ch2lmp`) and supports external utilities like `cif2lammps`, transitioning these models to GROMACS remains a challenge. Given that these tools are highly effective for generating complex topologies—particularly for systems where GROMACS-native builders may struggle—a robust conversion bridge is essential for inter-software interoperability.

## Current Status
Initially developed for the characterization of crystals, surfaces, and Metal-Organic Frameworks (MOFs), **lmp2gro** processes a single-molecule LAMMPS data file to generate the necessary GROMACS input files. The current implementation outputs a single residue name (`resname`), allowing for the subsequent integration of additional molecular species within the GROMACS environment.

The script has been validated using topologies generated via `msi2lmp` for the **INTERFACE FF** and **CLAY-FF** frameworks. Furthermore, it has been benchmarked against **UFF4MOF** parameters generated by [`cif2lammps`](https://github.com/rytheranderson/cif2lammps) and cross-referenced with [**OBGMX**](https://github.com/gioGarbe/OBGMX), a recognized tool for direct GROMACS parameterization.

## Requirements
**lmp2gro** utilizes standard Python 3 libraries for data manipulation and regular expression parsing:
- `pandas`
- `numpy`
- `scipy`

## Usage
The primary execution syntax is:

```bash
python3 lmp2gro.py data.lammps_data_file
```

The input file (`data.lammps_data_file`) must contain a single molecular entity, which may include periodic boundary conditions. 

### Optional Arguments
* **Residue Naming:** By default, the residue name is set to `UNL`. You can specify a custom name using the `--resname` or `-r` flag:
    ```bash
    python3 lmp2gro.py data.lammps_data_file -r RES
    ```
* **Output Directory:** The output is saved to a folder named after the input file (stripping `.data` or `data.`). To define a custom directory, use the `--folder` flag:
    ```bash
    python3 lmp2gro.py data.lammps_data_file -r RES --folder folder_name
    ```
    The resulting directory will contain a structural file (`conf.gro`), global force field parameters (`topol.top`, `ffbonded.itp`, `atomtypes.itp`), and a molecule-specific inclusion file (`conf.itp`).

### Parameter Refinement
In specific force fields like **CLAY-FF**, where interactions are predominantly non-bonded, automatically generated bonded terms may be physically redundant. The `--clean` function identifies and removes bonded parameters for which all values are zero.

```bash
python3 lmp2gro.py data.lammps_data_file -r RES --folder folder_name --clean
```

To manually exclude specific bonded interactions that possess non-zero parameters, provide the target indices as follows:

```bash
python3 lmp2gro.py data.lammps_data_file -r RES --folder folder_name --clean -b "1 2" -a "1 2 3" -d "1" -i "1 2"
```

* `-b`: Indices for **bonds** to be deleted.
* `-a`: Indices for **angles** to be deleted.
* `-d`: Indices for **dihedrals** to be deleted.
* `-i`: Indices for **impropers** to be deleted.
*  The numbers represent the indexes to be removed from the LAMMPS data file.

