Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Back Trace Error in Alignment #78

Closed

Conversation

evolvedmicrobe
Copy link

We encountered a bug in the library, which can be reproduced as follows: Given this reference and query files:

>ref
AGTGTAAACTGTACCTGATGGCTAA

>probe
ATGTAAACTGTACCTGATGGCTAA

The alignment produced by this command is clearly incorrect, though the alignment score appears correct for the "right" alignment:

python pyssw.py ref.fa query.fa -c -m 3 -x 2 -o 2 -e 1
target_name: ref
query_name: probe
optimal_alignment_score: 70	suboptimal_alignment_score: 22	strand: +	target_begin: 1	target_end: 25	query_begin: 1	query_end: 24

Target:       1	AGTGTAAACTGTACCTGATGGCTA	24
               	|****||******|*****|***|
Query:        1	ATGTAAACTGTACCTGATGGCTAA	24

Making this change produces the correct alignment, as it appeared the issue was due to the traceback terminating too early:

target_name: ref
query_name: probe
optimal_alignment_score: 70	suboptimal_alignment_score: 22	strand: +	target_begin: 1	target_end: 25	query_begin: 1	query_end: 24

Target:       1	AGTGTAAACTGTACCTGATGGCTAA	25
               	| |||||||||||||||||||||||
Query:        1	A-TGTAAACTGTACCTGATGGCTAA	24

I didn't have time to audit the code thoroughly enough to know if this solution was always valid, but it appeared to work on several tested examples.

We encountered a bug in the library, which can be reproduced as follows: Given this reference and query files:

```
>ref
AGTGTAAACTGTACCTGATGGCTAA

```

```
>probe
ATGTAAACTGTACCTGATGGCTAA
```

The alignment produced by this command is clearly incorrect, though the alignment score appears correct for the "right" alignment:

```
python pyssw.py ref.fa query.fa -c -m 3 -x 2 -o 2 -e 1
target_name: ref
query_name: probe
optimal_alignment_score: 70	suboptimal_alignment_score: 22	strand: +	target_begin: 1	target_end: 25	query_begin: 1	query_end: 24

Target:       1	AGTGTAAACTGTACCTGATGGCTA	24
               	|****||******|*****|***|
Query:        1	ATGTAAACTGTACCTGATGGCTAA	24
```

Making this change produces the correct alignment, as it appeared the issue was due to the traceback terminating too early:

```
target_name: ref
query_name: probe
optimal_alignment_score: 70	suboptimal_alignment_score: 22	strand: +	target_begin: 1	target_end: 25	query_begin: 1	query_end: 24

Target:       1	AGTGTAAACTGTACCTGATGGCTAA	25
               	| |||||||||||||||||||||||
Query:        1	A-TGTAAACTGTACCTGATGGCTAA	24
```

I didn't have time to audit the code thoroughly enough to know if this solution was always valid, but it appeared to work on several tested examples.
@martin-steinegger
Copy link

This PR should fix #61

@boristim66 boristim66 mentioned this pull request Oct 13, 2021
@mengyao
Copy link
Owner

mengyao commented May 20, 2022

Thank you so much for pointing out this. This point makes sense, however your code doesn't work at my place. I manually made your recommended change in my code. I will update the master branch with this change soon.

@mengyao mengyao closed this May 20, 2022
mengyao pushed a commit that referenced this pull request May 20, 2022
marcelm added a commit to ksahlin/strobealign that referenced this pull request Jun 12, 2023
SSW sometimes computes wrong alignments. This has been reported and fixed in
mengyao/Complete-Striped-Smith-Waterman-Library#78

Closes #294
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.

3 participants