| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Role providing Natural extension reference frame implementation for molecular building |
|
2
|
|
|
|
|
|
|
$HackaMol::Roles::NERFRole::VERSION = '0.052'; |
|
3
|
|
|
|
|
|
|
use 5.008; |
|
4
|
11
|
|
|
11
|
|
6947
|
use Moose::Role; |
|
|
11
|
|
|
|
|
57
|
|
|
5
|
11
|
|
|
11
|
|
59
|
use Math::Vector::Real; |
|
|
11
|
|
|
|
|
28
|
|
|
|
11
|
|
|
|
|
81
|
|
|
6
|
11
|
|
|
11
|
|
52548
|
use Math::Trig; |
|
|
11
|
|
|
|
|
31
|
|
|
|
11
|
|
|
|
|
595
|
|
|
7
|
11
|
|
|
11
|
|
61
|
|
|
|
11
|
|
|
|
|
36
|
|
|
|
11
|
|
|
|
|
4320
|
|
|
8
|
|
|
|
|
|
|
my $orig = V(0,0,0); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# adding the first vector |
|
11
|
|
|
|
|
|
|
my $self = shift; |
|
12
|
|
|
|
|
|
|
if (@_ == 3){ |
|
13
|
0
|
|
|
0
|
1
|
|
return V(@_); |
|
14
|
0
|
0
|
|
|
|
|
} |
|
15
|
0
|
|
|
|
|
|
else { |
|
16
|
|
|
|
|
|
|
return $orig; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
0
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
#allow the use of optvec to give control over the addition |
|
21
|
|
|
|
|
|
|
my ($self, $a, $R, $optvec) = @_; |
|
22
|
|
|
|
|
|
|
$optvec = V(1,0,0) unless defined($optvec); |
|
23
|
|
|
|
|
|
|
return ($a + $R*$optvec->versor); |
|
24
|
0
|
|
|
0
|
1
|
|
} |
|
25
|
0
|
0
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my ($self,$a,$b,$R,$ang) = @_; |
|
27
|
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
|
28
|
|
|
|
|
|
|
my ($ba, $j, $k) = ($b-$a)->rotation_base_3d; |
|
29
|
|
|
|
|
|
|
my $c = $b+$ba*$R; |
|
30
|
0
|
|
|
0
|
1
|
|
$c = $j->rotate_3d($ang, $c-$b) + $b; |
|
31
|
0
|
|
|
|
|
|
return ($c); |
|
32
|
0
|
|
|
|
|
|
} |
|
33
|
0
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my ($self,$a,$b,$c,$R,$ang,$tors) = @_; |
|
35
|
0
|
|
|
|
|
|
$ang = deg2rad(180-$ang); |
|
36
|
|
|
|
|
|
|
$tors = deg2rad($tors); |
|
37
|
|
|
|
|
|
|
my $cang = cos($ang); |
|
38
|
|
|
|
|
|
|
my $sang = sin($ang); |
|
39
|
0
|
|
|
0
|
1
|
|
my $ctor = cos($tors); |
|
40
|
0
|
|
|
|
|
|
my $stor = sin($tors); |
|
41
|
0
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $bc = ($c-$b)->versor; |
|
43
|
0
|
|
|
|
|
|
my $n = (($b-$a) x $bc)->versor; |
|
44
|
0
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $D = $R*($bc*$cang + ($n x $bc)*$sang*$ctor + $n*$sang*$stor) + $c; |
|
46
|
|
|
|
|
|
|
return $D; |
|
47
|
0
|
|
|
|
|
|
} |
|
48
|
0
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
no Moose::Role; |
|
50
|
0
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
1; |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
11
|
|
|
11
|
|
79
|
=pod |
|
|
11
|
|
|
|
|
23
|
|
|
|
11
|
|
|
|
|
57
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
HackaMol::Roles::NERFRole - Role providing Natural extension reference frame implementation for molecular building |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
version 0.052 |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Adds the NERF capabilities to consuming classes |
|
67
|
|
|
|
|
|
|
# Let's say that the $bld object below consumes this Role |
|
68
|
|
|
|
|
|
|
#Let's build a six member ring |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
push @vecs, $bld->init() ; |
|
71
|
|
|
|
|
|
|
push @vecs, $bld->extend_a( $vecs[0] , 1.47 ); |
|
72
|
|
|
|
|
|
|
push @vecs, $bld->extend_ab( @vecs[0,1], 1.47, 109.5 ); |
|
73
|
|
|
|
|
|
|
push @vecs, $bld->extend_abc(@vecs[0,1,2], 1.47, 109.5, 60 ); |
|
74
|
|
|
|
|
|
|
push @vecs, $bld->extend_abc(@vecs[1,2,3], 1.47, 109.5, -60 ); |
|
75
|
|
|
|
|
|
|
push @vecs, $bld->extend_abc(@vecs[2,3,4], 1.47, 109.5, 60 ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
printf ("C %10.6f %10.6f %10.6f\n", @$_ ) foreach @vecs; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The HackaMol::X::NERF library is a quick implementation of the Natural |
|
82
|
|
|
|
|
|
|
Extension Reference Frame method for building cartesian coordinates from |
|
83
|
|
|
|
|
|
|
internal coordinates. It is experimental. In fact, there are |
|
84
|
|
|
|
|
|
|
no substantial tests yet! They will be added soon. |
|
85
|
|
|
|
|
|
|
The API will change and expand. Currently, the class provides four methods four initializing and extending a vector space. Lend me a hand if you are interested! |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Study Z-matrices and the synopsis should be easy to understand. All angles are in degrees. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 METHODS |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 init |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
optional argument is list of three numbers: x, y, and z. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Returns an MVR object constructed from V(0,0,0) or V(x,y,z). |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 extend_a(MVR1, R) |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
two arguments MVR1 and R, along with optional argument MVR2. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Returns an MVR object that is a distance R from MVR1. This new vector will be |
|
102
|
|
|
|
|
|
|
displaced along the x axis unless the optional MVR2 is passed. If MVR2 the |
|
103
|
|
|
|
|
|
|
MVR returned is displace by R times the unit vector parallel to MVR1. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 extend_ab(MVR1, MVR2, R, ANGLE) |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
four arguments MVR1, MVR2, R, and ANGLE. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Returns an MVR object that is a distance R from MVR2 and at ANGLE from MVR1. |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 extend_abc(MVR1, MVR2, MVR3, R, ANGLE, TORSION) |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
six arguments MVR1, MVR2, MVR3, R, ANGLE, and TORSION. |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns an MVR object that is a distance R from MVR3, at ANGLE from MVR2, |
|
116
|
|
|
|
|
|
|
and at TORSION from MVR1 via the vector between MVR2 and MVR3. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 AUTHOR |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Demian Riccardi <demianriccardi@gmail.com> |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Demian Riccardi. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
127
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |