Pairwise Sequence Alignment Score Settings

Q

How to change Pairwise Sequence Alignment Score Settings?

✍: FYIcenter.com

A

Bio.Align.PairwiseAligner().align() uses a set of Alignment Score Settings to control how each possible alignment score is calculated. It then returns only those alignments that have the highest score.

Here are the Alignment Score Settings their default values.

fyicenter$ python
>>> from Bio import Align
>>> aligner = Align.PairwiseAligner()
>>> print(aligner)
Pairwise sequence aligner with parameters
  wildcard: None
  match_score: 1.000000
  mismatch_score: 0.000000
  target_internal_open_gap_score: 0.000000
  target_internal_extend_gap_score: 0.000000
  target_left_open_gap_score: 0.000000
  target_left_extend_gap_score: 0.000000
  target_right_open_gap_score: 0.000000
  target_right_extend_gap_score: 0.000000
  query_internal_open_gap_score: 0.000000
  query_internal_extend_gap_score: 0.000000
  query_left_open_gap_score: 0.000000
  query_left_extend_gap_score: 0.000000
  query_right_open_gap_score: 0.000000
  query_right_extend_gap_score: 0.000000
  mode: global

With these default settings, we will get 3 alignments with the best score of 4.0 between AACTT" and "AAGTT".

>>> alignments = aligner.align("AACTT", "AAGTT")
>>> for alignment in alignments:
...   print("score = {}".format(alignment.score))
...   print(alignment)
... 
score = 4.0
target            0 AAC-TT 5
                  0 ||--|| 6
query             0 AA-GTT 5

score = 4.0
target            0 AA-CTT 5
                  0 ||--|| 6
query             0 AAG-TT 5

score = 4.0
target            0 AACTT 5
                  0 ||.|| 5
query             0 AAGTT 5

But actually, the last alignment is much better than the first 2 alignments. In order to give the last alignment a higher total score, we can give a lower gap score setting.

>>> aligner.gap_score = -1.0
>>> print(aligner)
Pairwise sequence aligner with parameters
  wildcard: None
  match_score: 1.000000
  mismatch_score: 0.000000
  target_internal_open_gap_score: -1.000000
  target_internal_extend_gap_score: -1.000000
  target_left_open_gap_score: -1.000000
  target_left_extend_gap_score: -1.000000
  target_right_open_gap_score: -1.000000
  target_right_extend_gap_score: -1.000000
  query_internal_open_gap_score: -1.000000
  query_internal_extend_gap_score: -1.000000
  query_left_open_gap_score: -1.000000
  query_left_extend_gap_score: -1.000000
  query_right_open_gap_score: -1.000000
  query_right_extend_gap_score: -1.000000
  mode: global

>>> alignments = aligner.align("AACTT", "AAGTT")
>>> for alignment in alignments:
...   print("score = {}".format(alignment.score))
...   print(alignment)
... 
score = 4.0
target            0 AACTT 5
                  0 ||.|| 5
query             0 AAGTT 5

As you can see from the output, alignments with gaps are not returned any more, because their score is 2.0 now.

target            0 A  A  C  -  T  T 5
                  0 |  |  -  -  |  | 6
query             0 A  A  -  G  T  T 5
                    ----------------
                    1  1 -1 -1  1  1 = 2.0

 

Too Many Results from align() Function

Calculate Pairwise Sequence Alignment

Biopython - Tools for Biological Computation

⇑⇑ OBF (Open Bioinformatics Foundation) Tools

2023-05-09, 642🔥, 0💬