Align and Match Sequences

The align extension scan two sequences for similarities. It creates a new sequence of AlignResult objects, each AlignResult object hold a reference to an item from the left sequence and the right sequence when there is a match or single instance of the left or right sequences and a null (or a custom replacer) to indicate a mismatch.

Using the following source sequences:
string[] src1 = new string[] { "Y", "Y", "Y", "R", "Y", "Y", "Y", "B", "Y", "Y", "R", "Y", "R", "Y", "Y", "Y", "Y", "Y", "Y", "R", "R", "Y", "R", "R", "Y", "Y", "Y", "Y", "R", "Y", "Y", "R" };
string[] src2 = new string[] { "Y", "Y", "R", "Y", "Y", "Y", "R", "Y", "B", "B", "Y", "Y", "Y", "Y", "R", "R", "Y", "Y", "Y", "Y", "Y", "Y", "R", "R", "R", "Y", "Y", "Y", "R", "R", "Y", "Y" };

Calling the align extension:
var align = src1.Align(src2).ToList();

Will return the folowing results:


Same results in a graphical view:


This function can be used as the base for utilities such as file compare (file diff) or any other type of sequence analysis. Elements of left and right sequence do not have to be of the same type as long as the comparison function is capable of operating on both types.

The Match extension is similar to the align extension but it does not include the mismatches in the results.

Last edited Jan 5, 2012 at 2:34 AM by AmirLiberman, version 6


booolean May 5, 2012 at 3:50 AM 
awesome,this is what I am looking for,greatly thanks.