Metadata-Version: 2.4
Name: map2smiles
Version: 1.0.2
Summary: Convert modified peptide sequences (with PTMs, NNRs, cyclization) into SMILES using RDKit
Keywords: rdkit,modified peptides,SMILES
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: rdkit
Requires-Dist: rich

# map2smiles

Convert modified peptide sequences in MAP format into SMILES representations using RDKit.

`map2smiles` supports natural amino acids, post-translational modifications (PTMs), non-natural residues, terminal modifications, D-amino acids, and peptide cyclization for flexible peptide-to-structure generation.

---

## Installation

Install directly from PyPI:

```bash
pip install map2smiles
```

### Requirements

- Python 3.9+
- RDKit

> Note: RDKit installation via `pip` may fail on some systems.  
> If needed, install RDKit through Conda instead.

---

## Quick Start

Convert a peptide sequence to SMILES directly from the command line:

```bash
map2smiles "AGHTCA"
```

Example with modifications:

```bash
map2smiles "ACDE{cyc:n-c}"
```

Example with non-natural residues and D-amino acids:

```bash
map2smiles "A{d}G{nnr:ORN}KT"
```

---

## Batch Processing

Process multiple sequences from a file:

```bash
map2smiles -i input.txt -o output.csv
```

### Supported Input Formats

- `.txt` — one MAP sequence per line
- `.fasta`

### Generated Outputs

For TXT input:

```text
sequence, SMILES
```

For FASTA input:

```text
ID, sequence, SMILES
```

Errors are written to:

```text
output.csv.errors
```

---

## Features

- Conversion of peptide sequences to SMILES
- Support for:
  - Standard amino acids
  - Post-translational modifications (PTMs)
  - N- and C-terminal modifications
  - Non-natural residues
  - D-amino acids (stereochemistry inversion)
  - Peptide cyclization
- Batch processing support
- Extensible JSON-based residue/modification database

---

## MAP Sequence Syntax

### Natural Sequence

```text
ACDEFG
```

### Post-translational Modification

```text
A{ptm:mod}C
```

### Terminal Modifications

```text
DRP{nt:mod}
ACD{ct:mod}
```

### Non-natural Residues

```text
AG{nnr:CODE}KPW
```

### D-amino Acids

```text
A{d}CYQS
```

### Cyclization

Head-to-tail cyclization:

```text
ACDE{cyc:n-c}
```

Disulfide or residue pairing:

```text
ACDC{cyc:2-4}
```

---

## How It Works

1. The input sequence is parsed into residues and modification instructions.
2. Residues and modifications are resolved using the JSON database.
3. Each residue is converted into an RDKit molecule.
4. Residues are stitched together through peptide bond formation.
5. Optional cyclization reactions are applied.
6. D-amino acid stereochemistry is generated through chiral inversion.

---

## Package Structure

```text
map2smiles/
├── pyproject.toml
├── README.md
├── src/
│   └── map2smiles/
│       ├── cli.py
│       ├── core.py
│       ├── data/
│       │   ├── merged_final_data.json
│       │   └── catalogue.html
│       └── __init__.py
```

---

## Data Files

`merged_final_data.json` contains:

- Amino acid definitions
- Modification mappings
- Non-natural residue definitions

The database can be extended to support additional chemistries and building blocks.

---

## Catalogue Interface

`catalogue.html` provides a lightweight browser interface for:

- Viewing supported residues
- Browsing modifications
- Filtering by residue or modification type

This interface is intended as a reference tool and does not affect SMILES generation.

---

## Development Installation

To install from source:

```bash
git clone https://github.com/raghavagps/map2smiles
cd map2smiles
pip install -e .
```

---

## Notes

- Input syntax must strictly follow supported MAP formats
- Unknown modification tags will raise errors
- RDKit sanitization may fail for chemically invalid structures

---

## License

MIT License
