Database
--db <FILE> gives twitcher a persistent cache of alignment results in an SQLite file. Before a cluster is sent to the aligner, twitcher checks the in-memory cache of the current run, then the database; only on a miss is the alignment computed, and its result then written back. Since many individuals share the same mutation clusters, a database filled by earlier runs acts as a panel of known clusters and can skip most of the alignment work.
twitcher vcf sample1.vcf reference.fa --db known.db -o sample1.ts.vcf
twitcher vcf sample2.vcf reference.fa --db known.db -o sample2.ts.vcf # reuses clusters shared with sample1What a result is keyed by
- Configuration: the reference file name (not its path or contents), the aligner settings, including the cost model, and the major version of the tsalign aligner library. Each distinct combination gets a row in the
configurationstable; changing any aligner setting, or a twitcher release that moves to a new tsalign major, starts an empty cache within the same file. - Alignment: the realigned reference region, the alignment ranges within it, and the query sequence (stored 2-bit packed, with positions of
Nand other non-ACGT bases kept separately).
The cluster region is defined the same way for vcf and reads (see Clustering), so results stored by one subcommand are found by the other.
Successful alignments and soft failures are stored; hard errors are not. A cached out-of-memory failure is recomputed if the current run allows more memory than the one that stored it, and a cached timeout if the current timeout is longer.
Modes
--db-mode selects how the file is used:
read-write(default): look up results and store new ones.read-only: look up only. The file is never written; if its directory is not writable, it is opened as immutable, which assumes nobody else writes to it meanwhile.write-only: store new results without looking any up, i.e. recompute everything.
Concurrency and durability
The file is put in WAL mode, so several twitcher processes on the same machine can share one database. Each result is committed as soon as it is computed, so it survives the process being killed and is immediately visible to other jobs. If the database is busy, rows stay pending and are retried with the next write. Jobs on different machines, e.g. on a cluster file system such as Lustre, can share one file too, but will likely run into errors: each commit then holds the lock for seconds, so writes time out, and a job that cannot get the lock at startup exits with an error. A file per machine avoids this.
Schema versions
The schema version is stored in the file’s user_version. A twitcher release that changes the schema refuses to open older files rather than migrating them.