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