Skip to content

Gap penalties check, options.c line 246 #1337

@lmjakt

Description

@lmjakt

Summary:

Suggest changing:

if ((mo->q != mo->q2 || mo->e != mo->e2) && !(mo->e > mo->e2 && mo->q + mo->e < mo->q2 + mo->e2)

to

if ((mo->q != mo->q2 || mo->e != mo->e2) && !(mo->e >= mo->e2 && mo->q + mo->e < mo->q2 + mo->e2)

to avoid triggering error when using option -E2 or -E2,2.

And to consider modifying the error message for this operation.

Details

Use of alignment option -E2,2 or -E2 results in:

[ERROR] dual gap penalties violating E1>E2 and O1+E1<O2+E2

This is triggered by the following conditional on line 246 of options.c:

if ((mo->q != mo->q2 || mo->e != mo->e2) && !(mo->e > mo->e2 && mo->q + mo->e < mo->q2 + mo->e2))

Where the mo members q, q2, e, e2 correspond to O1, O2, E1 and E2 respectively (if I understand correctly).

(mo->q != mo->q2 || mo->e != mo->e2)

is TRUE since the default O1 and O2 values are 4 and 24.

!(mo->e > mo->e2 && mo->q + mo->e < mo->q2 + mo->e2)

is also TRUE since E1 == E2, which means that the second half will not be evaluated and hence doesn't matter in this scenario.

If the conditional was mo->e >= mo->e2, then mo->q + mo->e < mo->q2 + mo->e2 would be evaluated, and be TRUE since (2 + 4 < 2 + 24). Negating the second half will then give an overall FALSE value and the error should not be triggered.

The error message seems misleading to me. The message states that E1 > E2, which in this case is not TRUE for -E2,2. In the default scenario opt->q = 4, opt->e = 2, opt->q2 = 24, opt->e1 = 1, E1 is larger than E2 but this does not trigger the error. The error message also states that O1+E1<O2+E2, but it seems to me that the opposite condition is checked for due to the negation of the AND result. And in any case, under the default scenario this is TRUE, (2 + 4 < 1 + 24) and this is clearly not an error.

I'm not completely sure as to the intent of the check, but regardless, it seems that the error message should use 'or' rather than 'and', since the negation of an AND combination will be TRUE if either conditional is FALSE. Changing the error message to more clearly reflect the conditional:

[ERROR] dual gap penalties violating !(E1>E2 and O1+E1<O2+E2)

would seem more accurate; but perhaps a bit cryptic to the normal user.

My reason for trying -E2,2 is that I'm looking at pore-C data and finding many alignments with long indels. These indels may be caused by religation of nearby sites and I wish to avoid this.

Somewhat unrelated; I very much appreciate minimap2 (and htslib). Not only because it works very well, but also because the code for it is nicely structured and clearly written making it easy to reason about things. And that is not that common.

Thanks,

Martin

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions