HackaMol/Roles/BondsAnglesDihedralsRole.pm

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