Expand description
ChEBI compounds.tsv local parser (AST-03). ChEBI compounds.tsv local parser (AST-03).
§Format
Parses one documented ChEBI FTP-style bulk TSV from a caller-selected local byte slice (or path). No network I/O. Tiny synthetic fixtures only in tests.
Required header (tab-separated):
ID STATUS CHEBI_ACCESSION SOURCE PARENT_ID NAME DEFINITION| Column | Notes |
|---|---|
ID | Integer string (e.g. 15377) |
STATUS | Preserved as text (C / E / D …); D → quarantine |
CHEBI_ACCESSION | e.g. CHEBI:15377 (must match ID) |
SOURCE | Free text; may be empty |
PARENT_ID | Integer or empty → None |
NAME | Required non-empty (after trim) for acceptance |
DEFINITION | May be empty; preserved |
Optional trailing columns are accepted and ignored.
§Quarantine vs error
- Oversize whole input (
max_bytes) →ParseError::ByteBudgetExceeded - Oversize single line (
max_line_bytes) →ParseError::LineTooLong - Header mismatch / missing →
ParseError::BadHeader - Cancel flag set →
ParseError::Cancelled - Deleted / malformed / empty-name rows →
QuarantinedRow(others continue)
Cold construction: String fields are intentional. Hot-path Quin mapping is
AST-04.
Structs§
- Chebi
Record - One accepted ChEBI compound row from
compounds.tsv. - Parse
Budgets - Caller-supplied parse ceilings for one compounds.tsv pass.
- Parse
Report - Result of a successful (possibly partially quarantined) parse pass.
- Quarantined
Row - One quarantined source row (not accepted into the normalized set).
Enums§
- Parse
Error - Fail-closed errors for the cold-construction ChEBI TSV parser.
Constants§
- COMPOUNDS_
HEADER - Documented ChEBI FTP-style
compounds.tsvheader (seven required columns). - RAW_
PREVIEW_ MAX - Maximum bytes retained in
QuarantinedRow::raw_preview. - REQUIRED_
COLUMNS - Minimum columns required; trailing extras are ignored.
Functions§
- accession_
ok - Validate accession shape:
CHEBI:+ decimal digits (case-sensitive prefix). - bounded_
preview - Build a bounded preview from a raw line (no NUL expansion; chars truncated).
- header_
matches - Return true when
fieldsstarts with the documented header names. - parse_
compounds_ tsv - Parse ChEBI FTP-style
compounds.tsvbytes into accepted records and quarantined rows. - parse_
compounds_ tsv_ path - Convenience: read a caller-selected local path then parse (no network).