Part I of Cartesia's "From Tokens to Bytes" reports that an H-Net trained on DNA draws chunk boundaries on codon borders inside coding regions, and long, loosely structured chunks outside them. Measure that on a sequence with known coding regions.
seq is a string over A, C, G, T. boundaries holds one flag per nucleotide, 1 where a chunk starts; you may assume boundaries[0] == 1. A region is a half-open interval (start, end).
coding_end(seq, start)
ValueError unless seq[start:start + 3] == "ATG".start (positions start, start + 3, ...) and return the index just past the first stop codon (TAA, TAG or TGA), so the region (start, end) includes the stop codon. A stop codon that is not in frame does not count. Raise ValueError if no in-frame stop codon is found.frame_labels(n, regions)
n. Inside a region, position gets its frame , so 0 marks the first letter of a codon. Outside every region the label is .ValueError if a region is empty or leaves , or if two regions overlap.boundary_rate_by_frame(boundaries, labels)
[r0, r1, r2, r_nc]: for frames 0, 1, 2 and non-coding positions, the number of boundaries at positions with that label divided by the number of positions with that label. Use 0.0 for a label with no positions.codon_adherence(boundaries, labels)
chunk_lengths(boundaries, labels)
(mean_coding_length, mean_noncoding_length), using 0.0 for an empty group.