Skip to content

Find conserved sequences

Historically conserved sequences (HCS) are stretches of the alignment whose most common k-mer is carried by (almost) every sequence; see Historically conserved sequences for the method.

Terminal window
dima analyze -i spike.fasta -o spike.json --hcs-output spike.hcs.json

The regions are also written as <name>.hcs.tsv by --tsv-dir, and as a single table by -o FILE.tsv --table hcs. --hcs-output takes .json or .tsv, optionally followed by .gz or .zst.

The default threshold is the paper’s, 100%: positions where every sequence with a valid k-mer carries the Index (Tharanga et al. 2025). Set another with --hcs-min-incidence, a value above 50 and at most 100 (decimals allowed, compared exactly):

Terminal window
dima analyze -i hiv.fasta -o hiv.json --hcs-output hiv.hcs.tsv --hcs-min-incidence 70

Regions are computed from the results, so you can explore thresholds without reanalysing the alignment:

Terminal window
dima hcs -i spike.json # 100%, JSON on standard output
dima hcs -i spike.json --hcs-min-incidence 95 -o spike.hcs95.tsv
dima hcs -i spike.json.zst --hcs-min-incidence 90 --hcs-eligible-only -O tsv

dima hcs prints how many regions it found on standard error.

Terminal window
dima hcs -i mers.json -O tsv | head -3
region_id start_column end_column length min_incidence min_support conservation_lower_bound_95 flagged low_support_position_count sequence
1 7 22 16 100.0 170 0.9785344450190554 false 0 LLMFLLTPTESYVDVG
2 35 83 49 100.0 171 0.9786586254334971 false 0 IQQTFFDKTWPRPIDVSKADGIIYPQGRTYSNITITYQGLFPYQGDHGD

For each region: the alignment columns it covers and its sequence; the lowest Index incidence and the lowest support among its member positions; the lowest exact 95% Clopper–Pearson lower bound of their conservation (Clopper & Pearson 1934); and whether it is flagged because positions in its span have support at or below T . The JSON output adds every member position with its k-mer, count, support, incidence and bound, and the list of low-support positions; see JSON outputs.

A region is flagged when it spans positions supported by T sequences or fewer — “100% conserved” may then mean 3 of 3 sequences. DiMA keeps such regions, as the DiMA lineage did (Abd Raman et al. 2020; Hu et al. 2013), but marks them and warns (hcs_low_support_regions). Look at min_support and conservation_lower_bound_95: a k-mer carried by all of 3 sequences has a lower bound of 29.2%, by all of 100 sequences 96.4%.

To build regions from well-supported positions only, add --hcs-eligible-only: positions with support ≤ T cannot be members, and they end a region instead of being included in it.

  • 100% (default) asks for complete conservation, the paper’s definition.
  • Lower thresholds tolerate rare variants; above 50% the most common k-mer is still unique at every member position, which is why lower values are refused.
  • Report the threshold and whether eligible-only was used; both are recorded in the output (parameters).

Examples on the paper’s datasets are in Historically conserved sequences.

  • Abd Raman HS, Tan S, August JT, Khan AM. Dynamics of Influenza A (H5N1) virus protein sequence diversity. PeerJ. 2020;7:e7954. doi:10.7717/peerj.7954 ↩︎
  • Clopper CJ, Pearson ES. The use of confidence or fiducial limits illustrated in the case of the binomial. Biometrika. 1934;26(4):404-413. doi:10.1093/biomet/26.4.404 ↩︎
  • Hu Y, Tan PT, Tan TW, August JT, Khan AM. Dissecting the Dynamics of HIV-1 Protein Sequence Diversity. PLoS ONE. 2013;8(4):e59994. doi:10.1371/journal.pone.0059994 ↩︎
  • Tharanga S, Ünlü ES, Hu Y, Sjaugi MF, Çelik MA, Hekimoğlu H, Miotto O, Öncel MM, Khan AM. DiMA: sequence diversity dynamics analyser for viruses. Briefings in Bioinformatics. 2025;26(1):bbae607. doi:10.1093/bib/bbae607 ↩︎