October 2026
mcon-tool - Transform structured sample logs and convert them to tables.
mcon-tool [OPTIONS] [FILE]
Read a sample log, optionally transform its fields, and write MCON or tab-separated values (TSV) to standard output. MCON consists of a JSON header followed by one JSON object per sample. Unlike a rectangular table, it can hold arrays, objects, and fields whose structure changes between samples.
Input may be MCON or a TSV table with a header row. TSV cells are parsed as JSON values: numbers and booleans can be written directly, while strings require JSON quotes. Omit the filename to read standard input; an explicit - is treated as a literal filename.
Transformations run in a fixed order regardless of option order: drop fields, unnest groups, atomize structured values, split by structure, and add record numbers. Output defaults to MCON, preserving structure unless transformed.
MCON grouping keys ending in a single slash contribute a prefix to field names; keys ending in two slashes are transparent groups and contribute no prefix. --unnest replaces this grouping with flat logical names. --atomize instead expands structured field values into scalar components, with bracketed object keys or one-based array indices.
For example, with nested grouping, a sample containing
{"P1/":{"rates":[0.2,0.8]}} becomes
{"P1/rates":[0.2,0.8]} after unnesting. Using both
transformations gives fields P1/rates[1] and
P1/rates[2].
TSV conversion automatically expands structured values and retains fields with stable structure across samples. Missing or structurally varying fields are omitted and listed on standard error. A change in an array's length or an object-valued parameter's keys removes that entire value: its remaining components may have changed meaning. MCON groups contain separate fields, so a varying field does not discard its siblings. Output column names have group prefixes shortened where unambiguous.
Explicit --atomize expands values before this stability check, allowing components to survive independently. --split can instead produce separate tables for different structures, retaining fields that a combined table omits.
P1/rates to remove the array. Put
the input filename before this multiple-value option, or separate it
from the field list with --.
Convert a structured log to a table of stable fields:
mcon-tool run-1/C1.log.json --output TSV > samples.tsv
Remove a structured parameter and flatten the remaining group names:
mcon-tool samples.json --unnest --drop P1/rates > reduced.json
Write one TSV file per structure, discarding the combined stdout table:
mcon-tool samples.json --split part --output TSV > /dev/null
Returns 0 on success (including help) and 1 on an error.
statreport(1), stats-cat(1), stats-select(1)
BAli-Phy online help: https://www.bali-phy.org/docs.php.
Please send bug reports to bali-phy-users@googlegroups.com.