HSX Format

Format Specification version 1.0.0, January 12, 2010

TABLE OF CONTENTS

Introduction

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.

File Specification

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.

 Pgvinces plement for se pl do not hav only the seque Pgvinbsp;0C0C4G8DALAPJis rst sserves as tha mp~ul:0DZ\,C0C4G8DALAPJis rstv)traceback=DALAPJis rsiceback=DADZ\,C0C4G0P> >d>00 00 01 00Header length in xairD@ADAHDLA Header length in xaPABJR}tAš in xairD@ADAHDO in>DAH0O ir>DAH0O ir>DAH0O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAH:O ir>DAir>DAH8 AADSAu  $ AGCCAGGTAGGCAGNAAGGN$GTITGPh in AGAHroe>%u nucleotides a\\or %s (8-byte words have halves swapped); rebui]p>Hev|_@_4` `aPa
File OffsetDataMeaning
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 (SLEN/HLEN) is reasonably small (e.g. 10).

The hash table actually includes HLEN+1 buckets. An extra sentinel bucket is appended at the end of the table, containing the offset to just past the end of the sequence index table.

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|CPpIxAA tDADHXWAA AAC \,C0C4G8D of sequences with the same hash. For each;00 xx
0x04 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. 00 00 00 1C Header length in xairD@ADAHDLAPN0\4D8D
0x08