← Back to GenBankVault Overview
Package: ncbi-genome-vault v1.1.0
License: GPL-3.0-or-later
Reference Validation: 12/12 automated integration checks passing (tests/integration_tests.rs)
This document specifies the mathematical transformations, biological coordinate conventions, sequence statistics, genetic code mappings, and upstream database invariants implemented in GenBankVault.
GenBankVault enforces modality separation across five NcbiDataType gates to prevent whole-genome assemblies, linear megabase chromosomes, short transcripts/CDSs, circular organellar/prokaryotic replicons, and amino-acid entries from mixing in incompatible coordinate frames.
parsers::infer_gate_for_accession)Case-normalized accession prefixes resolve deterministically:
NP_*, XP_*, WP_*, YP_*, P0*, Q9* -> NcbiDataType::ProteinGCF_*, GCA_* -> NcbiDataType::LinearGenomeNC_012920*, J01415*, NC_000909*, NC_013967*, NC_001732*, NC_001733*, NZ_CP*, or INSDC CP[0-9]* -> NcbiDataType::CircularGenomeNC_0000*, NC_0723*, CM0006* -> NcbiDataType::LinearChromosomeNM_*, NR_*, XM_*, or gene-scoped accessions -> NcbiDataType::Nucleotidequery_router)To avoid ambiguous operator precedence in NCBI Entrez ESearch queries mixing AND and OR, nucleotide queries explicitly parenthesize both disjunction arms:
term = "((" + q + ") AND biomol_mrna[PROP]) OR ((" + q + ") AND linear[Topology] NOT \"complete genome\"[Title])"
parsers::parse_genbank_flatfile)DEFINITION: Indented continuation lines following DEFINITION (raw_line.starts_with(' ')) are concatenated with single spaces until the next top-level column-0 keyword (ACCESSION, VERSION, DBLINK, KEYWORDS, SOURCE, etc.).finalize_genbank_feature handler inspects every source feature's /db_xref="taxon:<id>" qualifier at feature transitions, FEATURES -> ORIGIN, and EOF (metadata-only records), assigning VaultRecord::tax_id while excluding source rows from VaultRecord::annotations.join(...) Intervals (parse_genbank_location_intervals):join(...), order(...), and complement(join(...)) (including multi-line wrapped locations) are parsed into ordered 1-based (start, end) exon intervals in AnnotationFeature::exons. Reverse-strand descending listings such as join(complement(b1..b2), complement(a1..a2)) with b1 > a2 are sorted into ascending genomic coordinate order for consistent exon rendering and export.Let a reference record of length N >= 1 contain a feature interval [fs, fe] (or spliced exons {[e_i_s, e_i_e]}), and let an exported slice cover 1-based endpoints [start, end]:
exporter::remap_feature_for_slice)start <= end, or non-circular topology):L = end - start + 1. An interval [ps, pe] overlapping [start, end] clips to [cs, ce] = [max(ps, start), min(pe, end)] and maps to 1-based slice coordinates:text
a = cs - start + 1
b = ce - start + 1 (1 <= a <= b <= L)
topology_circular && start > end):[start..=N] of length L_pre = N - start + 1 with the post-origin head [1..=end] of length end, giving total slice length L = L_pre + end:text
Pre-origin overlap [start..=N] : a = cs - start + 1, b = ce - start + 1
Post-origin overlap [1..=end] : a = L_pre + cs, b = L_pre + ce
Features that themselves span the origin (fs > fe) are decomposed into [fs..=N] and [1..=fe] before clipping. Contiguous mapped segments separated by <= 1 bp across the origin seam (a_{k+1} <= b_k + 1) merge cleanly into a single continuous slice interval.
Strand::Reverse)When exporting nucleotide records on Strand::Reverse, the output sequence is replaced by its base-wise reverse complement S'[i] = comp(S[L - i + 1]). Every mapped slice interval [a, b] transforms symmetrically under reflection across L:
a_rev = L - b + 1
b_rev = L - a + 1 (with interval ordering re-sorted ascending)
and the feature's relative strand flips (Forward <-> Reverse, leaving Unstranded unchanged).
##FASTA Seqid ConsistencyFor ExportFormat::Gff3, seqid is resolved once (chromosome.unwrap_or(accession)) and applied identically to ##sequence-region <seqid> <start> <end>, column 1 of every GFF3 annotation line, and the embedded ##FASTA sequence identifier (><seqid> ...).
parsers::translate_dna_frame_with_table)For reading frame f in {0, 1, 2} (representing +1, +2, +3) over normalized DNA (U -> T), codons C_k = b[f + 3k .. f + 3k + 3] are translated using either NCBI Table 1 or NCBI Table 2:
| Codon | Standard (GeneticCode::Standard, Table 1) |
Vertebrate Mitochondrial (GeneticCode::VertebrateMitochondrial, Table 2) |
|---|---|---|
ATA |
I (Ile) |
M (Met / Start) |
TGA |
* (Stop) |
W (Trp) |
AGA, AGG |
R (Arg) |
* (Stop) |
| Remaining 60 codons | Identical across Table 1 and Table 2 | Identical across Table 1 and Table 2 |
GenBankVault automatically selects GeneticCode::VertebrateMitochondrial when opening mitochondrial accessions (NC_012920*, transl_table=2, MT locus features, or "mitochondri" titles) while allowing interactive switching in the viewer toolbar.
Over any sequence window containing counts (N_A, N_C, N_G, N_T, N_U):
N_AT = N_A + N_T + N_U
N_GC = N_G + N_C
GC% = 100 * N_GC / max(N_AT + N_GC, 1)
GC_skew = (N_G - N_C) / (N_G + N_C) if (N_G + N_C) > 0, else 0.0
In draw_nucleotide_track, GC% bins are computed exclusively over the active zoomed slice [win_s..win_e] (offset by VaultRecord::sequence_offset) and plotted against explicit 0%, 50%, and 100% horizontal gridlines.
In exporter::build_multifasta_report, records with empty locally cached sequence (rec.sequence.is_empty(), e.g., metadata-only assembly maps) strictly emit ambig_count = 0 and gc_percent = None rather than synthesizing placeholder 'N' characters into quality-assurance counts.
+1.6 Transmembrane ThresholdFor a protein sequence of length M and sliding window size w (default w = 9 centered around position i, half-width h = (w - 1) / 2):
KD_avg(i) = (1 / |W_i|) * SUM_{j = max(0, i-h) .. min(M-1, i+h)} KD_scale(aa_j)
where KD_scale(aa) follows the Kyte & Doolittle (1982) hydropathy index (I=+4.5, V=+4.2, L=+3.8, F=+2.8, C=+2.5, M=+1.9, A=+1.8, G=-0.4, ..., R=-4.5). Following standard Kyte-Doolittle transmembrane segment criteria for 9–19 aa windows, the protein viewer overlays a horizontal +1.6 TM threshold line above 0.0 alongside -4.5 and +4.5 reference ticks.
ncbi_client::clamp_chromosome_fetch_window)Given actual chromosome sequence length N_chr = slen queried from Entrez esummary:
requested = Some((s, e)): clamp to [max(1, s), min(e, N_chr)] when s <= N_chr, or else shift a bounded span [N_chr - min(e - s, 100_000), N_chr] safely inside [1, N_chr].requested = None:N_chr <= 100_000: return (1, N_chr).N_chr >= 11_830_000: preserve classic Human Chr 1 MTHFR window (11_780_000, 11_830_000).100_000 < N_chr < 11_830_000: center a 50 kb window [N_chr/2 - 25_000, N_chr/2 + 25_000].Live NCBI Datasets v2 sequence_reports downloads populate ChromosomeSummary::centromere_bp = None whenever upstream metadata omits centromeric coordinates, rather than fabricating length_bp / 2. Curated reference assemblies (build_verified_seed_catalog) retain published GRCh38.p14 and SGD R64 centromere coordinates.
SHA-256 computed over <accession>|<len>|<ann_len>|<sequence> (parsers::compute_record_sha256).340 ms (<= 3 req/s unauthenticated) or 105 ms (<= 10 req/s with NCBI_API_KEY).NC_012920.1). Nature Genetics, 23(2), 147.eutils.ncbi.nlm.nih.gov, api.ncbi.nlm.nih.gov/datasets/v2).