# Sequence alignment with one to many characters

I'm trying to align a sequence of characters together, I found that sequence alignment algorithms which use dynamic programming like Needleman-Wunsch or Smith–Waterman only align one character with one character beside allowing character substitution, deletion or insertion.

For example, if I have a set of similarly sounding characters, like

monir, monier, muneer, munir, mounir, mouneer


The alignment algorithm will produce the following output

m u n i - r
| | | |   |
m o n e e r


Is there a way to adapt these algorithms (or an alternative algorithm) to consider aligning/substituting character with more than one character in order to output something like

m u n i  r
| | | |  |
m o n ee r


Please note that, I'm using the standard java implementation for these algorithms and I don't have a predefined list of similarly sounding characters, so I'm trying to aligning the similar words together in order to extract these alignments.

• Why don't you just merge gaps into neighbouring mismatches? Apr 24, 2015 at 14:01
• @Raphael the algorithm compare character by character to get the score of matching the characters and the gaps should not be always applicable to be matched with its neighbors Apr 24, 2015 at 20:20
• Why not? When will it be? Apr 24, 2015 at 20:38
• @Raphael consider these strings, how can you do that? The normal alignment will produce: (- a l s h o u a - i b i / e - l s h - - a e e b y) but actually, I need it to be aligned like (a l sh ou a i b i / e l sh - a ee b y) Apr 24, 2015 at 21:30
• You will have to make up your mind. In the question you say that the alignments are supposed to yield (candidates for) similar-sounding (groups of) characters. Now you talk of how things "need" to be. May 4, 2015 at 8:38