Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file index.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106moduleA=BatArraymoduleL=BatListmoduleLog=Dolog.LogmoduleBstree=structincludeBst.Bisec_tree.Make(FpMol)letof_moleculesl=create1Two_bands(A.of_listl)end(* For each molecule, find its nearest neighbor name and distance,
over all Bsts; parallelized over molecules. *)letnearest_neighbor_namesncoresbst_fnsmols=matchbst_fnswith|[]->[]|fn::fns->letannot_mols=(* load one bst *)Log.info"loading %s..."fn;let(bst:Bstree.t)=Utls.restorefninParany.Parmap.parmapncores(funmol->letnn,dist=Bstree.nearest_neighbormolbstin(mol,FpMol.get_namenn,dist))molsin(* fold on the other BSTs *)L.fold_left(funannotatedbst_fn->(* load another bst *)Log.info"loading %s..."bst_fn;let(bst:Bstree.t)=Utls.restorebst_fninParany.Parmap.parmapncores(fun(mol,nn_name,dist)->ifdist=0.0then(* already nearest *)(mol,nn_name,dist)elseletcurr_nn,curr_dist=Bstree.nearest_neighbormolbstinifcurr_dist<distthen(mol,FpMol.get_namecurr_nn,curr_dist)else(mol,nn_name,dist))annotated)annot_molsfnsletbst_nearest_name_distbstmol=letnn,dist=Bstree.nearest_neighbormolbstin(FpMol.get_namenn,dist)(* For each molecule, find its nearest neighbor name and distance,
over all Bsts; parallelized over bisector trees (indexed chunks) *)letnearest_neighbor_names_a(ncores:int)(bst_fns:stringlist)(mols_a:FpMol.tarray):(FpMol.t*string*float)array=matchbst_fnswith|[]->[||]|fn::fns'->(* init accumulater, for the muxer process.
This is the only calculation parallelized over molecules.
Remaining calculations will be paralellized over Bsts. *)letannot_mols=Log.info"loading %s..."fn;let(bst:Bstree.t)=Utls.restorefninParany.Parmap.array_parmapncores(funmol->letname,dist=bst_nearest_name_distbstmolin(mol,name,dist))(mols_a.(0),"",1.0)mols_ainletfns=A.of_listfns'inlet()=Parany.runncores~demux:(leti=ref1in(* fn already processed *)letn=A.lengthfnsinfun()->if!i<nthenletres=!iinincri;reselseraiseParany.End_of_input)~work:(funi->Log.info"loading %s..."fns.(i);let(bst:Bstree.t)=Utls.restorefns.(i)inA.map(bst_nearest_name_distbst)mols_a)~mux:(letm=A.lengthmols_ainfunnearest_name_dists->assert(A.lengthnearest_name_dists=m);fori=0tom-1doletmol,_prev_nearest_name,prev_dist=A.unsafe_getannot_molsiinifprev_dist=0.0then(* already nearest *)()elseletcurr_nearest_name,curr_dist=A.unsafe_getnearest_name_distsiinifcurr_dist<prev_distthen(* update acc *)A.unsafe_setannot_molsi(mol,curr_nearest_name,curr_dist)done)inannot_mols