SequenceAlignment
seems like a function that is not (yet?) fully integrated into Mathematica. I want a function that accepts general patterns instead.
I naively fed a StringPattern
instead of a literal string to SequenceAlignment
and met silence, though MatchQ
is positive:
{StringMatchQ["A", Alternatives["A", "B"]], SequenceAlignment["A", Alternatives["A", "B"]]}
(* Out= {True, SequenceAlignment["A", "A" | "B"]} *)
One approach would be to write out all alternatives and repeatedly feed them to SequenceAlignment
.
The question is strongly related to this one: How to generally match, unify and merge patterns?.
Background: I want to answer questions like "What DNA sequences give rise to a given protein sequence and where can you find them?". Then one naturally stumbles across Alternatives
.
For example, a transmembrane protein that is supposed to selectively filter K ions contains an amino acid sequence "TVGYG". I want to find all its DNA parents, ie DNA code of all proteins that may contain such a filter.
Due to the redundancy of the genetic code, that subsequence can be coded by a diversity of DNA sequences, giving rise to a StringExpression
with alternatives:
In[80]:= StringReplace["TVGYG", backlist]
Out[80]= "ACA" | "ACC" | "ACG" | "ACT" ~~ "GTA" | "GTC" | "GTG" | "GTT" ~~
"GGA" | "GGC" | "GGG" | "GGT" ~~ "TAC" | "TAT" ~~
"GGA" | "GGC" | "GGG" | "GGT"
The first residue, "T"
for Threonine, may thus be coded by either "ACA"
or "ACC"
or "ACG"
or "ACT"
, etc.
a transmembrane protein that is supposed to selectively filter K ions contains an amino acid sequence "TVGYG"
in this site is worth a +1. $\endgroup$