A Basic Reader and Writer for CRAM format
Project description
Compressed Row-Access Matrix file format.
Goal : Simple and Efficient storage of 2d sparse matrices for memory efficient access of rows columns and ranges.
File Structure:
-
Header Section:
- Describes the overall file metadata.
- Fixed size for simplicity.
-
Index Section:
- Row Index
- Maps rows to their corresponding data offsets in the file.
- Row Index
-
Data Section:
- Row Data
- Contains the actual sparse matrix data in a compressed Row Format. along with the column number
- Row Data
Detailed Layout
1. Header Section
Description: File identifiers and general fine info
Size: 40 bytes
| Field | Type | Size (Bytes) | Description |
|---|---|---|---|
| Magic Number | ASCII | 4 | File identifier - CRAM |
| Version | Integer | 2 | File format version |
| Rows | Integer | 4 | Number of rows in the matrix |
| Columns | Integer | 4 | Number of columns in the matrix |
| Non-Zero Count | Integer | 8 | Total number of non-zero entries |
| Index Offset | Integer | 8 | Byte offset to the index section |
| Data Offset | Integer | 8 | Byte offset to the data section |
2. Index Section
Description: Maps Rows to their corresponding data offsets
Size: 16 bytes
| Field | Type | Size (Bytes) | Description |
|---|---|---|---|
| Row ID | Integer | 4 | Row ID |
| Offset | Integer | 8 | Byte offset in the data section |
| Non-Zero Count | Integer | 4 | Number of non-zero entries |
3. Data Section
Description: Data elements of the
Size: 8
| Field | Type | Size (Bytes) | Description |
|---|---|---|---|
| Column Index | Integer | 4 | Column index of the value |
| Value | Float | 4 | The matrix value |
Installation
To install the package
pip install sparse-CRAM
Usage:
cram_path = '/path/to/cram_file.cram'
fileparser = CRAM.FileParser(cram_path)
headers = fileparser.parse_headers()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sparse_cram-0.1.6.3.tar.gz.
File metadata
- Download URL: sparse_cram-0.1.6.3.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae5570d74d2a74929ba946a5e1afdc56202de517080bca8f2cf8fae13011274a
|
|
| MD5 |
ffc4dd8795e0b8281b532243d6f9dfa5
|
|
| BLAKE2b-256 |
42bfccb56f95a1d723248e2c8791fbf76dce3ffd994c34a0e349aa0f852273c2
|
File details
Details for the file sparse_cram-0.1.6.3-py3-none-any.whl.
File metadata
- Download URL: sparse_cram-0.1.6.3-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.4 CPython/3.13.0 Darwin/22.6.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6ce84eea4a463ef793f4de3e1efc4d0ca076858b7d3cdf8cfdc503b5e02abee
|
|
| MD5 |
392872bd26472404b37a3c1724d7f3a6
|
|
| BLAKE2b-256 |
2bce3bf32e4e4e855323e9dff3eff9d312e16807e6b7f16f389fb38a028f9841
|