/// <summary> /// Converts a char first into a symbol and then into a regular expression. /// This is usually trivial appart from ambiguity symbols, such as "R" within /// the DNA alphabet. They are represented as an alternative, <para></para>e.g. "[AG] /// to express the ambiguity. /// </summary> /// <param name="ch">Character to convert.</param> /// <param name="alphabet">Alphabet the character belongs to.</param> /// <returns>Returns the converted character.</returns> public String Convert(char ch, Alphabet alphabet) { if (alphabet.IsValid(ch)) { Symbol sym = alphabet[ch]; if (sym is SymbolMeta) { StringBuilder sb = new StringBuilder(); sb.Append('['); for (int i = 0; i < ((SymbolMeta)sym).SymbolNumber; i++) sb.Append(((SymbolMeta)sym)[i].Letter); sb.Append(']'); return sb.ToString(); } return "" + sym.Letter; } return "" + ch; }