12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(* Copyright (C) 2020, Francois Berenger
Yamanishi laboratory,
Department of Bioscience and Bioinformatics,
Faculty of Computer Science and Systems Engineering,
Kyushu Institute of Technology,
680-4 Kawazu, Iizuka, Fukuoka, 820-8502, Japan. *)(* A fingerprint-encoded molecule *)moduleA=ArraymoduleFp=FingerprintmoduleHt=HashtblmoduleL=MyListmoduleLO=Line_orientedopenPrintftypet={name:string;index:int;(* position in input file *)value:float;fp:Fp.t}letcreatenameindexvaluebitstring={name;index;value;fp=Fp.of_stringbitstring}(* read one molecule from an FP file *)letread_one_molline=tryScanf.sscanfline"%s@,%f,%s"(funnamevaluebitstring->(name,value,bitstring))withScanf.Scan_failuremsg->failwith("FpMol.read_one_mol: fmt: %s@,%f,%s err: "^msg^" line: "^line)letparse_oneindexline=letname,value,bitstring=read_one_mollineincreatenameindexvaluebitstring(* go back to the line format you came from *)letto_string(m:t):string=sprintf"%s,%g,[%s]"m.namem.value(Fp.to_stringm.fp)letto_outoutm=fprintfout"%s\n"(to_stringm)letmolecules_of_filefn=LO.mapifnparse_oneletdistm1m2=Fp.distancem1.fpm2.fplettanim1m2=Fp.tanimotom1.fpm2.fpletget_namex=x.nameletget_valuex=x.valueletget_indexx=x.indexletget_fpx=x.fpletnb_featuresx=Fp.nb_featuresx.fpletmol_is_activeline=BatString.starts_withline"active"letis_activex=mol_is_activex.nameletdrop_featuresto_dropx={xwithfp=Fp.drop_featuresto_dropx.fp}