let parse_alignment ?ref_seqs line =
match String.split ~on:'\t' (line : Line.t :> string) with
| qname::flags::rname::pos::mapq::cigar::rnext
::pnext::tlen::seq::qual::optional_fields
-> (
parse_qname qname >>= fun qname ->
parse_flags flags >>= fun flags ->
parse_rname rname >>= fun rname ->
parse_pos pos >>= fun pos ->
parse_mapq mapq >>= fun mapq ->
parse_cigar cigar >>= fun cigar ->
parse_rnext rnext >>= fun rnext ->
parse_pnext pnext >>= fun pnext ->
parse_tlen tlen >>= fun tlen ->
parse_seq seq >>= fun seq ->
parse_qual qual >>= fun qual ->
Result.List.map optional_fields ~f:parse_optional_field
>>= fun optional_fields ->
alignment
?ref_seqs ?qname ~flags ?rname ?pos ?mapq ~cigar
?rnext ?pnext ?tlen ?seq ~qual ~optional_fields
()
)
| _ ->
Or_error.error_string "alignment line contains < 12 fields"