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