Reply – OpenSMILES: Comments in SMILES files
Your Name
or Cancel
In Reply To
OpenSMILES: Comments in SMILES files
— by Craig James-2 Craig James-2
(Cross posted to OpenBabel-discuss and BlueObelisk-discuss)

A discussion has started in the OpenBabel list about comments in SMILES.  Currently, the SMILES spec has no provision for comments, but some implementations allow them.  For example, OpenBabel will silently ignore any line that starts with a non-SMILES character such as a space.  Here is what I wrote in response to a comment by Chris Morley:

> a) The facility to have comment lines in SMILES files seems
> *very* useful and it would be a great shame to lose it.

That's very true, and perhaps we should add something to the OpenSMILES specification.  Perhaps something like starting a line with '#' or '//', like so many other languages.  Or even starting a line with whitespace -- it doesn't matter, as long as it's formally specified.

As we used to say in my electrical engineering days: "The great thing about standards is that there are so many to choose from!"  In other words, a standard isn't any good unless we all follow it.  If OpenBabel treats these lines as comments, it will produce files that other parsers can't read.

Just to illustrate: Suppose someone else said, "I'm going to skip whitespace that starts a line, and parse SMILES starting at the first non-whitespace character."  In other words, they'd parse indented SMILES.  This isn't hypothetical, I've seen people do this.  They would try to parse the lines that you think are comments, so this file:

  |   This is a comment about
  |   CCO, the ethanol molecule, not to be mistaken with the
  |   CO methanol molecule.

would be interpreted by OpenBabel as one SMILES, and by the other guys as three SMILES and one error.

So my proposal is to say that any line that starts with '#', '/', or ' ' (space) should be treated as a comment line, and should be ignored completely when processing the file, except that it may be copied to the output if a program's output format supports comments.


OpenBabel-discuss mailing list
[hidden email]