TABLE OF CONTENTS
HSX is a binary file format for indexing (or listing) DNA sequences in other files, allowing fast random access to those sequences. The format was created as part of the LASTZ project, providing a means to input selected sequences from several short read files into a single run of LASTZ.
This document is provided for users interested in creating HSX files with programs of their own design.
The HSX file contains a sequence index array and an associated hash table. Each sequence index entry includes the sequence's name, length, and a reference to the location of the sequence's data in some other file. This array can be accessed either sequentially or via the hash table. Note that the names in the index file do not have to match the original names or headers in the sequence files.
Sequence entries are ordered by the hashes of their names. Conceptually, the hash table groups the sequences into buckets of sequences with the same hash. For each bucket, the table gives the location in the sequence index of the first sequence in that bucket. Hash collisions are resolved by scanning subsequent index entries for the remaining sequences in the bucket.
There is also a file table, which allows a single index file to cover sequences from multiple sequence files of varying formats. However, currently LASTZ only supports indexing of files in FASTA format.
The file is stored in a binary format described by the table below. It can be written on either a big-endian or little-endian machine; programs reading the file determine the byte order of multi-byte fields by examining the magic number at the start of the file.
| File Offset | Data | Meaning |
0x00 |
D2 52 70 95
—or— 95 70 52 D2 |
Magic number indicating big-endian byte order.
Magic number indicating little-endian byte order. |
0x04 |
00 00 01 00 |
File conforms to version 1.0 of the HSX file format. |
0x08 |
00 00 00 1C |
Header length in bytes, including this field through the SOFF field. |
0x0C |
00 00 00 xx |
FLEN:
number of entries in the file table (limited to 255). |
0x10 |
xx xx xx xx |
FOFF:
offset (from file start) to the file table. |
0x14 |
xx xx xx xx |
HLEN:
number of buckets in the hash table. This also serves as the modulus for
the hash function.
Typically the number of buckets is set so that the average number of
sequences per bucket (
The hash table actually includes |
0x18 |
xx xx xx xx |
HOFF:
offset (from file start) to the hash table. |
0x1C |
xx xx xx xx |
Sspan class=ttab>
number of entries in the file tabl|CPpIxAAtDADH X W AAAAC \,C0C4G8D |