let parse_read_group tvl =
find1 `RG tvl "ID" >>= fun id ->
find01 `RG tvl "CN" >>= fun seq_center ->
find01 `RG tvl "DS" >>= fun description ->
find01 `RG tvl "DT" >>= fun run_date ->
find01 `RG tvl "FO" >>= fun flow_order ->
find01 `RG tvl "KS" >>= fun key_seq ->
find01 `RG tvl "LB" >>= fun library ->
find01 `RG tvl "PG" >>= fun program ->
find01 `RG tvl "PI" >>?~ (fun predicted_median_insert_size ->
try Ok (Int.of_string predicted_median_insert_size)
with _ ->
error
"invalid predicted median insert size"
predicted_median_insert_size
sexp_of_string
) >>= fun predicted_median_insert_size ->
find01 `RG tvl "PL" >>?~
parse_platform >>= fun platform ->
find01 `RG tvl "PU" >>= fun platform_unit ->
find01 `RG tvl "SM" >>= fun sample ->
assert_tags `RG tvl
["ID";"CN";"DS";"DT";"FO";"KS";"LB";"PG";"PI";"PL";"PU";"SM"]
>>= fun () ->
read_group
~id ?seq_center ?description ?run_date ?flow_order ?key_seq
?library ?program ?predicted_median_insert_size
?platform ?platform_unit ?sample ()