smftools.tools.sequence_alignment#
Functions
|
Globally align two sequences and return mismatch positions/bases. |
Classes
|
Record a mismatch or gap between two aligned sequences. |
- class smftools.tools.sequence_alignment.AlignmentMismatch(event, seq1_pos, seq1_base, seq2_pos, seq2_base)#
Bases:
objectRecord a mismatch or gap between two aligned sequences.
- smftools.tools.sequence_alignment.align_sequences_with_mismatches(seq1, seq2, match_score=1, mismatch_score=-1, gap_score=-1, ignore_n=True)#
Globally align two sequences and return mismatch positions/bases.
The alignment uses a simple Needleman-Wunsch dynamic programming approach with configurable scores. Mismatch reporting is based on the aligned sequences and returns 0-based coordinates in each sequence. Gap events are represented with a
Nonecoordinate for the gapped sequence.- Parameters:
seq1 (
str) -- First sequence (treated as reference for positions).seq2 (
str) -- Second sequence.match_score (
int(default:1)) -- Score for matching bases.mismatch_score (
int(default:-1)) -- Score for mismatching bases.gap_score (
int(default:-1)) -- Score for introducing a gap.ignore_n (
bool(default:True)) -- Whether to ignore mismatches involving the baseN.
- Return type:
tuple[str,str,list[AlignmentMismatch]]- Returns:
Tuple of (aligned_seq1, aligned_seq2, mismatches).