| 1 | package Chemistry::Domain; | ||||||||||
| 2 | |||||||||||
| 3 | 9 | $VERSION = '0.06'; | |||||||||
| 4 | # $Id: Domain.pm,v 1.6 2004/07/03 19:19:44 itubert Exp $ | ||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 9 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 9 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 9 | ▶ | use base qw(Chemistry::Mol); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 9 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 9 | ▶ | use Scalar::Util 'weaken'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | =head1 NAME | ||||||||||
| 15 | |||||||||||
| 16 | Chemistry::Domain - Class for domains in macromolecules | ||||||||||
| 17 | |||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||
| 19 | |||||||||||
| 20 | use Chemistry::Domain; | ||||||||||
| 21 | my $domain = Chemistry::Domain->new(parent => $bigmol); | ||||||||||
| 22 | |||||||||||
| 23 | =head1 DESCRIPTION | ||||||||||
| 24 | |||||||||||
| 25 | A domain is a substructure of a larger molecule. It is typically used to | ||||||||||
| 26 | represent aminoacid residues within a protein, or bases within a nucleic acid, | ||||||||||
| 27 | but you could use it for any arbitrary substructure such as functional groups | ||||||||||
| 28 | and rings. A domain has all the properties of a molecule, plus a "parent". The | ||||||||||
| 29 | parent is the larger molecule that contains the domain. In other words, the | ||||||||||
| 30 | Chemistry::Domain class inherits from Chemistry::Mol. | ||||||||||
| 31 | |||||||||||
| 32 | =head1 METHODS | ||||||||||
| 33 | |||||||||||
| 34 | Note: the methods that are inherited from Chemistry::Mol are not repeated here. | ||||||||||
| 35 | |||||||||||
| 36 | =over 4 | ||||||||||
| 37 | |||||||||||
| 38 | =item Chemistry::Domain->new(parent => $mol, name => value, ...) | ||||||||||
| 39 | |||||||||||
| 40 | Create a new Domain object with the specified attributes. You can use the same | ||||||||||
| 41 | attributes as for Chemistry::Mol->new, plus the parent attribute, which is | ||||||||||
| 42 | required. | ||||||||||
| 43 | |||||||||||
| 44 | =cut | ||||||||||
| 45 | |||||||||||
| 46 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||
| 47 | 0 | my $class = shift; | |||||||||
| 48 | 0 | my %args = @_; | |||||||||
| 49 | 0 | my $self = bless $class->SUPER::new(), $class; | |||||||||
| 50 | 0 | $self->$_($args{$_}) for (keys %args); | |||||||||
| 51 | 0 | ▶ | croak "Must specify parent to Chemistry::Domain->new" unless $self->parent; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | return $self; | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | =item $domain->parent | ||||||||||
| 57 | |||||||||||
| 58 | Returns the parent of the domain. | ||||||||||
| 59 | |||||||||||
| 60 | =cut | ||||||||||
| 61 | |||||||||||
| 62 | 0 | ▶ | sub parent { | ||||||||
|
Subroutine
parent: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 63 | 0 | my $self = shift; | |||||||||
| 64 | 0 | ▶ | if (@_) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | $self->{parent} = shift; | |||||||||
| 66 | 0 | weaken($self->{parent}); | |||||||||
| 67 | 0 | return $self; | |||||||||
| 68 | } else { | ||||||||||
| 69 | 0 | return $self->{parent}; | |||||||||
| 70 | } | ||||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | =item $domain->add_atom($atom, ...) | ||||||||||
| 74 | |||||||||||
| 75 | Add one or more Atom objects to the domain. Returns the last atom added. It | ||||||||||
| 76 | also automatically adds the atoms to the atom table of the parent molecule. | ||||||||||
| 77 | |||||||||||
| 78 | =cut | ||||||||||
| 79 | |||||||||||
| 80 | 0 | ▶ | sub add_atom { | ||||||||
|
Subroutine
add_atom: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 81 | 0 | my $self = shift; | |||||||||
| 82 | 0 | $self->add_atom_np(@_); # add atom to self (domain) | |||||||||
| 83 | 0 | $self->parent->add_atom(@_); # add atom to parent (macromol) | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | |||||||||||
| 87 | =item $domain->add_bond($bond, ...) | ||||||||||
| 88 | |||||||||||
| 89 | Add one or more Bond objects to the domain. Returns the last bond added. It | ||||||||||
| 90 | also automatically adds the bond to the bond table of the parent molecule. | ||||||||||
| 91 | |||||||||||
| 92 | =cut | ||||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | sub add_bond { | ||||||||
|
Subroutine
add_bond: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 95 | 0 | my $self = shift; | |||||||||
| 96 | 0 | $self->add_bond_np(@_); # add bond to self (domain) | |||||||||
| 97 | 0 | $self->parent->add_bond(@_); # add bond to parent (macromol) | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | 9 | 1; | |||||||||
| 102 | |||||||||||
| 103 | =back | ||||||||||
| 104 | |||||||||||
| 105 | =head1 VERSION | ||||||||||
| 106 | |||||||||||
| 107 | 0.06 | ||||||||||
| 108 | |||||||||||
| 109 | =head1 SEE ALSO | ||||||||||
| 110 | |||||||||||
| 111 | L<Chemistry::MacroMol>, L<Chemistry::Mol>, L<Chemistry::Atom>, | ||||||||||
| 112 | L<Chemistry::Bond> | ||||||||||
| 113 | |||||||||||
| 114 | =head1 AUTHOR | ||||||||||
| 115 | |||||||||||
| 116 | Ivan Tubert, E<lt>itub@cpan.orgE<gt> | ||||||||||
| 117 | |||||||||||
| 118 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 119 | |||||||||||
| 120 | Copyright 2004 by Ivan Tubert | ||||||||||
| 121 | |||||||||||
| 122 | This library is free software; you can redistribute it and/or modify | ||||||||||
| 123 | it under the same terms as Perl itself. | ||||||||||
| 124 | |||||||||||
| 125 | =cut | ||||||||||
| 126 | |||||||||||