let read_group
~id ?seq_center ?description ?run_date ?flow_order
?key_seq ?library ?program ?predicted_median_insert_size
?platform ?platform_unit ?sample
()
=
(match run_date with
| None -> Ok None
| Some run_date ->
try Ok (Some (`Date (Date.of_string run_date)))
with _ ->
try Ok (Some (`Time (Time.of_string run_date)))
with _ ->
error "invalid run date/time" run_date sexp_of_string
) >>= fun run_date ->
(match flow_order with
| None -> Ok None
| Some "" -> Or_error.error_string "invalid empty flow order"
| Some "*" -> Ok flow_order
| Some x ->
if String.for_all x ~f:(function
| 'A' | 'C' | 'M' | 'G' | 'R' | 'S' | 'V' | 'T' | 'W'| 'Y' | 'H'
| 'K' | 'D' | 'B' | 'N' -> true
| _ -> false
)
then
Ok flow_order
else
error "invalid flow order" x sexp_of_string
) >>| fun flow_order ->
{
id; seq_center; description; run_date; flow_order; key_seq;
library; program; predicted_median_insert_size;
platform; platform_unit; sample;
}