Chemistry Reference
In-Depth Information
Create Or Replace Function MF(text) Returns Text As $EOPERL$
use Chemistry::File::SMILES;
use Chemistry::File::Formula;
my ($s) = @_;
my $mol = Chemistry::Mol->parse($s, format => 'smiles');
return $mol->print(format => formula);
$EOPERL$ Language plperlu;
Notice that the mechanism for passing arguments is identical to an ordinary
perl function - using the @_ variable. The return value is simply a string.
Executing functions written in an interpreted language like perl or
python is slower than using a compiled language. The cansmiles func-
tion written in plperl and using PerlMol (see Appendix) is many times
slower than the cansmiles function available in CHORD from gNova,
Inc. However, PerlMol is open source and contains many useful functions
for processing molecular structures. On the other hand, the SMILES and
SMARTS representations in PerlMol do not include stereochemical centers
and have other limitations compared to the OpenEye OEChem library used
in CHORD. As always, there are trade-offs involved in any decision about
which computer languages and libraries to use for a particular project.
Another important consideration in selecting a procedural language
for functions is the time it takes to develop the function. It is generally
true that developing code in Perl or Python is faster than using a compiled
language like C. It is also more complicated to handle input arguments
and return values from C functions in PostgreSQL.
10.5.3 Core Chemical Functions
Chapter 7 introduced several core functions that serve as a foundation for a
very useful chemical extension of an RDBMS. The CHORD cartridge from
gNova, Inc. implements those functions and others. The previous section
discussed a PerlMol implementation of some of the core functions. There
are many other useful functions in the PerlMol modules. It is easy to build
a very powerful extension of PostgreSQL using plperl and PerlMol. The
Appendix shows how all of the functions described in Chapter 7 can be
implemented using plperl and PerlMol. The Appendix also shows another
open source implementation using plpythonu procedural language and
the FROWNS toolkit. 4 The third implementation of the core functions
shown in the Appendix uses plpythonu and OpenBabel. 5
Table 10.1 summarizes the core functions that are implemented using
PerlMol, FROWNS, and OpenBabel. The fingerprint fp function is not
included in the core functions as defined in Chapter 7, but it is a very
useful function for computing similarities of molecular structures and
for speeding up structure matching using the matches function. The fin-
gerprint function fp is not implemented using PerlMol. The isosmiles
Search WWH ::




Custom Search