libbiosyntax

User guide

This guide covers supported formats, the highlighting model, class metadata, and example CLIs.

Supported formats

biosyn_guess_format_from_path() recognizes BioSyntax-style FASTA scheme extensions such as .faa/.fastaa, .fas/.mfa, .fastahydro, .fastaylor, and .fastza.

Highlighting details

libbiosyntax returns semantic token classes rather than final colors only. Important token families include:

Class metadata and default colors

The C library includes built-in BioSyntax-inspired class metadata. No external theme file is required at runtime. Applications can retrieve class names, scopes, ANSI SGR fragments, foreground colors, background colors, and font style hints:

const char *biosyn_class_name(biosyn_class_t class_id);
const char *biosyn_class_scope(biosyn_class_t class_id);
const char *biosyn_class_ansi_sgr(biosyn_class_t class_id);
const char *biosyn_class_default_foreground(biosyn_class_t class_id);
const char *biosyn_class_default_background(biosyn_class_t class_id);
const char *biosyn_class_default_font_style(biosyn_class_t class_id);

biosyn_class_info_t info;
int ok = biosyn_class_info(BIOSYN_CLASS_NT_A, &info);

Use biosyn_class_count() to iterate over all token classes. The metadata API is the supported way to build editor themes, GUI styles, or binding-level lookup tables.

CLI examples

bcat is the simplest ANSI-rendering example. It is a small POSIX C program for plain text input:

make examples
build/bcat -f vcf sample.vcf
build/bcat -f fasta-zappo proteins.fa
build/bcat sample.fa

biocat is the HTSlib-backed example for compressed and binary bioinformatics files:

make biocat
build/biocat sample.vcf.gz
build/biocat sample.bam

biocat reads input through HTSlib, including .gz/.bgz text, BAM, CRAM, and BCF. Binary alignment and variant files are converted to SAM or VCF text in the CLI before highlighting.

Build both examples with:

make examples
make biocat

Only biocat is linked with HTSlib. Install HTSlib development headers and library before running make biocat. The core library itself has no HTSlib dependency.