Chemistry Reference
In-Depth Information
A.6 Core Function Implementation
for PostgreSQL
Some of the functions described in this topic are discussed in an abstract
way as chemical extensions to an RDBMS. There is a commercial imple-
mentation of these and other functions in the CHORD product of gNova.
This section shows three open-source implementations of the core func-
tions. It is necessary to install these additional modules and brief directions
are supplied here. It is also necessary to add the plperl and/or plpython
procedural languages to the PostgreSQL RDBMS. These are not installed
by default, but this is easily done using the createlang linux command
or the create language SQL command. The createlang command is
part of the installation packages for PostgreSQL.
createlang plperl
createlang plpythonu
A.6.1 PerlMol/plperlu
PerlMol is a module add-on to the perl language that facilitates working
with molecular structures using SMILES, SMARTS, and molfiles, as well
as other functionality. PerlMol is available from CPAN, the Comprehensive
Perl Archive Network. In order to install PerlMol, it is recommended to
use the command cpan -i PerlMol as superuser in order to install the
modules into the system perl library. This will install all the necessary
modules for the following functions, as well as other parts of PerlMol that
may be useful.
The following code will define the core functions described in Chapter
7 of this topic. The isosmiles function is not included here because of limi-
tation of PerlMol. These functions apply only to the PostgreSQL RDBMS.
Create Or Replace Function valid(text) Returns Boolean As $EOPERL$
use Chemistry::File ':auto';
#-- return true if input smi can be parsed
my ($smi) = @_;
my $mol = Chemistry::Mol->parse($smi, format => 'smiles', fatal => 0);
if ($mol->atoms(1)) {
#-- $mol has at least one valid atom
return true;
} else {
return false;
}
$EOPERL$ Language plperlu;
Search WWH ::




Custom Search