"""Run every step of our analysis in order, from a folder made by prepare_inputs.py. Fact-Checked Science ("Our analysis"), https://factchecked.science/planthopper-magnetic-genes/ Usage: python3 run_all.py Needs Python 3.9+ with numpy, scipy and pandas (igrf_route.py, clock_genes.py and xlsx_reader.py need only the standard library). Each step's rules file is named beside it. The re-derivation also writes three per-gene CSV files (about 1 MB each), which we don't host. """ import os import subprocess import sys HERE = os.path.dirname(os.path.abspath(__file__)) STEPS = [ # script, arguments (D = dataset folder, F = field folder, O = output folder), rules file ("igrf_route.py", ["F/igrf14coeffs.txt", "F/WMM2025COF.zip", "O/igrf_route.json"], "RULES_igrf_route.txt"), ("deg_recount.py", ["D", "O/deg_recount.json"], "RULES_deg_recount.txt"), ("deg_recount_check.py", ["D/Raw_data_for_Figure1-Complete list of differentially expressed genes in all comparisons.xlsx"], "RULES_deg_recount.txt"), ("go_terms.py", ["D", "O/go_terms.json"], "RULES_go_terms.txt"), ("clock_genes.py", ["D", "O/clock_genes.json"], "RULES_go_terms.txt (G3, descriptive)"), ("rederive.py", ["D", "O"], "RULES_rederive.txt"), ("permutation.py", ["D", "O/permutation.json"], "RULES_permutation.txt"), ("overlap.py", ["D", "O/overlap.json"], "RULES_overlap.txt"), ("field_params.py", ["D", "O/igrf_route.json", "O/field_params.json"], "RULES_field_params.txt"), ("qpcr_rnai.py", ["D", "O/qpcr_rnai.json"], "RULES_qpcr_rnai.txt"), ("exploratory.py", ["D", "O/exploratory.json"], "none: exploratory, not pre-registered"), ("exploratory_loo.py", ["D", "O/exploratory_loo.json"], "none: exploratory, not pre-registered"), ] def main(): if len(sys.argv) != 3: sys.exit("usage: python3 run_all.py ") folder, out = sys.argv[1], sys.argv[2] os.makedirs(out, exist_ok=True) subst = {"D": os.path.join(folder, "dataset"), "F": os.path.join(folder, "field"), "O": out} for script, args, rules in STEPS: real = [] for a in args: head, _, tail = a.partition("/") real.append(os.path.join(subst[head], tail) if tail else subst[head]) print(f"== {script} (rules: {rules})", flush=True) subprocess.run([sys.executable, "-I", os.path.join(HERE, script)] + real, check=True) if __name__ == "__main__": main()