123456789101112131415161718192021(* read one molecule from a SMILES file *)letread_one(input:in_channel):string=letline=input_lineinputin(* strip protects against trailing '\r'
we append '\n' because all other formats
end molecules with a '\n' *)(BatString.stripline)^"\n"letget_namesmiles_line=let_smiles,name=tryBatString.splitsmiles_line~by:"\t"withNot_found->failwith"Smi.get_name: smiles file not using tabs"in(* all other file formats expect molecule name only,
* not molecule name followed by EOL *)ifBatString.ends_withname"\r\n"thenBatString.rchop~n:2nameelseifBatString.ends_withname"\n"thenBatString.rchop~n:1nameelsename