1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465moduleError=structtypet=[|`chromosome_ambiguous_in_roman_formofstring]endexceptionErrorofError.t(* Use stronger type t internally. *)moduleI=structtypet=|ChrX|ChrY|ChrM|ChrNofint(* int is strictly greater than 0 *)|Unknownofstringletof_strings=lets'=String.lowercasesinletc=ifString.(is_prefixs'~prefix:"chr")thenString.(subs'~pos:3~len:(lengths'-3))elses'inmatchcwith|"x"->ChrX|"y"->ChrY|"m"|"mt"|"mtdna"->ChrM|_->matchRoman_num.of_romancwith|Okn->ChrN(Roman_num.to_arabicn)|Error_->tryletn=int_of_stringcinifn>0thenChrNnelseUnknownswithFailure_->Unknownsletnon_num_to_string=function|ChrX->"X"|ChrY->"Y"|ChrM->"M"|Unknowns->s|ChrN_->assertfalseletto_string_arabict=matchtwith|ChrX|ChrY|ChrM|Unknown_->non_num_to_stringt|ChrNn->string_of_intnletto_string_romant=letans=matchtwith|ChrX|ChrY|ChrM|Unknown_->non_num_to_stringt|ChrNn->Roman_num.to_roman(Roman_num.of_arabicn|>ok_exn)inifList.mem~equal:String.(=)["x";"y";"m";"mt";"mtdna"](String.lowercaseans)thenResult.Error(`chromosome_ambiguous_in_roman_form(to_string_arabict))elseOkansendletto_arabics=I.(s|>of_string|>to_string_arabic)letto_romans=I.(s|>of_string|>to_string_roman)letto_roman_exns=matchto_romanswith|Okx->x|Result.Errorx->raise(Errorx)