# MolX
MolX is an interactive protein-structure viewer for graphical terminals. It
opens PDB files, renders the molecule as a high-resolution raster, and lets you
rotate and zoom without leaving the command line. It also connects to the ESM
Metagenomic Atlas to fetch existing predictions or fold a short amino-acid
sequence with the public ESMFold service.
The viewer uses the repository's `rstui` runtime and automatically selects
Kitty graphics, iTerm2 images, Sixel, or an ANSI truecolor fallback.
## Build and run
```bash
cd molx
cargo run --release -- view protein.pdb
```
Install the `molx` command from this checkout:
```bash
cargo install --path molx
molx view protein.pdb
```
## PDB viewer
```bash
molx view protein.pdb
molx view protein.pdb --representation atoms --color element
molx view prediction.pdb --representation combined --color confidence
molx info protein.pdb
molx snapshot protein.pdb --output protein.png
```
MolX reads the first model in a PDB file, keeps the primary alternate location,
shows `ATOM` and `HETATM` records, and constructs a gap-aware C-alpha backbone
trace. Available representations are `backbone`, `atoms`, and `combined`.
Controls:
- Drag with the left mouse button, or use arrow keys / `h`, `j`, `k`, `l`, to rotate.
- Use the mouse wheel or `+` / `-` to zoom.
- Press `m` to cycle molecular representations.
- Press `c` to cycle chain, element, and pLDDT/B-factor colors.
- Press Space to toggle automatic rotation.
- Press `r` to reset the camera and `q` or Escape to quit.
For ESMFold structures, `--color auto` selects the pLDDT palette used by the
Atlas: blue is high confidence and red is low confidence.
## ESM Atlas
Download an existing prediction by MGnify protein identifier:
```bash
molx atlas fetch MGYP002537940442
molx atlas fetch MGYP002537940442 --output example.pdb --view
```
Fold one sequence using the public ESMFold endpoint:
```bash
molx atlas fold --sequence MKTAYIAKQRQISFVKSHFSRQ --output folded.pdb --view
molx atlas fold --fasta protein.fasta --output folded.pdb
```
Existing output files are preserved unless `--force` is passed. The public API
is rate-limited and intended for a small number of interactive predictions, not
bulk folding. MolX limits requests to 1,024 residues and uses a five-minute
request timeout. The Atlas data is distributed under CC BY 4.0; retain the
appropriate attribution when redistributing downloaded structures.
Official resources:
- <https://esmatlas.com/about#api>
- <https://github.com/facebookresearch/esm>
## Current scope
This first version focuses on local PDB viewing and stable public ESM Atlas
operations. mmCIF parsing, residue selection, surfaces, ligand bond inference,
measurements, and sequence/structure search are natural next modules.