Metadata-Version: 2.4
Name: scipion-em-cryocodex
Version: 0.3.1
Summary: CryoCodex map enhancement, local quality estimation and molecular masks for Scipion
Author: Bin Cheng, Yang Lab
License: MIT
Project-URL: CryoCodex source, https://github.com/YangLab-SDU/CryoCodex
Keywords: scipion,scipion-3.0,cryoem,cryocodex
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scipion-em>=3.8
Requires-Dist: mrcfile<2,>=1.4
Dynamic: license-file

# CryoCodex-Enhance plugin for Scipion

A Scipion plugin for [CryoCodex](https://github.com/YangLab-SDU/CryoCodex):
density-map enhancement, local quality estimation and molecular mask prediction.
Supports CryoCodex [v1.0.0](https://github.com/YangLab-SDU/CryoCodex/releases/tag/v1.0.0).

## Installation

Requires Linux, Scipion 3 (`scipion-em >= 3.8`), Conda, `wget` and an NVIDIA GPU
with a CUDA-compatible driver. The installer creates a separate Python 3.11
environment and downloads the model automatically.

Install from a downloaded plugin directory:

```bash
scipion3 installp -p /path/to/scipion-em-cryocodex --devel
```

The plugin is not yet published to PyPI. To install the backend separately:

```bash
scipion3 installb cryocodex-1.0.0
```

## Configuration

Defaults work after automatic installation. To use existing software or a model,
set absolute paths in the `[PLUGINS]` section of `scipion.conf`:

| Variable | Default / purpose |
|---|---|
| `CRYOCODEX_HOME` | Scipion's `software/em/cryocodex-1.0.0`; contains `predict.py` |
| `CRYOCODEX_PYTHON` | `CRYOCODEX_HOME/conda-env/bin/python`; Python 3.11 with CryoCodex dependencies |
| `CRYOCODEX_MODEL` | `CRYOCODEX_HOME/model_state_dicts/CryoCodex.pth` |
| `CRYOCODEX_CONDA_EXE` | `CONDA_EXE` or Conda on PATH; used for automatic installation |

```ini
[PLUGINS]
CRYOCODEX_HOME = /path/to/CryoCodex
CRYOCODEX_PYTHON = /path/to/cryocodex-env/bin/python
CRYOCODEX_MODEL = /path/to/CryoCodex.pth
CRYOCODEX_CONDA_EXE = /path/to/miniconda3/bin/conda
```

For an existing CryoCodex v1.0.0 installation, add `--noBin` to the plugin
installation command. These settings are optional, not per-run parameters.

## Verifying

Check plugin integration without a GPU or model:

```bash
scipion3 test cryocodex.tests.test_protocol.TestCryoCodexIntegration
```

Test actual inference after backend installation, on a GPU node:

```bash
CRYOCODEX_TEST_GPU=1 scipion3 test cryocodex.tests.test_protocol.TestCryoCodexGPU
```

Optionally set `CRYOCODEX_TEST_MAP=/path/to/map.mrc` and
`CRYOCODEX_TEST_GPU_ID=0` to choose your input and GPU.

## Protocol

**3D → Postprocess → CryoCodex-Enhance**

Import a volume, select it in the protocol, choose settings and click Execute.
Fast mode removes background; **Check crop** opens the interactive crop editor.
Enable **Restore full map extent** and **Return to input voxel size** to restore
background and native sampling. Results and ChimeraX coloring instructions
appear in Summary.

## Reference

Cheng B, Su B, Yang J. *CryoCodex: learning discrete structural representations
for cryo-EM map post-processing*. bioRxiv (2026).
[doi:10.64898/2026.09.30.755675](https://doi.org/10.64898/2026.09.30.755675).

## Coordinate handling (0.3.1)

Plugin-level origin correction is temporarily disabled. The Origin source option
is removed; prepared inputs retain the file origin and axis-mapped start indices.
Outputs retain backend file headers, without explicitly setting the Scipion Volume
origin. Sampling, cropping and resampling remain enabled. Previous crop
confirmations must be reviewed again. The correction code is retained as comments
in `convert.py` and `protocols/protocol_enhance.py` for future re-enabling.
