# Need help with Pairwise Alignment module in iterating over the alignment

from Bio import SeqIO
from Bio import Align

aligner = Align.PairwiseAligner()
aligner.mode = 'global'
aligner.match_score = 1
aligner.mismatch_score = -2
aligner.gap_score = -2

alignments = aligner.score(ref_seq_1.seq , seq1.seq)

print(alignments)
for alignment in sorted(alignments):
print(alignment)


So this is my code and as you can see in the last section i am trying to iterate over my alignment but I am getting this error

TypeError: 'float' object is not iterable


I have tried various things like using str() but it gives some strange values and I also tried to read the source code by using the inspect module but I can't figure out the problem.

Any help would be really appreciated.

My final objective is to find out how many matches, mismatches and gaps are present in the final alignment using biopython.

if there is any other better way to do it in python please feel free to suggest.

aligner.score(ref_seq_1.seq , seq1.seq) doesn't produce an alignment. It just gives you the score of the alignment as float value.
alignments = aligner.align(ref_seq_1.seq , seq1.seq)
Now alignments is an Bio.Align.PairwiseAlignments you can iterate over alignments or get the score with alignments.score which gives you the same as aligner.score(ref_seq_1.seq , seq1.seq)`