Metadata-Version: 2.4
Name: gwseq_io
Version: 0.9.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Rust
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Typing :: Typed
Requires-Dist: numpy
Requires-Dist: build ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: maturin>=1.7,<2.0 ; extra == 'dev'
Requires-Dist: gwseq-io[test] ; extra == 'dev'
Requires-Dist: pytest ; extra == 'test'
Requires-Dist: mypy ; extra == 'test'
Requires-Dist: pandas ; extra == 'test'
Requires-Dist: scipy ; extra == 'test'
Requires-Dist: openpyxl ; extra == 'test'
Provides-Extra: dev
Provides-Extra: test
License-File: LICENSE
Summary: Python library for processing bigWig, bigBed, BAM, CRAM, HiC, GTF and FASTA files (Rust)
Author-email: Arthur Gouhier <ajgouhier@gmail.com>
License-Expression: BSD-3-Clause
Requires-Python: >=3.11
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Repository, https://github.com/ajgouhier/gwseq_io

# gwseq_io

Read the files genome-scale sequencing produces, from Python or the command line.
The parsing, indexing and binning are done in Rust, and results reach numpy without a
copy.

| Format | What you can do | Reference |
|---|---|---|
| bigWig, bigBed | Read binned values and entries, write files, convert from bedGraph, WIG and BED | [bbi_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/bbi_api.md) |
| BED, peak tables | Read into memory, with the same calls as a bigBed | [bed_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/bed_api.md) |
| GTF, GFF3 | Read records and gene models, sort, index | [gtf_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/gtf_api.md) |
| FASTA | Read bases and base probabilities, index | [fasta_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/fasta_api.md) |
| BAM, CRAM | Read alignments, index, pile up into a coverage bigWig | [alignment_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/alignment_api.md) |
| HiC | Read contact matrices, quantify contacts | [hic_api](https://github.com/ajgouhier/gwseq_io/blob/main/docs/hic_api.md) |

Every format reads from a local path or an `http(s)://` URL, into numpy arrays and
tables of columns.

- [Core API](https://github.com/ajgouhier/gwseq_io/blob/main/docs/core_api.md): what every format shares, including regions, binning, tables and errors.
- [Command line](https://github.com/ajgouhier/gwseq_io/blob/main/docs/cli.md): the `gwseq-io` command.
- [Development](https://github.com/ajgouhier/gwseq_io/blob/main/docs/development.md): building and testing.
- [Architecture](https://github.com/ajgouhier/gwseq_io/blob/main/docs/architecture.md): the design.

Every example in these pages is run by the test suite, and every signature is checked
against the package's source.


## Install

```text
pip install gwseq-io
```

This installs the package, the `gwseq-io` command and numpy. Only a source distribution
is published, so pip compiles the extension on your machine. That needs
[Rust](https://rustup.rs) 1.85 or newer and Python 3.11 or newer. The extension is pure
Rust, so it needs no C compiler or Python headers.

`cargo install --path crates/gwseq-io-cli`, from a checkout, builds the same command
without Python.


## Quick start

```pycon
>>> import gwseq_io
>>> with gwseq_io.open("signal.bw", "w", chr_sizes={"chr1": 10_000}) as writer:
...     writer.write_values("chr1", 0, 100, [0.5, 1.0, 1.5, 2.0])
>>> reader = gwseq_io.open("signal.bw")
>>> reader
<gwseq_io.BigWigReader chromosomes=1>
>>> reader.read_values("chr1:1-400", bin_size=100)
array([[0.5, 1. , 1.5, 2. ]], dtype=float32)
>>> reader.quantify(["chr1:1-200", "chr1:201-400"])
array([0.75, 1.75], dtype=float32)
```

The same from the command line:

```console
$ gwseq-io read signal.bw -r chr1:1-400 --bin-size 100
chr1    0    400    0.5    1    1.5    2
$ gwseq-io quantify signal.bw -r chr1:1-200 -r chr1:201-400
chr1    0    200    0.75
chr1    200  400    1.75
```

