This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

SequenceAlignment

SequenceAlignment
finds an optimal alignment of sequences of elements in the strings or lists and , and yields a list of successive matching and differing sequences.
  • SequenceAlignment gives a list of the form where each is either a single string or sequence of list elements u, representing a matching segment, or a pair , representing segments that differ between the .
  • SequenceAlignment by default finds a global Needleman-Wunsch alignment of the complete strings or lists and .
  • With the option setting Method, it finds a local Smith-Waterman alignment.
  • For sufficiently similar strings or lists, local and global alignment methods give the same result.
  • The following options can be given:
GapPenalty0additional cost for each alignment gap
IgnoreCaseFalsewhether to ignore case of letters in strings
MergeDifferencesTruewhether to combine adjacent differences
Method"Global"alignment algorithm to be used
SimilarityRulesAutomaticrules for similarities between elements
  • SequenceAlignment attempts to find an alignment that maximizes the total similarity score.
  • With the default setting SimilarityRules->Automatic, each match between two elements contributes 1 to the total similarity score, while each mismatch, insertion, or deletion contributes -1.
  • Various named similarity matrices are supported, as specified in the notes for SimilarityRules.
Globally align two similar strings:
Global alignment of two strings:
Local alignment of the same strings:
Globally align two similar strings:
In[1]:=
Click for copyable input
Out[1]=
 
Global alignment of two strings:
In[1]:=
Click for copyable input
Out[1]=
Local alignment of the same strings:
In[2]:=
Click for copyable input
Out[2]=
Align two short protein sequences:
Assigning a negative score to the deletion of gives a different alignment:
By default, an alignment is found with two gaps:
Increasing the penalty for gaps forces another alignment with fewer gaps:
This gives insertions, deletions, and replacements as separate differences:
This gives the global alignment of two similar strings:
This shows the difference between global and local string alignment:
New in 7