Chemistry::ESPT::Aprmcrd - AMBER prmcrd file object.


Chemistry-ESPT documentation Contained in the Chemistry-ESPT distribution.

Index


Code Index:

NAME

Top

Chemistry::ESPT::Aprmcrd - AMBER prmcrd file object.

SYNOPSIS

Top

    use Chemistry::ESPT::Aprmcrd;

    my $prmcrd = Chemistry::ESPT::Aprmcrd->new();

DESCRIPTION

Top

This module provides methods to quickly access data contained in an AMBER prmcrd file. AMBER prmcrd files can only be read currently.

ATTRIBUTES

Top

All attributes are currently read-only and get populated by reading the assigned ESS file. Attribute values are accessible through the $Aprmcrd->get() method.

CARTCOORD

NATOMS x 3 matrix containing Cartesian coordinates

METHODS

Top

Method parameters denoted in [] are optional.

$prmcrd->new()

Creates a new Aprmcrd object

$prmcrd->analyze(filename [spin])

Analyze the spin results in file called filename. Spin defaults to Alpha.

VERSION

Top

0.02

SEE ALSO

Top

Chemistry::ESPT::ESSfile, http://amber.scripps.edu

AUTHOR

Top

Dr. Jason L. Sonnenberg, <sonnenberg.11@osu.edu>

COPYRIGHT AND LICENSE

Top


Chemistry-ESPT documentation Contained in the Chemistry-ESPT distribution.
package Chemistry::ESPT::Aprmcrd;

use base qw(Chemistry::ESPT::ESSfile);
use strict;
use warnings;

our $VERSION = '0.02';

## the object constructor **

sub new {
	my $invocant = shift;
	my $class = ref($invocant) || $invocant;
	my $prmcrd = Chemistry::ESPT::ESSfile->new();

	$prmcrd->{PROGRAM} = "AMBER";
	$prmcrd->{TYPE} = "prmcrd";

	# molecular info
	$prmcrd->{CARTCOORD} = [];		# Current cartesian coordinates

	bless($prmcrd, $class);
	return $prmcrd;
}


## methods ##

# set filename & spin then digest the file
sub analyze : method {
	my $prmcrd = shift;
	$prmcrd->prepare(@_);
	$prmcrd->_digest();
	return;
}


## subroutines ##

sub _digest {

my $prmcrd = shift;

# flags & counters
my $counter = 0;
my $Titleflag = 1;

# open filename for reading or display error
open(PRMCRDFILE,$prmcrd->{FILENAME}) || die "Could not read $prmcrd->{FILENAME}\n$!\n";

# grab everything which may be useful
while (<PRMCRDFILE>){
	# skip blank lines
	next if /^$/;

	# title; first line of text
	if ( $Titleflag == 1 && /^[\w\d\-\(\)]+/ ) {
		chomp($_);
		s/\s+$//;
		$prmcrd->{TITLE} = $_;
		$Titleflag = 0;
		next;
	}
	# number of atoms
	if ( $Titleflag == 0 && /^\s+(\d+)$/ ) {
		$prmcrd->{NATOMS} = $1;
		next;
	}
        # current cartesian coordinates
        # store in an N x 3 array for the time being
        # switch to PerlMol objects in the future
        if ( /^\s+((?:-*\d+\.\d+\s+){1,6})/ ) {
		my @carts = split /\s+/, $1;
                for (my $i=0; $i<scalar(@carts); $i++) {
                        push @{ $prmcrd->{CARTCOORD} [$counter] }, $carts[$i];
                        $counter++ if $#{$prmcrd->{CARTCOORD} [$counter]}  == 2;
                }
                next;
        }

}
}


1;
__END__