line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HackaMol::AtomGroup; |
2
|
|
|
|
|
|
|
$HackaMol::AtomGroup::VERSION = '0.051'; |
3
|
|
|
|
|
|
|
#ABSTRACT: HackaMol AtomGroup class |
4
|
14
|
|
|
14
|
|
222561
|
use 5.008; |
|
14
|
|
|
|
|
64
|
|
5
|
14
|
|
|
14
|
|
554
|
use Moose; |
|
14
|
|
|
|
|
298559
|
|
|
14
|
|
|
|
|
86
|
|
6
|
14
|
|
|
14
|
|
97804
|
use namespace::autoclean; |
|
14
|
|
|
|
|
99926
|
|
|
14
|
|
|
|
|
71
|
|
7
|
14
|
|
|
14
|
|
1134
|
use Carp; |
|
14
|
|
|
|
|
32
|
|
|
14
|
|
|
|
|
885
|
|
8
|
14
|
|
|
14
|
|
5358
|
use MooseX::StrictConstructor; |
|
14
|
|
|
|
|
265749
|
|
|
14
|
|
|
|
|
66
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#use MooseX::Storage; |
11
|
|
|
|
|
|
|
#with Storage( 'io' => 'StorableFile' ), |
12
|
|
|
|
|
|
|
with 'HackaMol::Roles::NameRole', |
13
|
|
|
|
|
|
|
'HackaMol::Roles::AtomGroupRole', |
14
|
|
|
|
|
|
|
'HackaMol::Roles::SelectionRole'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub Rg { |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#radius of gyration. |
19
|
8
|
|
|
8
|
1
|
2493
|
my $self = shift; |
20
|
8
|
100
|
|
|
|
350
|
return (0) unless ( $self->count_atoms ); |
21
|
7
|
|
|
|
|
252
|
my @atoms = $self->all_atoms; |
22
|
7
|
|
|
|
|
48
|
my $com = $self->COM; |
23
|
7
|
|
|
|
|
46
|
my $total_mass = $self->total_mass; |
24
|
7
|
|
|
|
|
48
|
my @masses = map { $_->mass } @atoms; |
|
3141
|
|
|
|
|
72799
|
|
25
|
7
|
|
|
|
|
74
|
my @dvec2 = map { $_ * $_ } map { $_->get_coords( $_->t ) - $com } @atoms; |
|
3141
|
|
|
|
|
4627
|
|
|
3141
|
|
|
|
|
74887
|
|
26
|
7
|
|
|
|
|
382
|
my $sum = 0; |
27
|
7
|
|
|
|
|
789
|
$sum += $masses[$_] * $dvec2[$_] foreach 0 .. $#dvec2; |
28
|
7
|
|
|
|
|
384
|
return ( sqrt( $sum / $total_mass ) ); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
1; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__END__ |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=pod |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 NAME |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
HackaMol::AtomGroup - HackaMol AtomGroup class |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 VERSION |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
version 0.051 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
use HackaMol::AtomGroup; |
50
|
|
|
|
|
|
|
use Math::Vector::Real; |
51
|
|
|
|
|
|
|
use Math::Vector::Real::Random; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $radius = 16; |
54
|
|
|
|
|
|
|
my $natoms = int(0.0334*($radius**3)*4*pi/3); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my @atoms = map {Atom->new(Z => 8, charges=> [0], coords => [$_]) } |
57
|
|
|
|
|
|
|
map {$_*$radius} |
58
|
|
|
|
|
|
|
map {Math::Vector::Real->random_in_sphere(3)} 1 .. $natoms; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $group = AtomGroup->new(gname => 'biggroup', atoms=> [@atoms]); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
print $group->count_atoms . "\n"; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
print $group->count_unique_atoms . "\n"; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
print $group->Rg . "\n"; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $numerical_error = $radius*sqrt($radius*3/5) - $group->Rg; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
The HackaMol AtomGroup class provides methods and attributes for groups of atoms. |
73
|
|
|
|
|
|
|
Atom groupings can be defined to mimic conventional forcefields or manipulated to |
74
|
|
|
|
|
|
|
generate novel analytical tools. For example, with a trajectory loaded, a dynamic |
75
|
|
|
|
|
|
|
cluster of atoms can be placed in a group and monitored in time. Or, perhaps, track |
76
|
|
|
|
|
|
|
regional charges of a quantum mechanical molecule with changes in configuration or |
77
|
|
|
|
|
|
|
external field. The AtomGroup class consumes the AtomGroupRole and provides the |
78
|
|
|
|
|
|
|
parent class for the Molecule class. |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 Rg |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
no arguments. returns the scalar radius of gyration for the group of atoms |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 name |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
isa Str that is lazy and rw. useful for labeling, bookkeeping... |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 SEE ALSO |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over 4 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item * |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
L<HackaMol::Molecule> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item * |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
L<HackaMol::AtomGroupRole> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=back |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 EXTENDS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=over 4 |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * L<Moose::Object> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=back |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 CONSUMES |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::AtomGroupRole> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::NameRole> |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::NameRole|HackaMol::Roles::AtomGroupRole|HackaMol::Roles::SelectionRole> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::SelectionRole> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=back |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Demian Riccardi <demianriccardi@gmail.com> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Demian Riccardi. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |