| 1 | package Chemistry::File::QChemOut; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 1 | $VERSION = '0.10'; | |||||||||||||||||||
| 4 | # $Id: QChemOut.pm,v 1.1.1.1 2006/10/04 16:13:50 itubert Exp $ | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use base qw(Chemistry::File); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use Chemistry::Mol; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 1 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | Chemistry::File::QChemOut - Q-Chem ouput molecule format reader | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | use Chemistry::File::QChemOut; | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | # read an QChemOut file | ||||||||||||||||||||
| 21 | my $mol = Chemistry::Mol->read("myfile.out", format => 'qchemout'); | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | # read all the intermediate structures (e.g., optimization steps) | ||||||||||||||||||||
| 24 | my $mol = Chemistry::Mol->read("myfile.out", | ||||||||||||||||||||
| 25 | format => 'chemout', all => 1); | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | =head1 DESCRIPTION | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | This module reads Q-Chem output files. It automatically registers the | ||||||||||||||||||||
| 32 | 'qchemout' format with Chemistry::Mol, so that Q-Chem outuput files may be | ||||||||||||||||||||
| 33 | identified and read using Chemistry::Mol->read(). | ||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | The current version of this reader simply extracts the cartesian coordinates | ||||||||||||||||||||
| 36 | and symbols from the Q-Chem outuput file. All other information is ignored. | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | =head1 INPUT OPTIONS | ||||||||||||||||||||
| 39 | |||||||||||||||||||||
| 40 | =over | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =item all | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | If true, read all the intermediate structures, as in a structure optimization. | ||||||||||||||||||||
| 45 | This causes $mol->read to return an array instead of a single molecule. | ||||||||||||||||||||
| 46 | Default: false. | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =back | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =cut | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 1 | Chemistry::Mol->register_format(qchemout => __PACKAGE__); | |||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 2 | ▶ | sub parse_string { | ||||||||||||||||||
|
Subroutine
parse_string: called CC=8 SCAR=21.0
Pod
documented
| |||||||||||||||||||||
| 55 | 2 | my ($class, $s, %opts) = @_; | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 2 | ▶ | my $mol_class = $opts{mol_class} || 'Chemistry::Mol'; | ||||||||||||||||||
|
Condition50%1/2
$opts{'mol_class'} || 'Chemistry::Mol'
MC/DC0%0/1
$opts{'mol_class'} || 'Chemistry::Mol'
$opts{'mol_class'}
Truth table50%1/2
A
A= $opts{'mol_class'}
| |||||||||||||||||||||
| 58 | 2 | ▶ | my $atom_class = $opts{atom_class} || $mol_class->atom_class; | ||||||||||||||||||
|
Condition33%1/3
$opts{'atom_class'} || $mol_class->atom_class
MC/DC0%0/2
$opts{'atom_class'} || $mol_class->atom_class
$opts{'atom_class'}
$mol_class->atom_class
Truth table33%1/3
A || B
A= $opts{'atom_class'}B= $mol_class->atom_class
| |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 2 | my @coord_blocks = $s =~ m{ | |||||||||||||||||||
| 61 | Standard\ Nuclear\ Orientation | ||||||||||||||||||||
| 62 | .*? | ||||||||||||||||||||
| 63 | ---- | ||||||||||||||||||||
| 64 | (?:\n|\r\n?) | ||||||||||||||||||||
| 65 | (.*?) # coordinate block | ||||||||||||||||||||
| 66 | \ ---- | ||||||||||||||||||||
| 67 | }smxg; | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 2 | ▶ | croak "no coordinates found" unless @coord_blocks; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 2 | ▶ | unless ($opts{all}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 72 | # keep only the last block | ||||||||||||||||||||
| 73 | 1 | splice @coord_blocks, 0, @coord_blocks - 1; | |||||||||||||||||||
| 74 | } | ||||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 2 | my @mols; | |||||||||||||||||||
| 77 | 2 | for my $block (@coord_blocks) { | |||||||||||||||||||
| 78 | 5 | my $mol = $mol_class->new(); | |||||||||||||||||||
| 79 | 5 | my @lines = split /(?:\n|\r\n?)/, $block; | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 5 | my $i = 0; | |||||||||||||||||||
| 82 | 5 | for my $line (@lines) { | |||||||||||||||||||
| 83 | 40 | $i++; | |||||||||||||||||||
| 84 | 40 | $line =~ s/^\s+//; | |||||||||||||||||||
| 85 | 40 | my ($n, $symbol, $x, $y, $z) = split ' ', $line; | |||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 40 | my $atom = $mol->new_atom( | |||||||||||||||||||
| 88 | symbol => $symbol, | ||||||||||||||||||||
| 89 | coords => [$x, $y, $z], | ||||||||||||||||||||
| 90 | ); | ||||||||||||||||||||
| 91 | } | ||||||||||||||||||||
| 92 | 5 | push @mols, $mol; | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 2 | ▶ | return $opts{all} ? @mols : $mols[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 96 | } | ||||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | ▶ | sub name_is { | ||||||||||||||||||
|
Subroutine
name_is: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 99 | 0 | my ($class, $fname) = @_; | |||||||||||||||||||
| 100 | 0 | return; | |||||||||||||||||||
| 101 | 0 | $fname =~ /\.xyz$/i; | |||||||||||||||||||
| 102 | } | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | 0 | ▶ | sub file_is { | ||||||||||||||||||
|
Subroutine
file_is: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 105 | 0 | my ($class, $fname) = @_; | |||||||||||||||||||
| 106 | 0 | return; | |||||||||||||||||||
| 107 | 0 | $fname =~ /\.xyz$/i; | |||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | 0 | ▶ | sub write_string { | ||||||||||||||||||
|
Subroutine
write_string: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 111 | 0 | my ($class, $mol, %opts) = @_; | |||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 0 | croak "QChemOut writing not implemented"; | |||||||||||||||||||
| 114 | } | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | 1 | 1; | |||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | =head1 VERSION | ||||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 0.10 | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 SEE ALSO | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | L<Chemistry::Mol>, L<http://www.perlmol.org/>. | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | =head1 AUTHOR | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | Ivan Tubert-Brohman <itub@cpan.org> | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||
| 131 | |||||||||||||||||||||