Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Construct a regular expression from a BioSequence with degenerate letters
ResourceFunction["BioSequenceToRegularExpression"][bioseq] constructs a RegularExpression that is functionally equivalent to the biomolecular sequence bioseq, for purposes of pattern matching.  | 
Convert a DNA strand with degenerate letters to an equivalent regular expression:
| In[1]:= | 
| Out[1]= | 
A biomolecular sequence with degenerate letters:
| In[2]:= | 
| Out[2]= | 
Convert it to a regular expression:
| In[3]:= | 
| Out[3]= | 
The regular expression can be used in string functions like StringCases:
| In[4]:= | 
| Out[4]= | 
This is equivalent to using StringCases directly on BioSequence objects:
| In[5]:= | 
| Out[5]= | ![]()  | 
Convert a peptide sequence with degenerate letters:
| In[6]:= | 
| Out[6]= | 
If the input biomolecular sequence does not contain degenerate letters, BioSequenceToRegularExpression returns a trivial regular expression:
| In[9]:= | 
| Out[9]= | 
Hybrid strands and sequence collections are not supported:
| In[10]:= | 
| Out[10]= | ![]()  | 
This work is licensed under a Creative Commons Attribution 4.0 International License