AvogadroLibs  1.91.0
Public Member Functions | List of all members
OBProcess Class Reference

The OBProcess class provides an interface to the obabel executable, which is run in a separate process. More...

#include <obprocess.h>

Inheritance diagram for OBProcess:

Public Member Functions

 OBProcess (QObject *parent_=0)
 
QString version ()
 

Process Management

Methods, slots, and signals used to interact with the OpenBabel process.

QString obabelExecutable () const
 
bool inUse () const
 
void abort ()
 
void obError ()
 
void aborted ()
 

File Format Support

Query the obabel executable for supported file formats.

bool queryReadFormats ()
 
bool queryWriteFormats ()
 
void queryReadFormatsFinished (QMap< QString, QString > readFormats)
 
void queryWriteFormatsFinished (QMap< QString, QString > writeFormats)
 

Format Operations

Operations that manipulate molecular representations.

bool convert (const QByteArray &input, const QString &inFormat, const QString &outFormat, const QStringList &options=QStringList())
 
bool convert (const QString &filename, const QString &inFormat, const QString &outFormat, const QStringList &options=QStringList())
 
void convertFinished (const QByteArray &output)
 

Force Fields

Methods, signals, and slots pertaining to force fields (e.g. geometry optimizations).

bool queryForceFields ()
 
bool optimizeGeometry (const QByteArray &cml, const QStringList &options)
 
void queryForceFieldsFinished (const QMap< QString, QString > &forceFields)
 
void optimizeGeometryFinished (const QByteArray &cml)
 
void optimizeGeometryStatusUpdate (int step, int maxSteps, double currentEnergy, double lastEnergy)
 

Detailed Description

The obabel executable used by this class can be overridden by setting the AVO_OBABEL_EXECUTABLE environment variable.

Member Function Documentation

◆ version()

QString version ( )
Returns
The output of obabel -V.

◆ obabelExecutable()

QString obabelExecutable ( ) const

The obabel executable used by the process.

◆ inUse()

bool inUse ( ) const
Returns
True if the process is in use, false otherwise.

◆ abort

void abort ( )
slot

Abort any currently running processes.

This will cause aborted() to be emitted, but not any of the operation-specific "finished" signals.

◆ obError

void obError ( )
slot

Called when an error in the process occurs.

◆ aborted

void aborted ( )
signal

Emitted when the abort() method has been called.

◆ queryReadFormats

bool queryReadFormats ( )
slot

Request a list of all supported input formats from obabel.

After calling this method, the queryReadFormatsFinished signal will be emitted. This method executes

obabel -L formats read

and parses the output into a map (keys are format descriptions, values are format extensions).

If an error occurs, queryReadFormatsFinished will be emitted with an empty argument.

Returns
True if the process started successfully, false otherwise.

◆ queryWriteFormats

bool queryWriteFormats ( )
slot

Request a list of all supported output formats from obabel.

After calling this method, the queryWriteFormatsFinished signal will be emitted. This method executes

obabel -L formats write

and parses the output into a map (keys are format descriptions, values are format extensions).

If an error occurs, queryWriteFormatsFinished will be emitted with an empty argument.

Returns
True if the process started successfully, false otherwise.

◆ queryReadFormatsFinished

void queryReadFormatsFinished ( QMap< QString, QString >  readFormats)
signal

Triggered when the process started by queryReadFormats() completes.

Parameters
readFormatsThe input file formats that OpenBabel understands. Keys are non-translated (english), human-readable descriptions of the formats, and the values are the corresponding file extensions.
Note
readFormats will usually contain more than one extensions per format, so accessing the values with QMap::values() (instead of QMap::value()) is required.

If an error occurs, readFormats will be empty.

◆ queryWriteFormatsFinished

void queryWriteFormatsFinished ( QMap< QString, QString >  writeFormats)
signal

Triggered when the process started by queryWriteFormats() completes.

Parameters
writeFormatsThe file formats that OpenBabel can write. Keys are non-translated (english), human-readable descriptions of the formats, and the values are the corresponding file extensions.
Note
writeFormats will usually contain more than one extensions per format, so accessing the values with QMap::values() (instead of QMap::value()) is required.

If an error occurs, writeFormats will be empty.

◆ convert [1/2]

bool convert ( const QByteArray &  input,
const QString &  inFormat,
const QString &  outFormat,
const QStringList &  options = QStringList() 
)
slot

Convert the text representation in input from inFormat to outFormat.

Parameters
inputText representation of molecule in inFormat format.
inFormatFile extension corresponding to input format (see obabel -L formats).
outFormatFile extension corresponding to output format.
optionsAdditional options passed to obabel.

After calling this method, the convertFinished signal will be emitted to indicate return status along with the requested representation of the molecule.

The conversion is performed as: obabel -i<inFormat> -o<outFormat> <options> < input > output

Returns
True if the process started succesfully, false otherwise.

◆ convert [2/2]

bool convert ( const QString &  filename,
const QString &  inFormat,
const QString &  outFormat,
const QStringList &  options = QStringList() 
)
slot

Convert the file filename from inFormat to outFormat.

Parameters
filenameFile containing molecule representation in inFormat format.
inFormatFile extension corresponding to input format (see obabel -L formats).
outFormatFile extension corresponding to output format.
optionsAdditional options passed to obabel.

After calling this method, the convertFinished signal will be emitted to indicate return status along with the requested representation of the molecule.

The conversion is performed as: obabel -i<inFormat> <filename> -o<outFormat> <options> > output

Returns
True if the process started succesfully, false otherwise.

◆ convertFinished

void convertFinished ( const QByteArray &  output)
signal

Emitted after a call to convert() finishes.

Parameters
outputThe molecule in CML format, or an empty QByteArray if an e error occurred.

◆ queryForceFields

bool queryForceFields ( )
slot

Request a list of all supported force fields from obabel.

After calling this method, the queryForceFieldsFinished signal will be emitted. This method executes

obabel -L forcefields

and parses the output.

If an error occurs, queryReadFormatsFinished will be emitted with an empty argument.

Returns
True if the process started successfully, false otherwise.

◆ queryForceFieldsFinished

void queryForceFieldsFinished ( const QMap< QString, QString > &  forceFields)
signal

Triggered when the process started by queryForceFields() completes.

Parameters
forceFieldsThe force fields supported by OpenBabel. Keys are unique identifiers for the force fields, and the values are non-translated (english), human-readable descriptions.

If an error occurs, forceFields will be empty.

◆ optimizeGeometry

bool optimizeGeometry ( const QByteArray &  cml,
const QStringList &  options 
)
slot

Request that obabel optimize a molecular structure using its minimize operation.

Parameters
cmlA Chemical Markup Language representation of the molecule.
optionsOptions for the optimization. See OBForceFieldDialog::prompt for an easy method way to get the options from the user.

After calling this method, the optimizeGeometryStatusUpdate signal will be emitted periodically to indicate the optimization's progress. Once the optimization finishes, optimizeGeometryFinished will be emitted with the result of the optimization.

The optimization is started with obabel -icml -ocml --minimize <options>

The standard output is recorded and returned by optimizeGeometryFinished. If options contains --log, the obabel process's standard error stream is monitored for the data used in the optimizeGeometryStatusUpdate progress updates.

Returns
True if the process started successfully, false otherwise.

◆ optimizeGeometryFinished

void optimizeGeometryFinished ( const QByteArray &  cml)
signal

Emitted with the standard output of the process when it finishes. If an error occurs, the argument will not be valid CML.

◆ optimizeGeometryStatusUpdate

void optimizeGeometryStatusUpdate ( int  step,
int  maxSteps,
double  currentEnergy,
double  lastEnergy 
)
signal

Emitted every 10 steps of the optimization to indicate the current progress.

Parameters
stepThe current step of the minimization algorithm.
maxStepsThe maximum number of steps before the minimization is aborted.
currentEnergyThe energy of the molecule at the current step.
lastEnergyThe energy of the molecule at the previous minimization step.

The documentation for this class was generated from the following file: