zachb
(Zach Bjornson)
1
I’m trying to get the following to return “pfam03571” from the XML structure.
Cases[
XMLElement[
"myelem", {}, {XMLElement[
"INSDQualifier_value", {}, {"Peptidase family M49; pfam03571"}]}],
XMLElement[_, {}, {___~~x:RegularExpression["pfam\\d+"]~~___}]:>x,
Infinity]
This doesn’t work. Is this possible without extracting all XMLElement values (I don’t know the element tag name) and using StringCases?
jeffb
(Jeffrey Bryant)
2
This seems to work:
In[22]:= Cases[
XMLElement[
"myelem", {}, {XMLElement[
"INSDQualifier_value", {}, {"Peptidase family M49; pfam03571"}]}],
XMLElement[_, {}, {x_String}] /; StringMatchQ[x, RegularExpression[".+pfam\\d+"]] :> x, Infinity]
Out[22]= {"Peptidase family M49; pfam03571"}
arnoudb
(Arnoud Buzing)
3
Maybe this:
Cases[
XMLElement["myelem", {}, {XMLElement["INSDQualifier_value", {}, {"Peptidase family M49; pfam03571"}]}]
,
x:_String /; StringMatchQ[x, ___ ~~ "pfam" ~~ DigitCharacter ..] :> StringSplit[x, "; "][[-1]], Infinity]
returning this:
{"pfam03571"}