| 1 | # .uniq v5 |
| 2 | |
| 3 | [](https://pkg.go.dev/github.com/shenwei356/uniq) |
| 4 | |
| 5 | This package provides k-mer serialization methods for the package [kmers](https://github.com/shenwei356/kmers), |
| 6 | TaxIds of k-mers are optionally saved, while there's no frequency information. |
| 7 | |
| 8 | This package is used in project [unikmer](https://github.com/shenwei356/unikmer) and [kmcp](https://github.com/shenwei356/kmcp). |
| 9 | |
| 10 | ## Details |
| 11 | |
| 12 | K-mers (represented in `uint64` in RAM ) are serialized in 8-Byte |
| 13 | (or less Bytes for shorter k-mers in compact format, |
| 14 | or much less Bytes for sorted k-mers) arrays and |
| 15 | optionally compressed in gzip format with extension of `.unik`. |
| 16 | |
| 17 | TaxIds are optionally stored next to k-mers with 4 or less bytes. |
| 18 | |
| 19 | ## Compression rate comparison |
| 20 | |
| 21 | No TaxIds stored in this test. |
| 22 | |
| 23 |  |
| 24 | |
| 25 | label |encoded-kmer<sup>a</sup>|gzip-compressed<sup>b</sup>|compact-format<sup>c</sup>|sorted<sup>d</sup>|comment |
| 26 | :---------------|:----------------------:|:-------------------------:|:------------------------:|:----------------:|:------------------------------------------------------ |
| 27 | `plain` | | | | |plain text |
| 28 | `gzip` | |✔ | | |gzipped plain text |
| 29 | `unik.default` |✔ |✔ | | |gzipped encoded k-mers in fixed-length byte array |
| 30 | `unik.compat` |✔ |✔ |✔ | |gzipped encoded k-mers in shorter fixed-length byte array |
| 31 | `unik.sorted` |✔ |✔ | |✔ |gzipped sorted encoded k-mers |
| 32 | |
| 33 | |
| 34 | - <sup>a</sup> One k-mer is encoded as `uint64` and serialized in 8 Bytes. |
| 35 | - <sup>b</sup> K-mers file is compressed in gzip format by default, |
| 36 | users can switch on global option `-C/--no-compress` to output non-compressed file. |
| 37 | - <sup>c</sup> One k-mer is encoded as `uint64` and serialized in 8 Bytes by default. |
| 38 | However few Bytes are needed for short k-mers, e.g., 4 Bytes are enough for |
| 39 | 15-mers (30 bits). This makes the file more compact with smaller file size, |
| 40 | controled by global option `-c/--compact `. |
| 41 | - <sup>d</sup> One k-mer is encoded as `uint64`, all k-mers are sorted and compressed |
| 42 | using varint-GB algorithm. |
| 43 | - In all test, flag `--canonical` is ON when running `unikmer count`. |
| 44 | |
| 45 | |
| 46 | ## License |
| 47 | |
| 48 | [MIT License](https://github.com/shenwei356/unikmer/blob/master/LICENSE) |
| 49 | |
| 50 | ## History |
| 51 | |
| 52 | This package was originally maintained in [unikmer](https://github.com/shenwei356/unikmer). |
| 53 | |
| 54 | The magic number of binary format is still `.unikmer` for keeping compatibility. |