e6d1189bea4cc541396f842b65a3392c33c8e734 max Wed Sep 2 02:55:03 2026 -0700 hprc2annot: put the collection in git and fix the QA findings The HPRC Release 2 GenArk contributed track collection (7 tracks x 462 assemblies) had only its one-line betaGenArk.txt enable checked in. Add the makeDoc, the build scripts, the seven track description pages and the trackDb stanzas, and fix the problems QA found. Data fixes, both rebuilt across all 462 assemblies: - liftoff: gff3ToGenePred was naming each genePred after the gene, so every transcript of a gene shared one name, the RefSeq accession was lost and the transcript_biotype lookup never matched (type empty on 99.8% of rows). Pass -rnaNameAttr=ID. Duplicate (chrom,start,end,name) tuples go from 24,969 to 0 and type is now empty on 2,132 of 82,973,730 rows. The same flag is a no-op on the CAT GFF3 (byte-identical output), so both gene tracks now share one code path and CAT needs no rebuild. - segdups: the build read SEDEF column 6, strand1, which is "+" by construction on every row, so every inverted duplication rendered forward. Use column 14, strand2, the orientation of the paralogous copy: 13.8M + and 13.8M - across the collection. Also translate the paralog partner out of PanSN through the GenArk chromAlias, since the browser does not translate a plain text field, and store identity as a percentage so the mouseover can read it. hprc2annotFixBed.sh is not idempotent for pclai: a second run re-parses an already-parsed name and blanks the values. It now refuses to touch a converted file. GCA_041900255.1 was damaged that way and is rebuilt from source. Provenance, all from the QA report: - stats.tsv is appended to rather than truncated on every run, and each run regenerates log/summary.tsv, a per-track roll-up over the collection. - dataVersion on all seven tracks. - Rows are now dropped for exactly two reasons and both are counted: past the end of the sequence, or a sequence name absent from the assembly, which also warns with example names. Only GCA_018472765.3 trips the second, the known upstream contig-version mismatch. genePredToBigGenePred failure is checked and an empty conversion result is a failure, not a valid empty bigBed. Description pages: fix a raw UTF-8 character, rewrite the segdups and pclai display conventions which still described the data before the name field was blanked, add a color legend checked against the data, add the pcLAI preprint (from the Crossref record, since it has no PMID), and correct the stated reason liftoff drops transcripts. Display: title case on the short labels, "Active centromeres" shortened to fit the 17-character limit, pcLAI to pack since it has no readable dense state, liftoff and segdups to dense, and a filter on the segdups original flag. refs #35415 diff --git src/hg/makeDb/scripts/hprc2annot/hprc2annotFillCdsPhase.py src/hg/makeDb/scripts/hprc2annot/hprc2annotFillCdsPhase.py new file mode 100755 index 00000000000..6fdb07c147a --- /dev/null +++ src/hg/makeDb/scripts/hprc2annot/hprc2annotFillCdsPhase.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python3 +"""Fill in the CDS phase (column 8) of a GFF3 whose CDS features all have '.'. + +The HPRC liftoff GFF3 files leave the phase column empty ('.') on every CDS, +which makes gff3ToGenePred reject every coding transcript ("no exonFrame on +CDS"). This recomputes the standard GFF3 phase per transcript. + +Reads GFF3 on stdin, writes the same GFF3 on stdout with CDS phase filled. +CDS lines that already carry a numeric phase are left untouched. CDS features +are grouped by their Parent attribute; within a transcript they are ordered by +genomic position (5'->3' for the strand) and the phase of each CDS is +(3 - (cumulative length of preceding CDS) % 3) % 3, with the first CDS = 0. + +Assumes the CDS lines of one transcript are contiguous in the file (true for +the liftoff output), so it streams with only the current transcript buffered. +""" +import sys, re + +parentRe = re.compile(r'(?:^|;)Parent=([^;]+)') + +def flush(buf, out): + """buf: list of (fields_list). Compute phase, write in original order.""" + if not buf: + return + strand = buf[0][6] + # order 5'->3' + order = sorted(range(len(buf)), key=lambda i: int(buf[i][3]), + reverse=(strand == '-')) + cum = 0 + phase = {} + for i in order: + f = buf[i] + phase[i] = (3 - (cum % 3)) % 3 + cum += int(f[4]) - int(f[3]) + 1 + for i, f in enumerate(buf): + if f[7] == '.': + f[7] = str(phase[i]) + out.write('\t'.join(f)) + out.write('\n') + +def main(): + out = sys.stdout + buf = [] + curParent = None + for line in sys.stdin: + if line.startswith('#') or '\t' not in line: + flush(buf, out); buf = []; curParent = None + out.write(line); continue + f = line.rstrip('\n').split('\t') + if len(f) < 9 or f[2] != 'CDS': + # a non-CDS feature ends the current CDS run + flush(buf, out); buf = []; curParent = None + out.write(line); continue + m = parentRe.search(f[8]) + p = m.group(1) if m else None + if p != curParent: + flush(buf, out); buf = []; curParent = p + buf.append(f) + flush(buf, out) + +if __name__ == '__main__': + main()