目录

MoonBit VCF Kit

moonbit-vcfkit is a native MoonBit toolkit for Variant Call Format text data. It focuses on the parts that are useful before a project needs the full htslib stack: header inspection, typed record parsing, compact filtering, small transformations, deterministic writing, and testable command behavior.

The package is written in MoonBit and uses synthetic fixtures only. It is intended for developer tools, teaching fixtures, lightweight data checks, and MoonBit ecosystem experiments. It is not a clinical validation tool.

What Works

  • Parse VCF 4.x-style header lines, including INFO, FORMAT, FILTER, contig, fileformat, and generic metadata.
  • Parse records into typed INFO and FORMAT values using header descriptors.
  • Filter records with expressions such as qual >= 30, has info.SOMATIC, and format.TUMOR.DP >= 20.
  • Split multi-allelic records into one alternate allele per output record.
  • Apply basic allele trimming normalization for simple single-alt records.
  • Serialize documents back to stable VCF text.
  • Summarize contigs, filters, INFO keys, sample count, multi-allelic records, and variant classes.
  • Run golden tests across wasm, wasm-gc, JavaScript, and native targets.
  • Provide a small CLI harness package plus cmd/vcfkit entrypoint.

Package Map

  • Root package: domain types, header/record parser, writer, transforms, stats.
  • filter: expression parser and evaluator.
  • cli: pure command dispatcher over VCF text.
  • cmd/vcfkit: executable entrypoint; reads demo input from VCFKIT_INPUT.
  • internal/text: small scanner helpers.
  • internal/normalize: allele trimming helper.

Quick Check

moon version --all
moon check --target all --deny-warn
moon test --target all --deny-warn
moon fmt --check
moon info

The repository also includes:

pwsh scripts/audit.ps1

CLI Demo

The executable path is intentionally thin. For shell demos, pass VCF text through VCFKIT_INPUT:

moon run cmd/vcfkit -- help

Core command behavior is tested through cli.run_cli_text(argv, input), so applications can embed the same logic without depending on shell IO.

Fixture Example

fixtures/basic.vcf contains three synthetic records covering a SNV, a multi-allelic insertion case, a deletion, typed INFO values, and FORMAT sample values. Expected outputs live under fixtures/golden/.

Current Boundaries

This version handles plain VCF text. It does not implement BCF, bgzip/tabix indexing, streaming decompression, external FASTA-backed left alignment, annotation databases, or clinical interpretation.

Source Notes

The implementation is original MoonBit source. VCF behavior is informed by the public hts-specs VCF documents, and MoonBit CI follows the public moonbit-community/.github workflow template shape with stricter warning checks. See docs/sources.md and docs/self-audit.md.

License

Apache-2.0.

关于

Native MoonBit toolkit for parsing, filtering, transforming, and inspecting VCF text data

127.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号