"""Clock genes in the authors' DESeq2 results (descriptive; RULES_go_terms.txt, G3). Data only. Fact-Checked Science ("Our analysis"), https://factchecked.science/planthopper-magnetic-genes/ Data: Xie, W., et al. (2026), Dryad, doi:10.5061/dryad.r4xgxd2vx (CC0); prepare the folder with prepare_inputs.py. Gene names are NCBI Gene's (records read on 20 November 2026, e.g. https://www.ncbi.nlm.nih.gov/gene/111044853); the authors' files name genes by NCBI's LOC numbers. Usage: python3 clock_genes.py /dataset (Python 3.9+, standard library only) """ import json import os import sys sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from xlsx_reader import read_xlsx # noqa: E402 FIG1 = "Raw_data_for_Figure1-Complete list of differentially expressed genes in all comparisons.xlsx" GENES = { # NCBI Gene ID -> (symbol, NCBI description) "111044853": ("cry", "circadian regulator cryptochrome (alias cry1)"), "111059678": ("phr6-4", "(6-4)-photolyase (alias cry2)"), "111059901": ("tim", "timeless"), "111054356": ("per", "period circadian regulator"), "111046258": ("Clk", "circadian locomoter output cycles kaput protein Clock"), "111063388": ("LOC111063388", "protein cycle"), "111050521": ("cwo", "transcription factor cwo"), "111061045": ("Pdfr", "Pigment-dispersing factor receptor"), "111044058": ("LOC111044058", "pigment-dispersing hormone peptides"), } SHEETS = ("DEG_GMF50_vs_GMF45", "DEG_NZMF_vs_GMF45", "DEG_NZMF_vs_GMF50") def main(): folder, out_path = sys.argv[1], sys.argv[2] wb = read_xlsx(os.path.join(folder, FIG1)) rows = {sh: {r[0]: r for r in wb[sh]["rows"][1:] if r} for sh in SHEETS} out = {} for gid, (sym, desc) in GENES.items(): key = "LOC" + gid rec = {"ncbi_symbol": sym, "description": desc} for sh in SHEETS: r = rows[sh].get(key) if r is None: rec[sh] = "not in file" continue padj = None if r[6] in (None, "NA") else float(r[6]) lfc = float(r[2]) rec[sh] = {"log2FC": round(lfc, 3), "padj": padj, "DEG": bool(padj is not None and padj < 0.05 and abs(lfc) > 0.25)} out[key] = rec with open(out_path, "w", encoding="utf-8", newline="\n") as f: json.dump(out, f, indent=1) for k, v in out.items(): print(k, v["ncbi_symbol"], "|", v["description"]) for sh in SHEETS: print(" ", sh, v[sh]) if __name__ == "__main__": main()