|
AvogadroLibs 2.1.0-20261111
|
Implementation of the SMILES line notation. More...
#include <avogadro/io/smilesformat.h>
Public Member Functions | |
| Operations | supportedOperations () const override |
| FileFormat * | newInstance () const override |
| std::string | identifier () const override |
| A unique identifier, used to retrieve formats programmatically. CML, XYZ, PDB etc. A runtime warning will be generated if the identifier is not unique. | |
| std::string | name () const override |
| The name of the format, should be short such as Chemical Markup Language, XYZ format, Protein Databank etc. | |
| std::string | description () const override |
| std::string | specificationUrl () const override |
| std::vector< std::string > | fileExtensions () const override |
| Get the file name extension(s) that the format supports reading. | |
| std::vector< std::string > | mimeTypes () const override |
| Get the MIME type(s) that the format supports reading. | |
| void | setHydrogenMode (SmilesWriter::HydrogenMode mode) |
| void | setAtomMaps (bool enable) |
| void | setAromatic (bool enable) |
| bool | read (std::istream &inStream, Core::Molecule &molecule) override |
Read the given in stream and load it into molecule. | |
| bool | write (std::ostream &outStream, const Core::Molecule &molecule) override |
Write to the given out stream the contents of molecule. | |
| Public Member Functions inherited from FileFormat | |
| bool | open (const std::string &fileName, Operation mode) |
| Open the specified file in Read or Write mode. | |
| Operation | mode () |
| The mode the format is currently operating in. | |
| bool | isMode (Operation isInMode) |
| Check if the supplied mode(s) is being used. | |
| void | close () |
| Close any opened file handles. | |
| bool | readMolecule (Core::Molecule &molecule) |
| Read in a molecule, if there are no molecules to read molecule will be empty. This can be used to read in one or more molecules from a given file using repeated calls for each molecule. | |
| bool | writeMolecule (const Core::Molecule &molecule) |
| Write out a molecule. This can be used to write one or more molecules to a given file using repeated calls for each molecule. | |
| virtual bool | readFile (const std::string &fileName, Core::Molecule &molecule) |
Read the given fileName and load it into molecule. | |
| virtual bool | writeFile (const std::string &fileName, const Core::Molecule &molecule) |
Write to the given fileName the contents of molecule. | |
| bool | readString (const std::string &string, Core::Molecule &molecule) |
Read the given string and load it into molecule. | |
| bool | writeString (std::string &string, const Core::Molecule &molecule) |
Write to the given string the contents of molecule. | |
| std::string | error () const |
| Get the error string, contains errors/warnings encountered. | |
| std::string | fileName () const |
| Get the file name (if known). | |
| void | setOptions (const std::string &options) |
| Set options for the file reader. | |
| std::string | options () const |
| Get the file format options, can be used to change file IO. | |
| virtual void | clear () |
| virtual std::vector< std::string > | contentPatterns () const |
| Get literal strings that identify files in this format by content. | |
Additional Inherited Members | |
| Public Types inherited from FileFormat | |
| enum | Operation { None = 0x0 , Read = 0x1 , Write = 0x2 , ReadWrite = Read | Write , MultiMolecule = 0x4 , Stream = 0x10 , String = 0x20 , File = 0x40 , All = ReadWrite | MultiMolecule | Stream | String | File } |
| Flags defining supported operations. | |
| using | Operations = int |
| Static Public Member Functions inherited from FileFormat | |
| static bool | validateFileName (const std::string &fileName) |
| Validates the given file name. | |
| Protected Member Functions inherited from FileFormat | |
| void | appendError (const std::string &errorString, bool newLine=true) |
| Append an error to the error string for the format. | |
| bool | boolOption (const std::string &name, bool &value) |
| Look up a boolean value in the options() string. | |
| bool | stringOption (const std::string &name, std::string &value) |
| Look up a string value in the options() string. | |
| bool | stringArrayOption (const std::string &name, std::vector< std::string > &values) |
| Look up an array of strings in the options() string. | |
| long long | maxDecompressedSizeOption () |
| The ceiling on decompressed data for this read, in bytes. | |
| bool | integerOption (const std::string &name, long long &value) |
| Look up an integer value in the options() string. | |
Writing only. A SMILES string carries no coordinates, so reading one yields a molecule with every atom at the origin; until Avogadro can generate coordinates natively, reading stays with the Open Babel plugin and this format deliberately does not advertise Read.
Behaviour is controlled either through the typed setters below, or – for generic callers that only have a FileFormat – through setOptions() with a JSON object:
Keys present in the options string override the typed setters. See SmilesWriter for what the values mean. Note that "atomMaps" implies "explicit", and that both default to the interchange-safe values, since this format's output is pasted into other programs and sent to web services.
|
overridevirtual |
Implements FileFormat.
|
overridevirtual |
Create a new instance of the file format class. Ownership passes to the caller.
Implements FileFormat.
|
overridevirtual |
Implements FileFormat.
|
overridevirtual |
Implements FileFormat.
|
overridevirtual |
A description of the format, along with any relevant help text for users.
Implements FileFormat.
|
overridevirtual |
The URL of the format specification if available (relevant web page/wiki otherwise).
Implements FileFormat.
|
overridevirtual |
Implements FileFormat.
|
overridevirtual |
Implements FileFormat.
| void setHydrogenMode | ( | SmilesWriter::HydrogenMode | mode | ) |
Set how hydrogens are represented. Note that atomMaps() overrides this, see setAtomMaps().
| void setAtomMaps | ( | bool | enable | ) |
Emit each atom's index as a Daylight atom map class, so that the string can be correlated back to the molecule it came from.
Classes are written one-based, because Daylight assigns class zero the meaning "unmapped"; a consumer reading the classes back must subtract one to recover the Avogadro atom index.
This implies HydrogenMode::Explicit. A hydrogen folded into a bracket count has nowhere to carry a class, and in Avogadro that hydrogen is a real atom with a real index, so folding it would silently produce a partial mapping.
| void setAromatic | ( | bool | enable | ) |
Write perceived aromatic rings in the lowercase form, so benzene is "c1ccccc1" rather than "C1=CC=CC=C1". Both describe the same molecule; the lowercase form is what most toolkits produce and expect, so it is enabled by default and callers wanting Kekule output must ask for it.
Perception is Core::AromaticityPerceiver; anything it does not recognise is written with its bond orders as stored.
|
nodiscardoverridevirtual |
| in | The input file stream. |
| molecule | The molecule the data will be read into. |
Implements FileFormat.
|
nodiscardoverridevirtual |
| out | The output stream to write the data to. |
| molecule | The contents of this molecule will be written to output. |
Implements FileFormat.