qualia_core_db/q42/chebi_parse/mod.rs
1//! ChEBI compounds.tsv local parser (AST-03).
2//!
3//! # Format
4//!
5//! Parses one documented ChEBI FTP-style bulk TSV from a **caller-selected**
6//! local byte slice (or path). No network I/O. Tiny synthetic fixtures only in
7//! tests.
8//!
9//! Required header (tab-separated):
10//!
11//! ```text
12//! ID STATUS CHEBI_ACCESSION SOURCE PARENT_ID NAME DEFINITION
13//! ```
14//!
15//! | Column | Notes |
16//! |--------|--------|
17//! | `ID` | Integer string (e.g. `15377`) |
18//! | `STATUS` | Preserved as text (`C` / `E` / `D` …); `D` → quarantine |
19//! | `CHEBI_ACCESSION` | e.g. `CHEBI:15377` (must match `ID`) |
20//! | `SOURCE` | Free text; may be empty |
21//! | `PARENT_ID` | Integer or empty → `None` |
22//! | `NAME` | Required non-empty (after trim) for acceptance |
23//! | `DEFINITION` | May be empty; preserved |
24//!
25//! Optional trailing columns are accepted and ignored.
26//!
27//! # Quarantine vs error
28//!
29//! - Oversize whole input (`max_bytes`) → `ParseError::ByteBudgetExceeded`
30//! - Oversize single line (`max_line_bytes`) → `ParseError::LineTooLong`
31//! - Header mismatch / missing → `ParseError::BadHeader`
32//! - Cancel flag set → `ParseError::Cancelled`
33//! - Deleted / malformed / empty-name rows → `QuarantinedRow` (others continue)
34//!
35//! Cold construction: `String` fields are intentional. Hot-path Quin mapping is
36//! AST-04.
37
38mod error;
39mod parse;
40mod record;
41mod tsv;
42
43pub use error::{bounded_preview, ParseError, QuarantinedRow, RAW_PREVIEW_MAX};
44pub use parse::{parse_compounds_tsv, parse_compounds_tsv_path};
45pub use record::{ChebiRecord, ParseBudgets, ParseReport};
46pub use tsv::{accession_ok, header_matches, COMPOUNDS_HEADER, REQUIRED_COLUMNS};