Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing comma-separated number in region #111

Merged
merged 1 commit into from Sep 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cljam/util/region.clj
Expand Up @@ -127,7 +127,7 @@
"Parse a region string into a map."
[region-str]
(when region-str
(let [pattern #"([!-)+-<>-~][!-~]*?)(:(\d+)?(-(\d+))?)?"
(let [pattern #"([!-)+-<>-~][!-~]*?)(:([\d,]+)?(-([\d,]+))?)?"
[_ chr _ start _ end] (re-matches pattern region-str)
start' (proton/as-long start)
end' (proton/as-long end)]
Expand Down
3 changes: 2 additions & 1 deletion test/cljam/util/region_test.clj
Expand Up @@ -210,6 +210,7 @@
"chr1:1" {:chr "chr1", :start 1}
"chr1:1-" {:chr "chr1:1-"}
"chr1:1-2" {:chr "chr1", :start 1, :end 2}
"chr1:1,000-2,000" {:chr "chr1", :start 1000, :end 2000}
"chr1:-2" {:chr "chr1", :end 2}
"chr1:001-200" {:chr "chr1", :start 1, :end 200}
"chr1:100-2" {:chr "chr1", :start 100, :end 2}
Expand Down Expand Up @@ -237,6 +238,7 @@
"chr1:1" nil
"chr1:1-" nil
"chr1:1-2" {:chr "chr1", :start 1, :end 2}
"chr1:1,000-2,000" {:chr "chr1", :start 1000, :end 2000}
"chr1:-2" nil
"chr1:001-200" {:chr "chr1", :start 1, :end 200}
"chr1:100-2" nil
Expand Down Expand Up @@ -269,4 +271,3 @@
{:chr "chr1", :end 10} nil
{:start 1} nil
{:end 10} nil))