let parse_ref_seq tvl =
find1 `SQ tvl "SN" >>= fun name ->
find1 `SQ tvl "LN" >>= fun length ->
(try Ok (Int.of_string length)
with _ ->
error "invalid ref seq length" length sexp_of_string
) >>= fun length ->
find01 `SQ tvl "AS" >>= fun assembly ->
find01 `SQ tvl "M5" >>= fun md5 ->
find01 `SQ tvl "SP" >>= fun species ->
find01 `SQ tvl "UR" >>= fun uri ->
assert_tags `SQ tvl ["SN";"LN";"AS";"M5";"SP";"UR"] >>= fun () ->
ref_seq ~name ~length ?assembly ?md5 ?species ?uri ()