Skip to content

Fix bugs in masking, consensus, window joins and output - #95

Open
traviswheeler wants to merge 1 commit into
mainfrom
fix-1.2.2-bugs
Open

traviswheeler wants to merge 1 commit into
mainfrom
fix-1.2.2-bugs

Conversation

@traviswheeler

Copy link
Copy Markdown
Member

This fixes thirteen bugs in 1.2.2, found while porting ULTRA to Rust.

Masking (mask.cpp, main.cpp)

  • --mask masked a record that had no repeats, using the previous record's regions, when that record's last repeat ran to its end.
  • The masker counted only ACGTN as positions, while the reader counts every alphanumeric byte and skips ; lines. Masks landed on the wrong positions after IUPAC codes, digits or comment lines.
  • The first base of a region stayed unmasked when only a run of N separated it from the previous region.
  • --mask with a path that could not be opened segfaulted. It now prints an error and exits 255.

Repeats (repeat.cpp)

  • CreateLogo did not advance its column counter past a deletion in the previous copy, so each deletion shifted the later copies by one consensus column. It now advances (p += bdesc.indelNumber) and counts the skipped bases in the columns they belong to.
  • joint_repeat_region cut the joined repeat short when the second repeat ended inside the first.
  • joint_repeat_region appended the second repeat's split positions without moving them to that repeat's place in the joined repeat.
  • StoreScores took the parent of the current column's cell where the previous column's cell looks intended. Only PositionScoreDeltas (--show_delta) reads these values.

Output and options

  • JSON LogoNumbers wrote its first entry twice (JSONFileWriter.cpp).
  • With --max_consensus 0, TSV rows had no Consensus column although the header did (TabFileWriter.cpp).
  • The --acgt sum check called the integer abs, so any sum between 0 and 2 passed (cli.cpp).
  • Annotation coverage counted the overlap between repeats twice, because OutputRepeat compared read ids with a counter that was never updated (ultra.cpp, ultra.hpp).
  • examples/library_example.cpp passed its options without a program name, so -p was ignored.

What was checked

  • The branch builds and make examples runs. The format check adds no warnings under clang-format 23.
  • Masking: on six inputs the masked FASTA agrees with the BED intervals at every byte. On an input built to hit the three position bugs, 1.2.2 gets 129 bytes wrong.
  • CreateLogo: for 24 copies of ACGGTCATTG with four 1-bp deletions, 1.2.2 reports the consensus GGGGGTTTTT and this branch reports ACGGTCATTG.
  • Joins: in a test that joins repeats across windows, 1.2.2 reports a 170-base repeat as 107 bases. On a 3 Mb input at -t 8, 1.2.2 reported seq1 599916-601237 as 599916-600000 in 4 of 6 runs, and this branch in 0 of 6.
  • Coverage: the reported total equals the union of the reported intervals on five runs. On one of them 1.2.2 reported 386,796 where the union is 383,948.

Known limits

  • The CreateLogo change is right when the deletion is real. When the model calls a deletion in a copy that is full length, the old code is back in phase one period later and the new code is not; that reading comes from one case traced by hand. In a simulation of arrays mutated from a master unit, the consensus became an exact rotation of the unit in 462 arrays and stopped being one in 49. Nobody has reviewed the simulator code.
  • Output at -t > 1 can still differ from -t 1. In 3 of the 6 runs above, the joined repeat had the right coordinates and score, but its consensus differed from the -t 1 consensus by one base. This PR does not address that.
  • The version string is still 1.2.2.

Implemented with assistance from Claude (Fable 5.2)

Masking (mask.cpp, main.cpp):
- --mask masked a record that had no repeats, using the previous
  record's regions, when that record's last repeat ran to its end.
- The masker counted only ACGTN as positions, while the reader counts
  every alphanumeric byte and skips ';' lines. Masks landed on the
  wrong positions after IUPAC codes, digits or comment lines.
- The first base of a region stayed unmasked when only a run of N
  separated it from the previous region.
- --mask with a path that could not be opened segfaulted. It now
  prints an error and exits 255.

Repeats (repeat.cpp):
- CreateLogo did not advance its column counter past a deletion in the
  previous copy, so each deletion shifted the later copies by one
  consensus column. It now advances and counts the skipped bases.
- joint_repeat_region cut the joined repeat short when the second
  repeat ended inside the first.
- joint_repeat_region appended the second repeat's split positions
  without moving them to that repeat's place in the joined repeat.
- StoreScores took the parent of the current column's cell where the
  previous column's cell looks intended. Only PositionScoreDeltas
  reads these values.

Output and options:
- JSON LogoNumbers wrote its first entry twice.
- With --max_consensus 0, TSV rows had no Consensus column although
  the header did.
- The --acgt sum check called the integer abs, so any sum between 0
  and 2 passed.
- Annotation coverage counted the overlap between repeats twice,
  because OutputRepeat compared read ids with a counter that was never
  updated.
- examples/library_example.cpp passed its options without a program
  name, so -p was ignored.

Implemented with assistance from Claude (Fable 5.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant