Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/FASTA-format/Lua/fasta-format.lua
Normal file
24
Task/FASTA-format/Lua/fasta-format.lua
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
local file = io.open("input.txt","r")
|
||||
local data = file:read("*a")
|
||||
file:close()
|
||||
|
||||
local output = {}
|
||||
local key = nil
|
||||
|
||||
-- iterate through lines
|
||||
for line in data:gmatch("(.-)\r?\n") do
|
||||
if line:match("%s") then
|
||||
error("line contained space")
|
||||
elseif line:sub(1,1) == ">" then
|
||||
key = line:sub(2)
|
||||
-- if key already exists, append to the previous input
|
||||
output[key] = output[key] or ""
|
||||
elseif key ~= nil then
|
||||
output[key] = output[key] .. line
|
||||
end
|
||||
end
|
||||
|
||||
-- print result
|
||||
for k,v in pairs(output) do
|
||||
print(k..": "..v)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue