-
Notifications
You must be signed in to change notification settings - Fork 0
/
Residue.pm
executable file
·74 lines (57 loc) · 1.87 KB
/
Residue.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## Residue.pm
#
############################################################################################
###
### Written by Sen Yao, 07/20/2016
### Copyright Sen Yao, Robert Flight, and Hunter Moseley, 07/20/2016. All rights reserved.
###
############################################################################################
package Residue;
use strict;
use Atom;
our @defaultDataMembers = ( "N" => 0,
"CA" => 0,
"CB" => 0,
"CG" => 0
# "atom" => []
);
sub new
{
my $class = shift @_;
my $self = { @defaultDataMembers, "atoms" => [] };
bless $self, ref $class || $class;
$self->add(@_); # add an arbitrary number of atoms.
return $self;
}
sub add
{
my $self = shift @_;
foreach my $atom (@_)
{
next if (@{$self->{atoms}} && $atom->resID() ne $self->residueID());
push @{$self->{atoms}}, $atom;
$self->{N} = $atom if ($atom->{atomName} eq "N");
$self->{CA} = $atom if ($atom->{atomName} eq "CA");
$self->{CB} = $atom if ($atom->{atomName} eq "CB");
$self->{CG} = $atom if ($atom->{atomName} eq "CG" || $atom->{atomName} eq "SG" || $atom->{atomName} eq "OG" || $atom->{atomName} eq "OG1" || $atom->{atomName} eq "CG1");
}
}
sub residueID
{
my $self = shift @_;
return $self->{atoms}[0]->resID();
}
sub cmp
{
my $self = shift @_;
my $other = shift @_;
my $selfAtom = $self->{atoms}[0];
my $otherAtom = $other->{atoms}[0];
return ($selfAtom->{chainID} eq $otherAtom->{chainID}) ? ($selfAtom->{residueNumber} <=> $otherAtom->{residueNumber}) : ($selfAtom->{chainID} cmp $otherAtom->{chainID});
}
sub chiOneAngle
{
my $self = shift @_;
return 0 if (! ($self->{N} && $self->{CA} && $self->{CB} && $self->{CG}));
return $self->{N}->torsionAngle($self->{CA}, $self->{CB}, $self->{CG});
}