1234567891011121314151617181920212223(* very small atom module to help compute atom environments (a la molprint2d) from MOL2 files *)openPrintftypet={idx:int;typ:string}letcreate(idx:int)(typ:string):t=(* indexes start at 1 in MOL2 files *){idx=idx-1;typ}letdummy=create(-1)""(* example line (output of OpenBabel):
" 1 S -0.0218 1.7554 0.0117 S.2 1 LIG1 -0.0637" *)letof_mol2_line(l:string):t=tryScanf.sscanfl" %d %s %f %f %f %s@ %s@ %s@ %s"(funidx_name_x_y_ztyp_bs0_bs1_bs2->createidxtyp)with_->failwith("Atom.of_mol2_line: could not parse: "^l)letto_string(a:t):string=sprintf"%d %s"a.idxa.typ