let rname al header = try Ok (Option.map (ref_id al) ~f:(fun id -> (Array.get header.ref_seq id).Sam.name)) with _ -> error_string "Bam.Alignment0.rname: unknown ref_id"