Chemistry-Mok

 view release on metacpan or  search on metacpan

MANIFEST  view on Meta::CPAN

Changes
MANIFEST			This list of files
Makefile.PL
README
atom_count.mok
atom_count.out
count_c.mok
count_c.out
formula.mok
formula.out
length.mok
length.out
lib/Chemistry/Mok.pm
mok
s94.mol
s95.mol
s97.mol
s98.mol
s99.mol
t/mok.t

formula.mok  view on Meta::CPAN

{ printf qq{$FILE: %s (%s)\n}, $MOL->name, $MOL->formula }

lib/Chemistry/Mok.pm  view on Meta::CPAN

Chemistry::Mok::UserCode::$options{package} package instead of the
Chemistry::Mok::UserCode::Default package. Specifying a package name is
recommended if you have more than one mok object and you are using global
varaibles, in order to avoid namespace clashes.

=item C<pattern_format>

The name of the format which will be used for parsing slash-delimited patterns
that don't define an explicit format. Mok versions until 0.16 only used the
'smiles' format, but newer versions can use other formats such as 'smarts',
'midas', 'formula_pattern', and 'sln', if available. The default is 'smarts'.

=back

=cut

sub new {
    my ($class, $code, @a) = @_;
    my %opts;

    # for backwards compatibility with Chemistry::Mok->new($code, $package)

mok  view on Meta::CPAN


=item -p TYPE     

Parse patterns using the specified TYPE. Default: 'smarts'. Other options are
'smiles' and 'midas'.

=item -t TYPE     

Assume that every file has the specified TYPE. Available types depend on
which Chemistry::File modules are installed, but currently available types
include mdl, sdf, smiles, formula, mopac, pdb.

=back

=head1 LANGUAGE SPECIFICATION

A Mok script consists of a sequence of pattern-action statements and
optional subroutine definitions, in a manner very similar to the AWK
language.

    pattern_type:/pattern/options { action statements }

mok  view on Meta::CPAN


=back

=head1 EXAMPLES

Print the names of all the molecules found in all the .sdf files in the 
current directory:

    mok 'println $MOL->name' *.sdf

Find esters among *.mol; print the filename, molecule name, and formula:

    mok '/C(=O)OC/{ printf "$FILE: %s (%s)\n", 
        $MOL->name, $MOL->formula }' *.mol

Find out the total number of atoms:

    mok '{ $n += $MOL->atoms } END { print "Total: $n atoms\n" }' *.mol

Find out the average C-S bond length:

    mok '/CS/g{ $n++; $len += $B[0]->length }
        END { printf "Average C-S bond length: %.3f\n", $len/$n; }' *.mol

Convert PDB files to MDL molfiles:

    mok '{ $FILE =~ s/pdb/mol/; $MOL->write($FILE, format => "mdlmol") }' *.pdb

Find molecules with a given formula by overriding the formula pattern type
globally (this example requires L<Chemistry::FormulatPattern>):

    mok -p formula_pattern '/C6H12O6/{ println $MOL->name }' *.sdf

Find molecules with a given formula by overriding the formula pattern type
just for one specific pattern. This can be used when more than one pattern
type is needed in one script.

    mok 'formula_pattern:/C6H12O6/{ println $MOL->name }' *.sdf


=head1 SEE ALSO

awk(1), perl(1)
L<Chemistry::Mok>,
L<Chemistry::Mol>, L<Chemistry::Pattern>,
L<http://dmoz.org/Arts/Animation/Cartoons/Titles/T/Thundarr_the_Barbarian/>.

Tubert-Brohman, I. Perl and Chemistry. The Perl Journal 2004-06 



( run in 0.267 second using v1.01-cache-2.11-cpan-26ccb49234f )