Message Boards Message Boards

0
|
4471 Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Splitting a peptide (splitting a long string between certain letters)

Posted 9 years ago

Hi guys,

I wonder is there any function in Mathematica can split a string like "MERASLIQKAKLAEQAERYEDMAAFMKGAV" , "GDYYRYLAEVETGDDKKRIIDSARSA", and "EKKQQMAREYREKIYETELRDICNDVLSLEYKFLIPNASQ" into sub-strings between the letters "Y" and "E". I found the documentation for string and text manipulation functions but they do not seem to work..

For example, turing XXXYEXXX, and AAAEYBBB into "XXXY", "EXXX", "AAAE", and "YBBB".

Thanks!

POSTED BY: Don Walter

There are a thousand different ways to skin this cat:

Insert a special character between Y and E and then split the string by that character:

StringSplit[StringReplace["XXXYEXXX", {"YE" -> "Y-E", "YE" -> "Y-E"}], "-"]

Or maybe it's best to treat this like a List instead of a String:

Split[Characters["XXXYEXXX"], Sort[{#1, #2}] != {"E", "Y"} &]

or

Map[StringJoin]@Split[Characters@"XXXYEXXX", Sort@{#1, #2} != {"E", "Y"} &]

These would be okay if you didn't care about speed.

POSTED BY: Sean Clarke
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract