| 1 | #!/home/ivan/bin/perl | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # Mok command line interpreter. This is part of the Chemistry::Mok | ||||||||||||||||||||
| 4 | # distribution. | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 8 | our $VERSION = '0.25'; | |||||||||||||||||||
| 7 | 8 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 8 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 8 | ▶ | no warnings qw(once); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 8 | ▶ | use Chemistry::Mok; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 8 | ▶ | use Getopt::Std; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 8 | $| = 1; # don't buffer stdio | |||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 8 | my %opt; | |||||||||||||||||||
| 16 | 8 | getopts('c:f:t:hvbp:dazD3', \%opt); | |||||||||||||||||||
| 17 | 8 | ▶ | usage() if $opt{h}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 8 | my $code; | |||||||||||||||||||
| 20 | 8 | ▶ | if ($opt{f}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 4 | ▶ | open F, "< $opt{f}" or die "Couldn't read $opt{f}\n"; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 22 | 4 | {local $/; $code = <F>;} | |||||||||||||||||||
| 23 | 4 | close F; | |||||||||||||||||||
| 24 | } else { | ||||||||||||||||||||
| 25 | 4 | ▶ | $code = shift || usage(); | ||||||||||||||||||
|
Condition33%1/3
shift @ARGV || usage()
MC/DC0%0/2
shift @ARGV || usage()
shift @ARGV
usage()
Truth table33%1/3
A || B
A= shift @ARGVB= usage()
| |||||||||||||||||||||
| 26 | } | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | 8 | my @files = @ARGV; | |||||||||||||||||||
| 29 | 8 | ▶ | if ($^O eq 'MSWin32') { # do our own globbing under Windows | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | @files = map glob, @files; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 8 | ▶ | $Chemistry::Mok::DEBUG = 1 if $opt{D}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | my $mok = Chemistry::Mok->new($code, | ||||||||||||||||||||
| 35 | 8 | ▶ | pattern_format => $opt{p} || 'smarts', | ||||||||||||||||||
|
Condition50%1/2
$opt{'p'} || 'smarts'
MC/DC0%0/1
$opt{'p'} || 'smarts'
$opt{'p'}
Truth table50%1/2
A
A= $opt{'p'}
| |||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | $mok->run( | ||||||||||||||||||||
| 40 | { | ||||||||||||||||||||
| 41 | mol_class => $opt{c}, | ||||||||||||||||||||
| 42 | format => $opt{t}, | ||||||||||||||||||||
| 43 | find_bonds => $opt{b}, | ||||||||||||||||||||
| 44 | delete_dummies => $opt{d}, | ||||||||||||||||||||
| 45 | aromatize => $opt{a}, | ||||||||||||||||||||
| 46 | 0 | build_3d => $opt{3}, | |||||||||||||||||||
| 47 | }, | ||||||||||||||||||||
| 48 | @files | ||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 0 | ▶ | sub usage { | ||||||||||||||||||
|
Subroutine
usage: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 52 | 0 | print <<EOF; | |||||||||||||||||||
| 53 | mok version $VERSION | ||||||||||||||||||||
| 54 | Usage: $0 [OPTION]... 'CODE' FILE... | ||||||||||||||||||||
| 55 | Read each molecular file and run CODE on each. Options: | ||||||||||||||||||||
| 56 | -3 generate 3D coordinates using Chemistry::3DBuilder | ||||||||||||||||||||
| 57 | -a "aromatize" each molecule as it is read | ||||||||||||||||||||
| 58 | -b find bonds from 3D coordinates | ||||||||||||||||||||
| 59 | -c CLASS use CLASS instead of Chemistry::Mol to read molecules | ||||||||||||||||||||
| 60 | -D print debugging information (very verbose) | ||||||||||||||||||||
| 61 | -d delete dummy atoms after reading each molecule | ||||||||||||||||||||
| 62 | -f FILE run the code from FILE instead of the command line | ||||||||||||||||||||
| 63 | -h this help | ||||||||||||||||||||
| 64 | -p TYPE parse patterns using the specified TYPE. Default: 'smarts' | ||||||||||||||||||||
| 65 | -t TYPE assume that every file has the specified TYPE | ||||||||||||||||||||
| 66 | EOF | ||||||||||||||||||||
| 67 | 0 | exit; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | __END__ | ||||||||||||||||||||