Metadata-Version: 2.4
Name: nuc2d
Version: 0.3.0
Summary: Nuc2D visualizes RNA and DNA secondary structures as publication-ready SVG images.
Author: Soma Ishii
License-Expression: MIT
Project-URL: Repository, https://github.com/Soma-yu/nuc2d
Keywords: nucleic acid,RNA,DNA,secondary structure,visualization
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: matplotlib
Requires-Dist: svgwrite
Dynamic: license-file

# Nuc2D

Nuc2D visualizes RNA and DNA secondary structures as publication-ready SVG images.

<p align="center">
  <img src="https://raw.githubusercontent.com/Soma-yu/nuc2d/main/docs/images/example.png" width="80%">
</p>

## Installation

```bash
pip install nuc2d
```

## Quick start

```python
from nuc2d import draw_svg

dpp_string = "(((..+...)))"

svg = draw_svg(
    dpp_string=dpp_string,
)

svg.saveas("output.svg")
```

The `dpp_string` argument should be specified in dot-parens-plus notation.

If you are using Jupyter Notebook or JupyterLab, you can also display
the generated SVG directly:

```python
from IPython.display import SVG, display

display(SVG(svg.tostring()))
```

## Sequence annotation

Nucleotide sequences can be provided through the `sequences` argument.
```python
sequences = ["AUGCA", "UGCCAU"]

svg = draw_svg(
    dpp_string=dpp_string,
    sequences=sequences,
)
```

## Base-pair probability visualization

Base-pair probabilities can be visualized by providing a symmetric
base-pair probability matrix through the `probs` argument.
```python
# Base-pair probability matrix from a structure prediction tool.
# probs[i][j] is the probability of nucleotides i and j forming a base pair.
# The diagonal probs[i][i] represents the probability that nucleotide i is unpaired.
probs = ...

svg = draw_svg(
    dpp_string=dpp_string,
    probs=probs,
)
```

## Output

`nuc2d` renders structures as SVG, making the resulting figures
suitable for further editing and use in presentations and
publications.

## License

This project is licensed under the MIT License.
