Skip to content

Commit

Permalink
Fix loading of keywords that do not begin with '$' (#8)
Browse files Browse the repository at this point in the history
* fix loading of keywords that do not begin with $

(This is a pretty common situation, e.g. the spillover matrix is commonly found
in "SPILL", "SPILLOVER" and only sometimes in "$SPILL".)

* accomodate the test for the additional loaded params

* use iterator directly to terminate the parsing cycle

* bump version
  • Loading branch information
tlnagy authored Mar 5, 2020
1 parent 51bd6a3 commit 3a02bb0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FCSFiles"
uuid = "d76558cf-badf-52d4-a17e-381ab0b0d937"
version = "0.1.1"
version = "0.1.2"

[deps]
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
Expand Down
27 changes: 12 additions & 15 deletions src/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,21 @@ function parse_text(io, start_text::Int, end_text::Int)
raw_btext = Array{UInt8}(undef, end_text - start_text + 1)
read!(io, raw_btext)
raw_text = String(raw_btext)
delimiter = raw_text[1]
# initialize iterator, save&skip the delimiter
delimiter, state = iterate(raw_text)

# container for the results
text_mappings = Dict{String, String}()
# initialize iterator
iter_result = iterate(raw_text)
while iter_result !== nothing
i, state = iter_result

# found a new key, value pair
if i == '$'
# grab key and ignore escaped delimiters
key, state = grab_word(raw_text, state, delimiter)
# grab value and ignore escaped delimiters
value, state = grab_word(raw_text, state, delimiter)
# FCS keywords are case insensitive so force them uppercase
text_mappings["\$"*uppercase(key)] = value
end
iter_result = iterate(raw_text, state)
while iterate(raw_text, state) !== nothing
# grab key and ignore escaped delimiters
key, state = grab_word(raw_text, state, delimiter)

# grab value and ignore escaped delimiters
value, state = grab_word(raw_text, state, delimiter)

# FCS keywords are case insensitive so force everything to uppercase
text_mappings[uppercase(key)] = value
end
text_mappings
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using Test, HTTP
# load the large file
flowrun = load("testdata/testLargeFile.fcs")
@test length(flowrun.data) == 50
@test length(flowrun.params) == 262
@test length(flowrun.params) == 268

# cleanup
rm("testdata/testLargeFile.fcs", force=true)
Expand Down

2 comments on commit 3a02bb0

@tlnagy
Copy link
Owner Author

@tlnagy tlnagy commented on 3a02bb0 Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/10592

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.2 -m "<description of version>" 3a02bb0d4f981008cebf83c5871498b41d2dc887
git push origin v0.1.2

Please sign in to comment.