Chemistry::Domain - Class for domains in macromolecules


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

Index


Code Index:

NAME

Top

Chemistry::Domain - Class for domains in macromolecules

SYNOPSIS

Top

  use Chemistry::Domain;
  my $domain = Chemistry::Domain->new(parent => $bigmol);

DESCRIPTION

Top

A domain is a substructure of a larger molecule. It is typically used to represent aminoacid residues within a protein, or bases within a nucleic acid, but you could use it for any arbitrary substructure such as functional groups and rings. A domain has all the properties of a molecule, plus a "parent". The parent is the larger molecule that contains the domain. In other words, the Chemistry::Domain class inherits from Chemistry::Mol.

METHODS

Top

Note: the methods that are inherited from Chemistry::Mol are not repeated here.

Chemistry::Domain->new(parent => $mol, name => value, ...)

Create a new Domain object with the specified attributes. You can use the same attributes as for Chemistry::Mol->new, plus the parent attribute, which is required.

$domain->parent

Returns the parent of the domain.

$domain->add_atom($atom, ...)

Add one or more Atom objects to the domain. Returns the last atom added. It also automatically adds the atoms to the atom table of the parent molecule.

$domain->add_bond($bond, ...)

Add one or more Bond objects to the domain. Returns the last bond added. It also automatically adds the bond to the bond table of the parent molecule.

VERSION

Top

0.06

SEE ALSO

Top

Chemistry::MacroMol, Chemistry::Mol, Chemistry::Atom, Chemistry::Bond

AUTHOR

Top

Ivan Tubert, <itub@cpan.org>

COPYRIGHT AND LICENSE

Top


Chemistry-MacroMol documentation Contained in the Chemistry-MacroMol distribution.
package Chemistry::Domain;

$VERSION = '0.06';
# $Id: Domain.pm,v 1.6 2004/07/03 19:19:44 itubert Exp $


use 5.006;
use strict;
use warnings;
use base qw(Chemistry::Mol);
use Carp;
use Scalar::Util 'weaken';

sub new {
    my $class = shift;
    my %args = @_;
    my $self = bless $class->SUPER::new(), $class;
    $self->$_($args{$_}) for (keys %args);
    croak "Must specify parent to Chemistry::Domain->new" unless $self->parent;
    return $self;
}


sub parent {
    my $self = shift;
    if (@_) {
        $self->{parent} = shift;
        weaken($self->{parent});
        return $self;
    } else {
        return $self->{parent};
    }
}

sub add_atom {
    my $self = shift;
    $self->add_atom_np(@_); # add atom to self (domain)
    $self->parent->add_atom(@_); # add atom to parent (macromol)
}


sub add_bond {
    my $self = shift;
    $self->add_bond_np(@_); # add bond to self (domain)
    $self->parent->add_bond(@_); # add bond to parent (macromol)
}


1;