I am trying to use the SimilarityRules
option of SequenceAlignment
to customize its output. This works perfectly for strings, but I cannot get it to work for lists.
Compare the following outputs:
SequenceAlignment["abcba","abdcba"]
{"ab", {"", "d"}, "cba"}
SequenceAlignment[{a, b, c, b, a}, {a, b, d, c, b, a}]
{{a, b}, {{}, {d}}, {c, b, a}}
SequenceAlignment["abcba", "abdcba",
SimilarityRules -> {{a_, a_} -> 1, {a_, b_} -> -1}]
{"ab", {"", "d"}, "cba"}
SequenceAlignment[{a, b, c, b, a}, {a, b, d, c, b, a},
SimilarityRules -> {{a_, a_} -> 1, {a_, b_} -> -1}]
SequenceAlignment[{a, b, c, b, a}, {a, b, d, c, b, a}, SimilarityRules -> {{a_, a_} -> 1, {a_, b_} -> -1}]
So SequenceAlignment
seems to work for lists, but not with the SimilarityRules
option. Does anyone have a workaround for this?
SequenceAlignment
given list arguments will acceptSimilarityRules -> Automatic
which makes me suspect it is checking forAutomatic
internally in this case. I would call this a documentation bug. The documentation totally fails to discussSequenceAlignment
with respect to list arguments, so we are left adrift where the issue you raise is concerned. What kind similarity rules were you thinking of using for lists? $\endgroup$a
andb
, wherea
was generated fromb
by removing some chunks. I want to aligna
tob
. Therefore, my similarity rule would discount substitutions in favour of insertions, to get the best alignment. ({{a_, a_} -> 1, {a_, ""} -> -1, {a_, b_} -> -2}
) I also use the optionGapPenalty->1
. This works for strings, but now I am trying to speed up by splitting the string into atomic parts (words), and putting those in lists. $\endgroup$