Skip to content

--umi auto cannot find a UMI that runs to the end of the read #34

Description

@davidliwei

Problem

mageckcount_search_variable_region never closes a variable region that runs to the end of the sequence it is given, so --umi auto cannot find a UMI that sits at the end of the read.

It sets var_start at the first column whose base composition looks random, then scans forward for the first column that does not, and assigns var_end there. If every remaining column is variable, the loop ends without assigning anything and var_end stays -1.

The common layout hits this exactly: a UMI immediately after the guide, with nothing following it. remainingseq_list is then the UMI and nothing else, every column is variable, and the search returns (0, -1).

Reproduce

An 8bp random UMI directly after a 20bp guide on read 1, 200 reads:

--umi auto                            -> "Search failed", exit non-zero
--umi firstpair --umi-start 0 --umi-end 8   -> 2000 rows, correct

Before #33 this was worse than a clean failure: (0, -1) was accepted as a successful second-read search — if umi_start_2 >= 0 or umi_end_2 >= 0 — so reads were sliced [0:-1] and umi_count.txt filled with plausible-looking rows built from unrelated read-2 sequence. #33 fixed the acceptance test, which turns the silent corruption into an honest failure. It does not make the search find the region.

Proposed change

When the scan reaches the end without finding a non-variable column, close the region at the end of the sequence rather than leaving var_end at -1. Guard the case where var_start is 0 and the whole sequence is variable, which is legitimate.

Worth adding at the same time: the caller logs the chosen window at info level, so a test can assert the window rather than only the row count.

Note

This is only reachable from --umi auto. --pairguide auto was disabled in #33 and is tracked separately in #32, which proposes a different search (library matching via mageckcount_trim5_auto) rather than this one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions