File Coverage

blib/lib/HackaMol/Roles/BondsAnglesDihedralsRole.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             $HackaMol::Roles::BondsAnglesDihedralsRole::VERSION = '0.052';
2             # ABSTRACT: Array traits for containers of HackaMol Bonds, Angles, Dihedrals.
3             use Moose::Role;
4 12     12   5505  
  12         27  
  12         74  
5             has $_ => (
6             traits => ['Array'],
7             is => 'ro',
8             isa => 'ArrayRef[Any]',
9             default => sub { [] },
10             lazy => 1,
11             handles => {
12             "has_$_" => 'count',
13             "push_$_" => 'push',
14             "get_$_" => 'get',
15             "set_$_" => 'set',
16             "all_$_" => 'elements',
17             "count_$_" => 'count',
18             "delete_$_" => 'delete',
19             "clear_$_" => 'clear',
20             },
21             ) foreach qw(bonds angles dihedrals);
22              
23             no Moose::Role;
24 12     12   52543  
  12         52  
  12         51  
25             1;
26              
27              
28             =pod
29              
30             =head1 NAME
31              
32             HackaMol::Roles::BondsAnglesDihedralsRole - Array traits for containers of HackaMol Bonds, Angles, Dihedrals.
33              
34             =head1 VERSION
35              
36             version 0.052
37              
38             =head1 DESCRIPTION
39              
40             The HackaMol BondsAnglesDihedralsRole provides ARRAY trait methods for interacting with
41             arrays of bonds angles and dihedrals. The Molecule class consumes this
42             role. The Atom class does not. Thus, Molecules are responsible for reporting multiple bonded
43             connections for any given atom.
44              
45             =head1 ARRAY METHODS
46              
47             =head2 push_bonds, get_bonds, set_bonds, all_bonds, count_bonds, delete_bonds, clear_bonds
48              
49             ARRAY traits for the bonds attribute, respectively: push, get, set, elements, count, delete, clear
50              
51             =head2 push_bonds
52              
53             push bond on to bonds array
54              
55             $group->push_bonds($bond1, $bond2, @otherbonds);
56              
57             =head2 all_bonds
58              
59             returns array of all elements in bonds array
60              
61             print $_->bond_order, "\n" foreach $group->all_bonds;
62              
63             =head2 get_bonds
64              
65             return element by index from bonds array
66              
67             print $group->get_bonds(1); # returns $bond2 from that pushed above
68              
69             =head2 set_bonds
70              
71             set bonds array by index
72              
73             $group->set_bonds(1, $bond1);
74              
75             =head2 count_bonds
76              
77             return number of bonds in the array
78              
79             print $group->count_bonds;
80              
81             =head2 delete_bonds
82              
83             deletes bond from bonds array and returns it.
84              
85             =head2 clear_bonds
86              
87             clears bonds array
88              
89             =head2 push_angles, get_angles, set_angles, all_angles, count_angles, delete_angles, clear_angles
90              
91             ARRAY traits for the bonds attribute, respectively: push, get, set, elements, count, delete, clear
92              
93             Analogous to those for bonds.
94              
95             =head2 push_dihedrals, get_dihedrals, set_dihedrals, all_dihedrals, count_dihedrals, delete_dihedrals, clear_dihedrals
96              
97             ARRAY traits for the bonds attribute, respectively: push, get, set, elements, count, delete, clear
98              
99             Analogous to those for bonds.
100              
101             =head1 SYNOPSIS
102             use HackaMol::Atom;
103             use HackaMol::Angle;
104             use HackaMol::Dihedral;
105              
106             my $atom1 = HackaMol::Atom->new(
107             name => 'O1',
108             coords => [ V( 2.05274, 0.01959, -0.07701 ) ],
109             Z => 8,
110             );
111            
112             my $atom2 = HackaMol::Atom->new(
113             name => 'H1',
114             coords => [ V( 1.08388, 0.02164, -0.12303 ) ],
115             Z => 1,
116             );
117            
118             my $atom3 = HackaMol::Atom->new(
119             name => 'H2',
120             coords => [ V( 2.33092, 0.06098, -1.00332 ) ],
121             Z => 1,
122             );
123            
124             my $atom4 = HackaMol::Atom->new(
125             name => 'Cl',
126             coords => [ V(-0.91386, 0.02587, -0.21792 ) ],
127             Z => 17,
128             );
129            
130             my @atoms = ($atom1,$atom2,$atom3,$atom4);
131            
132             my $bond1 = HackaMol::Angle->new(name=> 'test', atoms[@atoms[0,1]]);
133             my $bond2 = HackaMol::Angle->new(name=> 'test', atoms[@atoms[0,2]]);
134            
135             my @bonds = $atom1->all_bonds;
136              
137             my $angle1 = HackaMol::Angle->new(name=> 'test', atoms[@atoms[1,0,2]]);
138             my $angle2 = HackaMol::Angle->new(name=> 'test', atoms[@atoms[0,1,3]]);
139            
140             my @angles = $atom1->all_angles;
141            
142             my $dihe1 = HackaMol::Dihedral->new(name=> 'test', atoms[@atoms]);
143             my $dihe2 = HackaMol::Dihedral->new(name=> 'test', atoms[reverse @atoms]);
144            
145             my @dihes = $atom1->all_dihedrals;
146              
147             =head1 SEE ALSO
148              
149             =over 4
150              
151             =item *
152              
153             L<HackaMol::Molecule>
154              
155             =back
156              
157             =head1 AUTHOR
158              
159             Demian Riccardi <demianriccardi@gmail.com>
160              
161             =head1 COPYRIGHT AND LICENSE
162              
163             This software is copyright (c) 2017 by Demian Riccardi.
164              
165             This is free software; you can redistribute it and/or modify it under
166             the same terms as the Perl 5 programming language system itself.
167              
168             =cut