a56d88e05670b759ff3b32829542537ccc790c57 lrnassar Tue Apr 28 19:18:20 2026 -0700 Address CR feedback on insight + tp53 hub scripts. refs #37418 Drop duplicated bash() wrappers in favor of subprocess.run / check_output with list args, eliminating shell=True, embedded-quote concerns, and stderr-into-stdout merging. Centralize common operations as run_sort_bed/run_liftOver in tp53FuncLib alongside existing run_bedToBigBed. Switch HTML escaping to stdlib html.escape() consistently. insightHCIPriors mouseover (previously unescaped) now escapes HGVS fields, addressing the specific c.123A>G case Jonathan flagged. Replace invalid
tags with
across all five affected mouseover sites. diff --git src/hg/makeDb/scripts/tp53/tp53Flossies.py src/hg/makeDb/scripts/tp53/tp53Flossies.py index 3410cf07bef..580695ca24b 100644 --- src/hg/makeDb/scripts/tp53/tp53Flossies.py +++ src/hg/makeDb/scripts/tp53/tp53Flossies.py @@ -132,31 +132,31 @@ def hg19_to_hg38_lift(records, outdir): """Lift FLOSSIES hg19 coords to hg38; return dict keyed on variant_id.""" chain = "/gbdb/hg19/liftOver/hg19ToHg38.over.chain.gz" if not os.path.exists(chain): chain = "/cluster/data/hg19/bed/liftOver/hg19ToHg38.over.chain.gz" in_bed = os.path.join(outdir, ".flossies_lift_in.bed") out_bed = os.path.join(outdir, ".flossies_lift_out.bed") unmapped = os.path.join(outdir, ".flossies_unmapped.bed") with open(in_bed, 'w') as f: for v in records: pos = int(v['pos']) ref = v['ref'] f.write("chr{}\t{}\t{}\t{}\n".format( v['chrom'], pos - 1, pos - 1 + len(ref), v['variant_id'])) - lib.bash("liftOver {} {} {} {}".format(in_bed, chain, out_bed, unmapped)) + lib.run_liftOver(in_bed, chain, out_bed, unmapped) lookup = {} with open(out_bed) as f: for line in f: flds = line.rstrip("\n").split("\t") if len(flds) >= 4: lookup[flds[3]] = (flds[0], int(flds[1]), int(flds[2])) for p in [in_bed, out_bed, unmapped]: if os.path.exists(p): os.remove(p) return lookup def emit_rows(records, assembly, hg38_lookup): """Build BED9+8 lines for the requested assembly.""" lines = [] @@ -220,31 +220,31 @@ print(" liftOver matched {}/{} variants".format( len(hg38_lookup), len(records))) lines = emit_rows(records, 'hg38', hg38_lookup) else: lines = emit_rows(records, 'hg19', None) print(" {} BED rows".format(len(lines))) bs2_count = sum(1 for L in lines if "\tBS2\t" in L) print(" BS2 applicable: {}".format(bs2_count)) as_file = os.path.join(outdir, "TP53Flossies.as") lib.write_autosql(as_file, AUTOSQL) bed = os.path.join(outdir, "TP53Flossies_{}.bed".format(db)) with open(bed, 'w') as f: f.write("\n".join(lines) + "\n") - lib.bash("sort -k1,1 -k2,2n {0} -o {0}".format(bed)) + lib.run_sort_bed(bed) bb = os.path.join(outdir, "TP53Flossies{}.bb".format(db.capitalize())) lib.run_bedToBigBed(bed, as_file, bb, lib.chrom_sizes_path(db), "bed9+10") print(" wrote {}".format(bb)) def main(): p = argparse.ArgumentParser(description=__doc__) p.add_argument('-o', '--output-dir', default=DEFAULT_OUTDIR) p.add_argument('--db', action='append', help='hg38 or hg19 (repeat). Default hg38.') p.add_argument('--src', default=DEFAULT_SRC) args = p.parse_args() dbs = args.db if args.db else ['hg38'] for db in dbs: build(db, args.output_dir, args.src)