Goal : Simple and Efficient storage of 2d sparse matrices for memory efficient access of rows columns and ranges.
-
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
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 |
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 |
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 |
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()