123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081(* 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=MyListopenPrintftypet={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=Utls.mapi_on_lines_of_filefnparse_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}