Template:Pathway/Metabolic
From Metabolomics.JP
< Template:Pathway(Difference between revisions)
Line 18: | Line 18: | ||
else | else | ||
--- Second and later lines --- | --- Second and later lines --- | ||
+ | local map = {}; | ||
if (string.sub(line,1,1) == 'R') then | if (string.sub(line,1,1) == 'R') then | ||
line = string.sub(line,2); | line = string.sub(line,2); | ||
--- Create reverse mapping | --- Create reverse mapping | ||
− | |||
for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do | for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do | ||
map[v] = k; | map[v] = k; | ||
--print(v .. "-" .. k .. " "); | --print(v .. "-" .. k .. " "); | ||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
− | |||
else | else | ||
--- Create standard mapping | --- Create standard mapping | ||
− | |||
for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do | for k, v in string.gmatch(line, "(%d%d?) (%d%d?) %d?%d? ?;") do | ||
map[k] = v; | map[k] = v; | ||
--print(k .. "-" .. v .. " "); | --print(k .. "-" .. v .. " "); | ||
end | end | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
end | end | ||
+ | --- Leave only positions that can be mapped | ||
+ | local list2 = {}; | ||
+ | for k, v in pairs(list) do | ||
+ | if (map[k] ~= nil) then list2[map[k]] = map[k]; end | ||
+ | end | ||
+ | list = list2; | ||
end | end | ||
local str = ""; | local str = ""; |
Revision as of 12:30, 16 March 2009