Calculate the score for a character pair based on whether they match or mismatch. Returns 1 if the characters match, -1 if they mismatch, and -2 if either of the characters is a gap. >>> score_function('A', 'A') 1 >>> score_function('A', 'C') -1 >>> score_function('-
(
source_char: str,
target_char: str,
match: int = 1,
mismatch: int = -1,
gap: int = -2,
)
| 10 | |
| 11 | |
| 12 | def score_function( |
| 13 | source_char: str, |
| 14 | target_char: str, |
| 15 | match: int = 1, |
| 16 | mismatch: int = -1, |
| 17 | gap: int = -2, |
| 18 | ) -> int: |
| 19 | """ |
| 20 | Calculate the score for a character pair based on whether they match or mismatch. |
| 21 | Returns 1 if the characters match, -1 if they mismatch, and -2 if either of the |
| 22 | characters is a gap. |
| 23 | >>> score_function('A', 'A') |
| 24 | 1 |
| 25 | >>> score_function('A', 'C') |
| 26 | -1 |
| 27 | >>> score_function('-', 'A') |
| 28 | -2 |
| 29 | >>> score_function('A', '-') |
| 30 | -2 |
| 31 | >>> score_function('-', '-') |
| 32 | -2 |
| 33 | """ |
| 34 | if "-" in (source_char, target_char): |
| 35 | return gap |
| 36 | return match if source_char == target_char else mismatch |
| 37 | |
| 38 | |
| 39 | def smith_waterman( |
no outgoing calls
no test coverage detected