Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file bpmap.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283openCFStreamtypeprobe={org_name:string;version:string;chr_name:string;start_pos:int;sequence:Seq.t}typerow={pmcoord:int*int;mmcoord:int*int;probe:probe}typet=rowlistexceptionBadofstringletraise_badmsg=raise(Badmsg)letcol_names=["PMX";"PMY";"MMX";"MMY";"Seq";"Pos";"Probe"]letnum_probes=List.lengthletiterfl=List.iter~flletfoldfinitl=List.fold_left~f~initlletto_listt=tmoduleParser=structletheader(s:string):stringlist=letsl=String.splits~on:'\t'inifsl=col_namesthenslelseraise_bad"incorrectly formatted header"letrow~chr_map(s:string):row=matchString.splits~on:'\t'with|[pmcx;pmcy;mmcx;mmcy;org_ver_chr;pos;seq]->letorg,ver_chr=matchString.splitorg_ver_chr~on:':'with|[o;ver_chr]->o,ver_chr|_->raise_bad"expecting exactly one colon in Seq column"inletver,chr=matchString.splitver_chr~on:';'with|[v;c]->v,chr_mapc|_->raise_bad"expecting exactly one semicolon in Seq column"in{pmcoord=int_of_stringpmcx,int_of_stringpmcy;mmcoord=int_of_stringmmcx,int_of_stringmmcy;probe={org_name=org;version=ver;chr_name=chr;start_pos=int_of_stringpos;sequence=trySeq.of_stringseqwithSeq.Badm->raise_badm}}|_->raise_bad"expecting 7 columns"letbpmap~chr_mapfile=letparsefilecin=letlines=Lines.of_channelcininleterrmsg=Msg.err~pos:(Pos.make~source:file~line:(Stream.countlines)())msgintryignore(header((Stream.next_exnlines):Lines.item:>string));Stream.to_list(Stream.map~f:(fun(x:Lines.item)->row~chr_map(x:>string))lines)withFailuremsg|Badmsg->raise_bad(errmsg)inIn_channel.with_filefile~f:(parsefile)endletof_file?(chr_map=ident)file=Parser.bpmap~chr_mapfileletrow_to_stringr=let(pmx,pmy)=r.pmcoordinlet(mmx,mmy)=r.mmcoordinString.concat~sep:"\t"[string_of_intpmx;string_of_intpmy;string_of_intmmx;string_of_intmmy;r.probe.org_name^":"^r.probe.version^";"^r.probe.chr_name;string_of_int(r.probe.start_pos);Seq.to_string(r.probe.sequence)]letto_filefilet=letprintcout=fprintfcout"%s\n"(String.concat~sep:"\t"col_names);List.iter~f:(funx->fprintfcout"%s\n"(row_to_stringx))tinOut_channel.with_filefile~f:print