From da0c1881ddeb851bb9a492466d08c7d7919e19a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20O=27Mara?= Date: Mon, 20 Jul 2020 12:49:56 +1000 Subject: [PATCH] Workaround for #23 --- src/sam/readrecord.jl | 13 ++++++++++--- test/test_sam.jl | 13 +++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/sam/readrecord.jl b/src/sam/readrecord.jl index 4bc0761..60252f6 100644 --- a/src/sam/readrecord.jl +++ b/src/sam/readrecord.jl @@ -28,9 +28,16 @@ const sam_machine_metainfo, sam_machine_record, sam_machine_header, sam_machine_ key.actions[:enter] = [:pos2] key.actions[:exit] = [:metainfo_dict_key] val = re"[ -~]+" - val.actions[:enter] = [:pos2] - val.actions[:exit] = [:metainfo_dict_val] - keyval = cat(key, ':', val) + + # val.actions[:enter] = [:pos2] + # val.actions[:exit] = [:metainfo_dict_val] + # keyval = cat(key, ':', val) + + separator = re":" + separator.actions[:exit] = [:pos2] + + keyval = cat(key, separator, opt(val)) + keyval.actions[:exit] = [:metainfo_dict_val] cat(keyval, rep(cat('\t', keyval))) end diff --git a/test/test_sam.jl b/test/test_sam.jl index e669757..cd9b74e 100644 --- a/test/test_sam.jl +++ b/test/test_sam.jl @@ -30,6 +30,19 @@ @test metainfo["VN"] == "1.0" @test metainfo["SO"] == "coordinate" @test_throws KeyError metainfo["GO"] + + + metainfo = SAM.MetaInfo("@PG ID:hisat2 PN:hisat2 VN: CL:\"/script.sh\"") + @test haskey(metainfo, "ID") + @test haskey(metainfo, "PN") + # @test haskey(metainfo, "VN") + @test haskey(metainfo, "CL") + + @test metainfo["ID"] == "hisat2" + @test metainfo["PN"] == "hisat2" + # @test metainfo["VN"] == "" + @test metainfo["CL"] == "\"/script.sh\"" + end @testset "Header" begin