NAME

HackaMol - HackaMol: Object-Oriented Library for Molecular Hacking

VERSION

version 0.00_01

SYNOPSIS

use HackaMol;

use Math::Vector::Real;

use Math::Vector::Real::Random;

use Math::Trig;

my $hack = HackaMol->new( name => "hackitup" );

my @atoms = $hack->read_file_atoms("t/lib/1L2Y.pdb");

my $mol = HackaMol::Molecule->new( name => 'trp-cage', atoms => [@atoms] );

# all coordinates from NMR ensemble are loaded

my $fh = $mol->print_xyz( $mol->name . ".xyz" ); foreach my $t ( 1 .. 4 ) { $mol->t($t); $mol->print_xyz($fh); }

$mol->t(0);

$mol->translate( -$mol->COM );

$mol->rotate( V( 1, 0, 0 ), 180, V( 10, 10, 10 ) );

$mol->print_xyz($fh);

$mol->translate( -$mol->COM );

$mol->print_xyz($fh);

# translate/rotate method is provided by AtomGroupRole #populate groups byatom resid attr my @groups = $hack->group_by_atom_attr( 'resid', $mol->all_atoms ); $mol->push_groups(@groups);

foreach my $ang ( 1 .. 36 ) { $_->rotate( V( 1, 1, 1 ), 10, $_->COM ) foreach $mol->all_groups;

#  $mol->get_groups(1)->print_xyz;
$mol->print_xyz($fh);
}

$fh->close;

my $radius = 20; my $natoms = int( 0.0334 * ( $radius**3 ) * 4 * pi / 3 );

my @sphatoms = map { HackaMol::Atom->new( Z => 8, charges => [0], coords => [$_] ) } map { Math::Vector::Real->random_in_sphere( 3, $radius ) } 1 .. $natoms;

my $sphere = HackaMol::Molecule->new( name => "ball", atoms => [@sphatoms] );

my $bigmol = HackaMol::Molecule->new( name => "bigoverlap", atoms => [ $mol->all_atoms, $sphere->all_atoms ], );

$fh = $bigmol->print_xyz( $bigmol->name . ".xyz" );

foreach my $ang ( 1 .. 36 ) { $sphere->rotate( V( 1, 1, 1 ), 20, $sphere->COM ); $bigmol->print_xyz($fh); }

DESCRIPTION

The HackaMol library enables users to build simple, yet powerful scripts for carrying out computational work on molecules at multiple scales. The molecular object system organizes atoms within molecules using groups, bonds, angles, and dihedrals. HackaMol seeks to provide intuitive attributes and methods that may be harnessed to coerce computational chemistry through a common core.

The HackaMol class uses the core classes to provide some object building utilities described below. This class consumes HackaMol::MolReadRole to provide structure readers for xyz and pdb coordinates. Additional formats are pretty easy to add, but using open babel to do so may be a more robust approach.

METHODS

build_bonds

takes a list of atoms and returns a list of bonds. The bonds are generated for "list neighbors" by simply stepping through the atom list one at a time. e.g.

my @bonds = $hack->build_bonds(@atoms[1,3,5]);

will return two bonds: B13 and B35 

build_angles

takes a list of atoms and returns a list of angles. The angles are generated for "list neighbors" by simply stepping through the atom list one at a time. e.g.

my @angles = $hack->build_angles(@atoms[1,3,5]);

will return one angle: A135

build_dihedrals

takes a list of atoms and returns a list of dihedrals. The dihedrals are generated for "list neighbors" by simply stepping through the atom list one at a time. e.g.

my @dihedral = $hack->build_dihedrals(@atoms[1,3,5]);

will croak!  you need atleast four atoms.

my @dihedral = $hack->build_dihedrals(@atoms[1,3,5,6,9]);

will return two dihedrals: D1356 and D3569

group_by_atom_attr

takes atom attribute as argument and builds AtomGroup objects by attribute

find_bonds_brute

takes hash argument list and returns bonds. Find bonds between bond_atoms and the candidates.

my @oxy_bonds = $hack->find_bonds_brute(
                                  bond_atoms => [$hg],
                                  candidates => [$mol->all_atoms],
                                  fudge      => 0.45,
                );

fudge is an optional argument. Default is 0.45 (open babel uses same default). find_bonds_brute uses a bruteforce algorithm that tests the interatomic separation against the sum of the covalent radii + fudge. It does not return a self bond for an atom ( next if refaddr($ati) == refaddr($atj) ).

ATTRIBUTES

name

name is a rw str provided by HackaMol::NameRole.

SEE ALSO

EXTENDS

CONSUMES

AUTHOR

Demian Riccardi <demianriccardi@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by Demian Riccardi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.