From 3745ff9fc32b11c4d62b55df711c465216d763e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Sat, 15 Dec 2018 16:52:04 +1100 Subject: [PATCH] Allow integer identifier --- src/reader.jl | 2 +- test/runtests.jl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/reader.jl b/src/reader.jl index 6e15ec9..f08d3ce 100644 --- a/src/reader.jl +++ b/src/reader.jl @@ -1,6 +1,6 @@ # Check if the record data is in the four column BED format. function isLikeRecord(line::String) :: Bool - return occursin(r"^\s*\S*(?=[A-Za-z])\S*\s+(\d+)\s+(\d+)\s+(\S*\d)\s*$", line) # Note: is like a record. + return occursin(r"^\s*\S*(?=[A-Za-z0-9])\S*\s+(\d+)\s+(\d+)\s+(\S*\d)\s*$", line) # Note: is like a record. end function isBrowser(line::String) :: Bool diff --git a/test/runtests.jl b/test/runtests.jl index 227b875..ba3b280 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -38,6 +38,8 @@ const line9 = "chr19 49304400 49304700 1.00" const line_other_space = "2R 8225773 8226043 -0.426032509896305" const line_other = "2R 8225773 8226043 -0.426032509896305" +const line_other_chrom = "1 3006665 3006673 2" + # Varaiations of line 1. const line1_2 = "chr19 49302000 49302300 -1.0" # tab separated. const line1_3 = "chr19 49302000 49302300 -1.0" # mix of tabs and spaces. @@ -157,7 +159,7 @@ end #testset I/O @test Bedgraph.isComment(Bag.comment1) @test Bedgraph.isBrowser(Bag.browser3) -@test Bedgraph.isLikeRecord("1 2 3 4") == false +@test Bedgraph.isLikeRecord("1 2 3 4") == true @test Bedgraph.isLikeRecord(Bag.parameter_line) == false @test Bedgraph.isLikeRecord(Bag.parameter_line_4) == false @test Bedgraph.isLikeRecord(Bag.parameter_line_min) == false @@ -173,6 +175,7 @@ end #testset I/O @test Bedgraph.isLikeRecord(Bag.line_other_space) == true @test Bedgraph.isLikeRecord(Bag.line_other) == true +@test Bedgraph.isLikeRecord(Bag.line_other_chrom) == true end #testset Matching