Chemical Game Theory — Supplementary Python Source Code
=======================================================

Purpose
-------
This archive provides the Python source-code implementation corresponding to the
computational workflow described in Section 3.17 of the manuscript
"Chemical Game Theory: Linking Metabolite Diversity, Biosynthetic Architecture,
and Realized Payoffs".

The scripts are supplied as supplementary information for transparent,
inspectable reproducibility. They are not a maintained software package, API, or
standalone application.

Files
-----
1. cgt_core.py
   Core calculations: compositional closure; Shannon, Pielou and Hill
   descriptors; pathway entropy and intrapathway diversity; GBDI; aggregation at
   metabolite, chemical-class and biosynthetic-pathway levels; zero replacement;
   realized chemical payoff; payoff impact; positive-payoff summaries;
   zero-replacement sensitivity; Shannon decomposition; Friedman tests;
   paired Wilcoxon tests with Holm correction; Pearson correlations; and
   numerical validation checks.

2. run_cgt_analysis.py
   Command-line workflow that reads a tidy composition table and writes auditable
   CSV outputs for the complete analysis.

3. validate_cgt.py
   Synthetic-data self-test. This verifies mathematical identities and code
   execution only; it does not replace the empirical data supplied in
   Supplementary File S1.

4. requirements.txt
   Python package versions used/expected by the supplementary scripts.

Input data
----------
The empirical data remain in Supplementary File S1. For direct execution, provide
a tidy CSV/TSV/XLSX table containing the following columns:

month
compartment
compound
abundance
chemical_class
pathway

The compartment labels used in the manuscript are:
Leaves, Stage I, Stage II, Stage III, Stage IV.

Abundance may be reported peak area, percentage, or another non-negative relative
scale. Each month-compartment profile is closed to unit sum by the script before
calculating descriptors.

Typical execution
-----------------
python run_cgt_analysis.py --input composition.csv --output results

For an Excel file:
python run_cgt_analysis.py --input composition.xlsx --sheet Input --output results

Validation
----------
python validate_cgt.py

Expected validation criteria include:
- each normalized state sums to 1;
- exact Shannon decomposition residual is approximately 0;
- abundance-weighted realized payoff is centered at approximately 0 for each
  transition;
- the statistical workflow executes over the five monthly blocks.

Relationship to Supplementary File S1
-------------------------------------
Supplementary File S1 remains the canonical data and formula-driven numerical
audit trail. This archive provides the corresponding Python implementation of the
reported calculations. The two supplementary resources are complementary rather
than competing canonical records.

Methodological conventions reproduced here
-------------------------------------------
- GBDI exponent alpha = 0.5.
- Primary zero replacement: 0.5 x the smallest positive abundance at the
  corresponding analytical hierarchy, followed by reclosure.
- Sensitivity replacement: 0.1 x the smallest positive abundance, followed by
  reclosure.
- Realized payoff uses centered log growth relative to the initial-abundance-
  weighted chemical background.
- Payoff impact uses original normalized abundances before zero replacement.
- Monthly samples are paired blocks for Friedman and paired Wilcoxon analyses.
- Leaves are a vegetative reference and are not treated as Stage 0 in the ordered
  payoff trajectory.

Authors should verify the final archive against Supplementary File S1 before
submission and preserve this archive unchanged as the version supplied to the
journal.
