Replace several substrings in a column

Hi everyone

I have a column containing mutations with three letter amino acid codes. I want to change each of them to the corresponding one letter codes. I tried using the replace function in the column expressions node, but I can’t make it execute all 20 replace functions on the column.

For example, the first mutation is “Gly5Ala” and when i run the two functions in the column expressions node:

replace(column(“Protein Consequence”), “Gly”, “G”)
replace(column(“Protein Consequence”), “Ala”, “A”)

i get “Gly5A”

So essentially I want to do the replacement for all possible amino acids on this column and replace it with a column containing the one letter mutations.

Any suggestions are much appreciated


Try this
replace(replace(column(“Protein Consequence”), “Ala”, “A”), “Gly”, “G”)

Or alternative use the Cell Replacer node :slight_smile:
AminoAcid_replacement.knwf (17.2 KB)


Or you could also store “sub-results” in variables in ce node

Thank you so much, worked perfectly!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.