Chemistry::Smiles - SMILES parser (deprecated)
#!/usr/bin/perl use Chemistry::Smiles; my $s = 'C1C[13C]1(=O)[O-]'; # Default use - Requires Chemistry::Mol my $default_parser = new Chemistry::Smiles; my $mol = $default_parser->parse($s, new Chemistry::Mol); print $mol->print; # Callback use my $i = 0; my $callback_parser = new Chemistry::Smiles( add_atom => sub {print "ATOM(@_)\n"; ++$i}, add_bond => sub {print "BOND(@_)\n"} ); $callback_parser->parse($s, 'mol');
NOTE: THIS MODULE IS DEPRECATED! Use Chemistry::File::SMILES instead.
This object-oriented module parses a SMILES (Simplified Molecular Input Line Entry Specification) string. It can either return the molecule as a Chemistry::Mol object or be used via callback functions.
Create a SMILES parser. If the add_atom and add_bond subroutine references are given, they will be called whenever an atom or a bond needs to be added to the molecule. If they are not specified, default methods, which create a Chemistry::Mol object, will be used.
Parse a Smiles $string. $mol is a "molecule state object". It can be anything; the parser doesn't do anything with it except sending it as the first parameter to the callback functions. If callback functions were not provided when constructing the parser object, $mol must be a Chemistry::Mol object, because that's what the default callback functions require.
Called by the parser whenever an atom is found. The first parameter is the state object given to $obj->parse(). The other parameters are the isotope, symbol, chirality, hydrogen count, and charge of the atom. Only the symbol is guaranteed to be defined. Mnemonic: the parameters are given in the same order that is used in a SMILES string (such as [18OH-]). This callback is expected to return something that uniquely identifies the atom that was created (it might be a number, a string, or an object).
Called by the parser whenever an bond needs to be created. The first parameter is the state object given to $obj->parse(). The other parameters are the bond type and the two atoms that need to be bonded. The atoms are identified using the return values from the add_atom() callback.
The SMILES Home Page at http://www.daylight.com/dayhtml/smiles/ The Daylight Theory Manual at http://www.daylight.com/dayhtml/doc/theory/theory.smiles.html
The SMILES specification is not fully implemented yet. For example, branches that start before an atom (such as (OC)C, which should be equivalent to C(CO) and COC).
Ivan Tubert <itub@cpan.org>
Copyright (c) 2004 Ivan Tubert. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Chemistry::Smiles, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Chemistry::Smiles
CPAN shell
perl -MCPAN -e shell install Chemistry::Smiles
For more information on module installation, please visit the detailed CPAN module installation guide.