In the Macaulay package ReactionNetworks.m2, a set of reactions is represented as
{"AB1-->B+C" "C2-->D"}
with new lines (or maybe spaces?) separating the first reaction "AB1-->B+C" of the second. I would like to have a Mathematica function to convert the above to the format
{"AB1"->"B"+"C", "C2"->"D"}
(used in the package ReactionKinetics.wl). Note the arrows --> changed to -> and "" are put around species, rather than around reactions.
The answer provided is correct for spaces, but a bit confusing for novices, because it seems that in 13.3 at least, Mathematica outputs strings as symbols. Thus the line
rn = ReplaceAll[str_String :> Total[StringSplit[str, "+"]]][ Rule @@@ StringSplit[First@(List @@@ {"AB1-->B+C" "C2-->D"}), "-->"]]
outputs a list of Rules applied to apparent symbols, with no quotation marks. Subsequently, copy pasting the output into an input cell, or typing
{StringQ[rn[[1, 1]]],Head[rn[[1, 1]]] === Symbol}
Outputs
{True, False}
revealing that Mathematica 13.3 has hidden in the first output the fact that "apparent symbols" were actually strings.However, the input I have (a copy paste from output of Macaulay2 run on emacs) seems separated by newlines, for example
A={X1-- > X2 X2-- > X1}
and the solution provided for spaces stops working. I guess I need two different functions, one for each possible separator.