| 1 | package Bio::PDB::Structure::Atom; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Math::Trig; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | #define an atom object containing all the fields of a pdb file | ||||||||||||||||||||||||||||
| 6 | sub new | ||||||||||||||||||||||||||||
| 7 | 179 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 179 | my $self = {}; | |||||||||||||||||||||||||||
| 9 | 179 | $self->{TYPE} = undef; | |||||||||||||||||||||||||||
| 10 | 179 | $self->{NUMBER} = undef; | |||||||||||||||||||||||||||
| 11 | 179 | $self->{NAME} = undef; | |||||||||||||||||||||||||||
| 12 | 179 | $self->{RESIDUE_NAME} = undef; | |||||||||||||||||||||||||||
| 13 | 179 | $self->{CHAIN} = undef; | |||||||||||||||||||||||||||
| 14 | 179 | $self->{RESIDUE_NUMBER} = undef; | |||||||||||||||||||||||||||
| 15 | 179 | $self->{X} = undef; | |||||||||||||||||||||||||||
| 16 | 179 | $self->{Y} = undef; | |||||||||||||||||||||||||||
| 17 | 179 | $self->{Z} = undef; | |||||||||||||||||||||||||||
| 18 | 179 | $self->{OCCUPANCY} = undef; | |||||||||||||||||||||||||||
| 19 | 179 | $self->{BETA} = undef; | |||||||||||||||||||||||||||
| 20 | 179 | $self->{ALT} = undef; | |||||||||||||||||||||||||||
| 21 | 179 | $self->{INSERTION_CODE} = undef; | |||||||||||||||||||||||||||
| 22 | 179 | bless($self); | |||||||||||||||||||||||||||
| 23 | 179 | return $self; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | #accesor methods for atom objects | ||||||||||||||||||||||||||||
| 27 | sub type | ||||||||||||||||||||||||||||
| 28 | 239 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
type: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 29 | 239 | my $self= shift; | |||||||||||||||||||||||||||
| 30 | 239 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | { | ||||||||||||||||||||||||||||
| 32 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 33 | 179 | $self->{TYPE} = $val; | |||||||||||||||||||||||||||
| 34 | 179 | return; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 60 | return $self->{TYPE}; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | sub number | ||||||||||||||||||||||||||||
| 40 | 239 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
number: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 41 | 239 | my $self= shift; | |||||||||||||||||||||||||||
| 42 | 239 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||
| 44 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 45 | 179 | $self->{NUMBER} = $val; | |||||||||||||||||||||||||||
| 46 | 179 | return; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 60 | return $self->{NUMBER}; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | sub name | ||||||||||||||||||||||||||||
| 52 | 270 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 53 | 270 | my $self= shift; | |||||||||||||||||||||||||||
| 54 | 270 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||
| 56 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 57 | 179 | $self->{NAME} = $val; | |||||||||||||||||||||||||||
| 58 | 179 | return; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 91 | return $self->{NAME}; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub chain | ||||||||||||||||||||||||||||
| 64 | 239 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
chain: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 65 | 239 | my $self= shift; | |||||||||||||||||||||||||||
| 66 | 239 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | { | ||||||||||||||||||||||||||||
| 68 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 69 | 179 | $self->{CHAIN} = $val; | |||||||||||||||||||||||||||
| 70 | 179 | return; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | 60 | return $self->{CHAIN}; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub residue_number | ||||||||||||||||||||||||||||
| 76 | 239 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
residue_number: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 77 | 239 | my $self= shift; | |||||||||||||||||||||||||||
| 78 | 239 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||
| 80 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 81 | 179 | $self->{RESIDUE_NUMBER} = $val; | |||||||||||||||||||||||||||
| 82 | 179 | return; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | 60 | return $self->{RESIDUE_NUMBER}; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | sub residue_name | ||||||||||||||||||||||||||||
| 88 | 241 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
residue_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 89 | 241 | my $self= shift; | |||||||||||||||||||||||||||
| 90 | 241 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | { | ||||||||||||||||||||||||||||
| 92 | 179 | my $val = shift; | |||||||||||||||||||||||||||
| 93 | 179 | $self->{RESIDUE_NAME} = $val; | |||||||||||||||||||||||||||
| 94 | 179 | return; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | 62 | return $self->{RESIDUE_NAME}; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub x | ||||||||||||||||||||||||||||
| 100 | 785 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
x: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 101 | 785 | my $self= shift; | |||||||||||||||||||||||||||
| 102 | 785 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | { | ||||||||||||||||||||||||||||
| 104 | 295 | my $val = shift; | |||||||||||||||||||||||||||
| 105 | 295 | $self->{X} = $val; | |||||||||||||||||||||||||||
| 106 | 295 | return; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | 490 | return $self->{X}; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | sub y | ||||||||||||||||||||||||||||
| 112 | 785 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
y: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 113 | 785 | my $self= shift; | |||||||||||||||||||||||||||
| 114 | 785 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||
| 116 | 295 | my $val = shift; | |||||||||||||||||||||||||||
| 117 | 295 | $self->{Y} = $val; | |||||||||||||||||||||||||||
| 118 | 295 | return; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 490 | return $self->{Y}; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | sub z | ||||||||||||||||||||||||||||
| 124 | 785 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
z: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 125 | 785 | my $self= shift; | |||||||||||||||||||||||||||
| 126 | 785 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | { | ||||||||||||||||||||||||||||
| 128 | 295 | my $val = shift; | |||||||||||||||||||||||||||
| 129 | 295 | $self->{Z} = $val; | |||||||||||||||||||||||||||
| 130 | 295 | return; | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 490 | return $self->{Z}; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | sub occupancy | ||||||||||||||||||||||||||||
| 136 | 235 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
occupancy: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 137 | 235 | my $self= shift; | |||||||||||||||||||||||||||
| 138 | 235 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||
| 140 | 175 | my $val = shift; | |||||||||||||||||||||||||||
| 141 | 175 | $self->{OCCUPANCY} = $val; | |||||||||||||||||||||||||||
| 142 | 175 | return; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | 60 | return $self->{OCCUPANCY}; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | sub beta | ||||||||||||||||||||||||||||
| 148 | 235 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
beta: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 149 | 235 | my $self= shift; | |||||||||||||||||||||||||||
| 150 | 235 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | { | ||||||||||||||||||||||||||||
| 152 | 175 | my $val = shift; | |||||||||||||||||||||||||||
| 153 | 175 | $self->{BETA} = $val; | |||||||||||||||||||||||||||
| 154 | 175 | return; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | 60 | return $self->{BETA}; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | sub alt | ||||||||||||||||||||||||||||
| 160 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alt: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 161 | 0 | my $self= shift; | |||||||||||||||||||||||||||
| 162 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | { | ||||||||||||||||||||||||||||
| 164 | 0 | my $val = shift; | |||||||||||||||||||||||||||
| 165 | 0 | $self->{ALT} = $val; | |||||||||||||||||||||||||||
| 166 | 0 | return; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | 0 | return $self->{ALT}; | |||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | sub insertion_code | ||||||||||||||||||||||||||||
| 172 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
insertion_code: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 173 | 0 | my $self= shift; | |||||||||||||||||||||||||||
| 174 | 0 | ▶ | if (@_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||
| 176 | 0 | my $val = shift; | |||||||||||||||||||||||||||
| 177 | 0 | $self->{INSERTION_CODE} = $val; | |||||||||||||||||||||||||||
| 178 | 0 | return; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 0 | return $self->{INSERTION_CODE}; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | #compute usefull stuff for atom objects | ||||||||||||||||||||||||||||
| 184 | sub distance | ||||||||||||||||||||||||||||
| 185 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
distance: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 186 | 3 | shift; | |||||||||||||||||||||||||||
| 187 | 3 | my $n = @_; | |||||||||||||||||||||||||||
| 188 | 3 | ▶ | die "Error in distance calculation: need two atoms as argument" if ($n != 2); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | 3 | my $obj1 = shift; | |||||||||||||||||||||||||||
| 190 | 3 | my $obj2 = shift; | |||||||||||||||||||||||||||
| 191 | 3 | my $dist = ($obj1 -> x - $obj2 ->x )**2; | |||||||||||||||||||||||||||
| 192 | 3 | $dist += ($obj1 ->y - $obj2 ->y )**2; | |||||||||||||||||||||||||||
| 193 | 3 | $dist += ($obj1 -> z - $obj2 ->z )**2; | |||||||||||||||||||||||||||
| 194 | 3 | $dist = sqrt($dist); | |||||||||||||||||||||||||||
| 195 | 3 | return $dist; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | #given three atoms a1-a2-a3 , compute the angle betwen bonds a1-a2 and a2-a3 | ||||||||||||||||||||||||||||
| 199 | sub angle | ||||||||||||||||||||||||||||
| 200 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
angle: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 201 | 1 | shift; | |||||||||||||||||||||||||||
| 202 | 1 | my $n = @_; | |||||||||||||||||||||||||||
| 203 | 1 | ▶ | die "Error in angle calculation: need three atoms as argument" if ($n != 3); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 1 | my $obj1 = shift; | |||||||||||||||||||||||||||
| 205 | 1 | my $obj2 = shift; | |||||||||||||||||||||||||||
| 206 | 1 | my $obj3 = shift; | |||||||||||||||||||||||||||
| 207 | 1 | my $d1 = $obj1->distance($obj1,$obj2); #so the class is not hard coded | |||||||||||||||||||||||||||
| 208 | 1 | my $d2 = $obj1->distance($obj2,$obj3); | |||||||||||||||||||||||||||
| 209 | 1 | my $dx1 = ($obj1 -> x - $obj2 ->x)/$d1; | |||||||||||||||||||||||||||
| 210 | 1 | my $dy1 = ($obj1 -> y - $obj2 ->y)/$d1; | |||||||||||||||||||||||||||
| 211 | 1 | my $dz1 = ($obj1 -> z - $obj2 ->z)/$d1; | |||||||||||||||||||||||||||
| 212 | 1 | my $dx2 = ($obj3 -> x - $obj2 ->x)/$d2; | |||||||||||||||||||||||||||
| 213 | 1 | my $dy2 = ($obj3 -> y - $obj2 ->y)/$d2; | |||||||||||||||||||||||||||
| 214 | 1 | my $dz2 = ($obj3 -> z - $obj2 ->z)/$d2; | |||||||||||||||||||||||||||
| 215 | 1 | my $dot = $dx1*$dx2 + $dy1*$dy2 + $dz1*$dz2; | |||||||||||||||||||||||||||
| 216 | 1 | return 180.0/pi * acos( $dot ); | |||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | #given four atoms a1-a2-a3-a4, compute the dihedral that lies between a2 and a3 | ||||||||||||||||||||||||||||
| 220 | sub dihedral | ||||||||||||||||||||||||||||
| 221 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
dihedral: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 222 | 1 | shift; | |||||||||||||||||||||||||||
| 223 | 1 | my $n = @_; | |||||||||||||||||||||||||||
| 224 | 1 | ▶ | die "Error in dihedral calculation: need four atoms as argument" if ($n != 4); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | 1 | my @object; | |||||||||||||||||||||||||||
| 226 | 1 | ▶ | for (my $i=0; $i <4; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | { | ||||||||||||||||||||||||||||
| 228 | 4 | $object[$i] = shift; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 1 | my @v; | |||||||||||||||||||||||||||
| 231 | 1 | ▶ | for (my $j=0; $j < 4; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||
| 233 | 4 | $v[0][$j] = $object[$j] ->x; | |||||||||||||||||||||||||||
| 234 | 4 | $v[1][$j] = $object[$j] ->y; | |||||||||||||||||||||||||||
| 235 | 4 | $v[2][$j] = $object[$j] ->z; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 1 | my @b; | |||||||||||||||||||||||||||
| 238 | 1 | ▶ | for(my $i=0;$i<3;$i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 239 | { | ||||||||||||||||||||||||||||
| 240 | 3 | $b[$i][0] = $v[$i][0] - $v[$i][1]; | |||||||||||||||||||||||||||
| 241 | 3 | $b[$i][1] = $v[$i][2] - $v[$i][1]; | |||||||||||||||||||||||||||
| 242 | 3 | $b[$i][2] = $v[$i][3] - $v[$i][2]; | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 1 | my @t1; | |||||||||||||||||||||||||||
| 245 | my @t2; | ||||||||||||||||||||||||||||
| 246 | #cross product b[][1] x b[][0] | ||||||||||||||||||||||||||||
| 247 | 1 | $t1[0] =$b[1][1]*$b[2][0] - $b[2][1]*$b[1][0]; | |||||||||||||||||||||||||||
| 248 | 1 | $t1[1] =$b[2][1]*$b[0][0] - $b[0][1]*$b[2][0]; | |||||||||||||||||||||||||||
| 249 | 1 | $t1[2] =$b[0][1]*$b[1][0] - $b[1][1]*$b[0][0]; | |||||||||||||||||||||||||||
| 250 | #cross product b[][1] x b[][2] | ||||||||||||||||||||||||||||
| 251 | 1 | $t2[0] =$b[1][1]*$b[2][2] - $b[2][1]*$b[1][2]; | |||||||||||||||||||||||||||
| 252 | 1 | $t2[1] =$b[2][1]*$b[0][2] - $b[0][1]*$b[2][2]; | |||||||||||||||||||||||||||
| 253 | 1 | $t2[2] =$b[0][1]*$b[1][2] - $b[1][1]*$b[0][2]; | |||||||||||||||||||||||||||
| 254 | 1 | my $norm1 = sqrt($t1[0]**2 + $t1[1]**2 + $t1[2]**2); | |||||||||||||||||||||||||||
| 255 | 1 | my $norm2 = sqrt($t2[0]**2 + $t2[1]**2 + $t2[2]**2); | |||||||||||||||||||||||||||
| 256 | 1 | my $dot1=0; | |||||||||||||||||||||||||||
| 257 | 1 | my $dot2=0; | |||||||||||||||||||||||||||
| 258 | 1 | ▶ | for (my $i=0; $i < 3; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | { | ||||||||||||||||||||||||||||
| 260 | 3 | $t1[$i] /= $norm1; | |||||||||||||||||||||||||||
| 261 | 3 | $t2[$i] /= $norm2; | |||||||||||||||||||||||||||
| 262 | 3 | $dot1 += $t1[$i] * $t2[$i]; | |||||||||||||||||||||||||||
| 263 | 3 | $dot2 += $b[$i][2] * $t1[$i]; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | 1 | my $dihedral = 180.0/pi * acos($dot1); | |||||||||||||||||||||||||||
| 266 | 1 | ▶ | $dihedral *= -1.0 if ( $dot2 < 0.0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 1 | return $dihedral; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | package Bio::PDB::Structure::Molecule; | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 1 | ▶ | use 5.012003; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 275 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 276 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 1 | our $VERSION = '0.01'; | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | sub new | ||||||||||||||||||||||||||||
| 281 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 282 | 6 | my $self = []; | |||||||||||||||||||||||||||
| 283 | 6 | bless ($self); | |||||||||||||||||||||||||||
| 284 | 6 | return $self; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | #count the number of atoms in a molecule object | ||||||||||||||||||||||||||||
| 287 | sub size | ||||||||||||||||||||||||||||
| 288 | 16 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
size: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 289 | 16 | my $self= shift; | |||||||||||||||||||||||||||
| 290 | 16 | my $n = @{ $self }; | |||||||||||||||||||||||||||
| 291 | 16 | return $n; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | #return the ith atom | ||||||||||||||||||||||||||||
| 295 | sub atom | ||||||||||||||||||||||||||||
| 296 | 421 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
atom: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 297 | 421 | my $self = shift; | |||||||||||||||||||||||||||
| 298 | 421 | my $n = @_; | |||||||||||||||||||||||||||
| 299 | 421 | ▶ | die "Error in atom: need one atom position\n" unless ($n == 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 300 | 421 | my $pos = shift; | |||||||||||||||||||||||||||
| 301 | 421 | return $self ->[$pos]; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | #add an atom or a molecule to a molecule | ||||||||||||||||||||||||||||
| 305 | sub push | ||||||||||||||||||||||||||||
| 306 | 176 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
push: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 307 | 176 | my $self = shift; | |||||||||||||||||||||||||||
| 308 | 176 | my $n = @_; | |||||||||||||||||||||||||||
| 309 | 176 | ▶ | die "Eror in push: need one atom or molecule\n" unless ( $n == 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | 176 | my $object = shift; | |||||||||||||||||||||||||||
| 311 | 176 | ▶ | push (@{$self},$object) if (ref($object) eq "Bio::PDB::Structure::Atom"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 176 | ▶ | if ( ref($object) eq "Bio::PDB::Structure::Molecule") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||
| 314 | 1 | my $nm = $object -> size; | |||||||||||||||||||||||||||
| 315 | 1 | ▶ | for (my $i=0; $i < $nm; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | { | ||||||||||||||||||||||||||||
| 317 | 30 | push (@{$self},$object->[$i]); | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||
| 320 | 176 | return; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | #return number of models in a pdb file | ||||||||||||||||||||||||||||
| 324 | sub models | ||||||||||||||||||||||||||||
| 325 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
models: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 326 | 1 | shift; | |||||||||||||||||||||||||||
| 327 | 1 | my $fname = shift; | |||||||||||||||||||||||||||
| 328 | 1 | ▶ | open(CMDFPDB,"<$fname") or die "Error in models: File $fname not found\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 329 | 1 | my $count = 0; | |||||||||||||||||||||||||||
| 330 | 1 | ▶ | while (<CMDFPDB>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 331 | { | ||||||||||||||||||||||||||||
| 332 | 60 | ▶ | $count++ if (/^END/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | 1 | close CMDFPDB; | |||||||||||||||||||||||||||
| 335 | 1 | return $count; | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | #read a pdb file into a molecule, can specify a specific model to read | ||||||||||||||||||||||||||||
| 339 | sub read | ||||||||||||||||||||||||||||
| 340 | 6 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
read: called CC=16 SCAR=30.0
| |||||||||||||||||||||||||||||
| 341 | 6 | my $type; | |||||||||||||||||||||||||||
| 342 | my $anum; | ||||||||||||||||||||||||||||
| 343 | 6 | my $aname; | |||||||||||||||||||||||||||
| 344 | 6 | my $altloc; | |||||||||||||||||||||||||||
| 345 | 6 | my $rname; | |||||||||||||||||||||||||||
| 346 | 6 | my $chain; | |||||||||||||||||||||||||||
| 347 | 6 | my $rnum; | |||||||||||||||||||||||||||
| 348 | 6 | my $icode; | |||||||||||||||||||||||||||
| 349 | 6 | my $xx; | |||||||||||||||||||||||||||
| 350 | 6 | my $yy; | |||||||||||||||||||||||||||
| 351 | 6 | my $zz; | |||||||||||||||||||||||||||
| 352 | 6 | my $coor; | |||||||||||||||||||||||||||
| 353 | 6 | my $beta; | |||||||||||||||||||||||||||
| 354 | 6 | my @data; | |||||||||||||||||||||||||||
| 355 | 6 | my $inum = 0; | |||||||||||||||||||||||||||
| 356 | 6 | my $record = 0; | |||||||||||||||||||||||||||
| 357 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 358 | 6 | ▶ | die "Error in read: pdb file must be specified\n" unless (@_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 6 | my $fname = shift; | |||||||||||||||||||||||||||
| 360 | 6 | ▶ | $record = shift if ( @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | 6 | ▶ | open(FPDB,"<$fname") or die "File $fname not found\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 362 | 6 | ▶ | if ( $record > 0 ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | { | ||||||||||||||||||||||||||||
| 364 | 0 | my $rcount=1; | |||||||||||||||||||||||||||
| 365 | 0 | ▶ | while (<FPDB>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 366 | { | ||||||||||||||||||||||||||||
| 367 | 0 | ▶ | if (/^END/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | { | ||||||||||||||||||||||||||||
| 369 | 0 | ▶ | last if ( $rcount == $record); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 370 | 0 | $rcount++; | |||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | 6 | ▶ | while(<FPDB>) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||
| 376 | 180 | ▶ | last if (/^END/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 377 | 174 | ▶ | next unless (/^ATOM |^HETATM / ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 378 | 174 | my $atom = Bio::PDB::Structure::Atom -> new; | |||||||||||||||||||||||||||
| 379 | 174 | ($type,$anum,$aname,$altloc,$rname,$chain,$rnum,$icode,$xx,$yy,$zz,$coor,$beta ) =(/^(.{6})(.{5})(.{5})(.{1})(.{3})(.{2})(.{4})(.{1}).{3}(.{8})(.{8})(.{8})(.{0,6})(.{0,6})/); | |||||||||||||||||||||||||||
| 380 | #take out unecessary spaces | ||||||||||||||||||||||||||||
| 381 | 174 | $type =~ s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 382 | 174 | $anum =~ s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 383 | 174 | $aname =~s/^\s*(\S*\s*\S)\s*$/$1/; | |||||||||||||||||||||||||||
| 384 | 174 | $chain =~s/^\s*(\S*)\s*$/$1/; | |||||||||||||||||||||||||||
| 385 | 174 | ▶ | $chain = " " if ($chain eq ""); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 386 | 174 | $rname =~s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 387 | 174 | $rnum =~s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 388 | 174 | $coor =~s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 389 | 174 | ▶ | $coor = 1.00 unless ( $coor =~ /\d/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | 174 | $beta =~s/^\s*(\S+)\s*$/$1/; | |||||||||||||||||||||||||||
| 391 | 174 | ▶ | $beta = 0.00 unless ( $beta =~ /\d/); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | 174 | $atom -> type($type); | |||||||||||||||||||||||||||
| 394 | 174 | $atom -> number($anum); | |||||||||||||||||||||||||||
| 395 | 174 | $atom -> name($aname); | |||||||||||||||||||||||||||
| 396 | 174 | $atom -> residue_name($rname); | |||||||||||||||||||||||||||
| 397 | 174 | $atom -> chain($chain); | |||||||||||||||||||||||||||
| 398 | 174 | $atom -> residue_number($rnum); | |||||||||||||||||||||||||||
| 399 | 174 | $atom ->x($xx); | |||||||||||||||||||||||||||
| 400 | 174 | $atom ->y($yy); | |||||||||||||||||||||||||||
| 401 | 174 | $atom ->z($zz); | |||||||||||||||||||||||||||
| 402 | 174 | $atom -> occupancy($coor); | |||||||||||||||||||||||||||
| 403 | 174 | $atom -> beta($beta); | |||||||||||||||||||||||||||
| 404 | #since alterate location and insertion code are seldomly used only include them for atoms that have them | ||||||||||||||||||||||||||||
| 405 | 174 | ▶ | $atom -> alt($altloc) if ( $altloc ne " "); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 174 | ▶ | $atom -> insertion_code($icode) if ( $icode ne " "); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | 174 | $self-> push($atom); | |||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||
| 409 | 6 | close FPDB; | |||||||||||||||||||||||||||
| 410 | 6 | return; | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | #print out a molecule to stdout or to a file | ||||||||||||||||||||||||||||
| 414 | sub print | ||||||||||||||||||||||||||||
| 415 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
print: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | #names of all the pdb atoms with correct justification for pdb print out | ||||||||||||||||||||||||||||
| 418 | #these are set by convention and are important for some programs to work correctly | ||||||||||||||||||||||||||||
| 419 | 2 | my %atom_name = ( | |||||||||||||||||||||||||||
| 420 | 'C' => ' C ', | ||||||||||||||||||||||||||||
| 421 | 'C1' => ' C1 ', | ||||||||||||||||||||||||||||
| 422 | 'C1A' => ' C1A', | ||||||||||||||||||||||||||||
| 423 | 'C1B' => ' C1B', | ||||||||||||||||||||||||||||
| 424 | 'C1C' => ' C1C', | ||||||||||||||||||||||||||||
| 425 | 'C1D' => ' C1D', | ||||||||||||||||||||||||||||
| 426 | 'C2' => ' C2 ', | ||||||||||||||||||||||||||||
| 427 | 'C2A' => ' C2A', | ||||||||||||||||||||||||||||
| 428 | 'C2B' => ' C2B', | ||||||||||||||||||||||||||||
| 429 | 'C2C' => ' C2C', | ||||||||||||||||||||||||||||
| 430 | 'C2D' => ' C2D', | ||||||||||||||||||||||||||||
| 431 | 'C3' => ' C3 ', | ||||||||||||||||||||||||||||
| 432 | 'C3A' => ' C3A', | ||||||||||||||||||||||||||||
| 433 | 'C3B' => ' C3B', | ||||||||||||||||||||||||||||
| 434 | 'C3C' => ' C3C', | ||||||||||||||||||||||||||||
| 435 | 'C3D' => ' C3D', | ||||||||||||||||||||||||||||
| 436 | 'C4' => ' C4 ', | ||||||||||||||||||||||||||||
| 437 | 'C4A' => ' C4A', | ||||||||||||||||||||||||||||
| 438 | 'C4A' => ' C4A', | ||||||||||||||||||||||||||||
| 439 | 'C4B' => ' C4B', | ||||||||||||||||||||||||||||
| 440 | 'C4C' => ' C4C', | ||||||||||||||||||||||||||||
| 441 | 'C4D' => ' C4D', | ||||||||||||||||||||||||||||
| 442 | 'C5' => ' C5 ', | ||||||||||||||||||||||||||||
| 443 | 'C6' => ' C6 ', | ||||||||||||||||||||||||||||
| 444 | 'CA' => ' CA ', | ||||||||||||||||||||||||||||
| 445 | 'CAA' => ' CAA', | ||||||||||||||||||||||||||||
| 446 | 'CAB' => ' CAB', | ||||||||||||||||||||||||||||
| 447 | 'CAC' => ' CAC', | ||||||||||||||||||||||||||||
| 448 | 'CAD' => ' CAD', | ||||||||||||||||||||||||||||
| 449 | 'CB' => ' CB ', | ||||||||||||||||||||||||||||
| 450 | 'CBA' => ' CBA', | ||||||||||||||||||||||||||||
| 451 | 'CBB' => ' CBB', | ||||||||||||||||||||||||||||
| 452 | 'CBC' => ' CBC', | ||||||||||||||||||||||||||||
| 453 | 'CBD' => ' CBD', | ||||||||||||||||||||||||||||
| 454 | 'CD' => ' CD ', | ||||||||||||||||||||||||||||
| 455 | 'CD1' => ' CD1', | ||||||||||||||||||||||||||||
| 456 | 'CD2' => ' CD2', | ||||||||||||||||||||||||||||
| 457 | 'CE' => ' CE ', | ||||||||||||||||||||||||||||
| 458 | 'CE1' => ' CE1', | ||||||||||||||||||||||||||||
| 459 | 'CE2' => ' CE2', | ||||||||||||||||||||||||||||
| 460 | 'CE3' => ' CE3', | ||||||||||||||||||||||||||||
| 461 | 'CG' => ' CG ', | ||||||||||||||||||||||||||||
| 462 | 'CG1' => ' CG1', | ||||||||||||||||||||||||||||
| 463 | 'CG2' => ' CG2', | ||||||||||||||||||||||||||||
| 464 | 'CGA' => ' CGA', | ||||||||||||||||||||||||||||
| 465 | 'CGD' => ' CGD', | ||||||||||||||||||||||||||||
| 466 | 'CH2' => ' CH2', | ||||||||||||||||||||||||||||
| 467 | 'CHA' => ' CHA', | ||||||||||||||||||||||||||||
| 468 | 'CHB' => ' CHB', | ||||||||||||||||||||||||||||
| 469 | 'CHC' => ' CHC', | ||||||||||||||||||||||||||||
| 470 | 'CHD' => ' CHD', | ||||||||||||||||||||||||||||
| 471 | 'CMA' => ' CMA', | ||||||||||||||||||||||||||||
| 472 | 'CMB' => ' CMB', | ||||||||||||||||||||||||||||
| 473 | 'CMC' => ' CMC', | ||||||||||||||||||||||||||||
| 474 | 'CMD' => ' CMD', | ||||||||||||||||||||||||||||
| 475 | 'CZ' => ' CZ ', | ||||||||||||||||||||||||||||
| 476 | 'CZ2' => ' CZ2', | ||||||||||||||||||||||||||||
| 477 | 'CZ3' => ' CZ3', | ||||||||||||||||||||||||||||
| 478 | 'FE' => 'FE ', | ||||||||||||||||||||||||||||
| 479 | 'H' => ' H ', | ||||||||||||||||||||||||||||
| 480 | 'HA' => ' HA ', | ||||||||||||||||||||||||||||
| 481 | 'HB' => ' HB ', | ||||||||||||||||||||||||||||
| 482 | 'HG' => ' HG ', | ||||||||||||||||||||||||||||
| 483 | 'HE' => ' HE ', | ||||||||||||||||||||||||||||
| 484 | 'HZ' => ' HZ ', | ||||||||||||||||||||||||||||
| 485 | 'HH' => ' HH ', | ||||||||||||||||||||||||||||
| 486 | '1H' => '1H ', | ||||||||||||||||||||||||||||
| 487 | '2H' => '2H ', | ||||||||||||||||||||||||||||
| 488 | '3H' => '3H ', | ||||||||||||||||||||||||||||
| 489 | '1HA' => '1HA ', | ||||||||||||||||||||||||||||
| 490 | '1HB' => '1HB ', | ||||||||||||||||||||||||||||
| 491 | '1HD' => '1HD ', | ||||||||||||||||||||||||||||
| 492 | '1HE' => '1HE ', | ||||||||||||||||||||||||||||
| 493 | '1HG' => '1HG ', | ||||||||||||||||||||||||||||
| 494 | '1HZ' => '1HZ ', | ||||||||||||||||||||||||||||
| 495 | '2HA' => '2HA ', | ||||||||||||||||||||||||||||
| 496 | '2HB' => '2HB ', | ||||||||||||||||||||||||||||
| 497 | '2HD' => '2HD ', | ||||||||||||||||||||||||||||
| 498 | '2HE' => '2HE ', | ||||||||||||||||||||||||||||
| 499 | '2HG' => '2HG ', | ||||||||||||||||||||||||||||
| 500 | '1HZ' => '1HZ ', | ||||||||||||||||||||||||||||
| 501 | '2HZ' => '2HZ ', | ||||||||||||||||||||||||||||
| 502 | '3HB' => '3HB ', | ||||||||||||||||||||||||||||
| 503 | '3HE' => '3HE ', | ||||||||||||||||||||||||||||
| 504 | '3HZ' => '3HZ ', | ||||||||||||||||||||||||||||
| 505 | 'N' => ' N ', | ||||||||||||||||||||||||||||
| 506 | 'NA' => ' NA ', | ||||||||||||||||||||||||||||
| 507 | 'NB' => ' NB ', | ||||||||||||||||||||||||||||
| 508 | 'NC' => ' NC ', | ||||||||||||||||||||||||||||
| 509 | 'ND' => ' ND ', | ||||||||||||||||||||||||||||
| 510 | 'N A' => ' N A', | ||||||||||||||||||||||||||||
| 511 | 'N B' => ' N B', | ||||||||||||||||||||||||||||
| 512 | 'N C' => ' N C', | ||||||||||||||||||||||||||||
| 513 | 'N D' => ' N D', | ||||||||||||||||||||||||||||
| 514 | 'N1' => ' N1 ', | ||||||||||||||||||||||||||||
| 515 | 'N2' => ' N2 ', | ||||||||||||||||||||||||||||
| 516 | 'N3' => ' N3 ', | ||||||||||||||||||||||||||||
| 517 | 'ND1' => ' ND1', | ||||||||||||||||||||||||||||
| 518 | 'ND2' => ' ND2', | ||||||||||||||||||||||||||||
| 519 | 'NE' => ' NE ', | ||||||||||||||||||||||||||||
| 520 | 'NE1' => ' NE1', | ||||||||||||||||||||||||||||
| 521 | 'NE2' => ' NE2', | ||||||||||||||||||||||||||||
| 522 | 'NH1' => ' NH1', | ||||||||||||||||||||||||||||
| 523 | 'NH2' => ' NH2', | ||||||||||||||||||||||||||||
| 524 | 'NZ' => ' NZ ', | ||||||||||||||||||||||||||||
| 525 | 'O' => ' O ', | ||||||||||||||||||||||||||||
| 526 | 'O1' => ' O1 ', | ||||||||||||||||||||||||||||
| 527 | 'O1A' => ' O1A', | ||||||||||||||||||||||||||||
| 528 | 'O1D' => ' O1D', | ||||||||||||||||||||||||||||
| 529 | 'O2' => ' O2 ', | ||||||||||||||||||||||||||||
| 530 | 'O2A' => ' O2A', | ||||||||||||||||||||||||||||
| 531 | 'O2D' => ' O2D', | ||||||||||||||||||||||||||||
| 532 | 'O3' => ' O3 ', | ||||||||||||||||||||||||||||
| 533 | 'O4' => ' O4 ', | ||||||||||||||||||||||||||||
| 534 | 'O5' => ' O5 ', | ||||||||||||||||||||||||||||
| 535 | 'O6' => ' O6 ', | ||||||||||||||||||||||||||||
| 536 | 'OD1' => ' OD1', | ||||||||||||||||||||||||||||
| 537 | 'OD2' => ' OD2', | ||||||||||||||||||||||||||||
| 538 | 'OE1' => ' OE1', | ||||||||||||||||||||||||||||
| 539 | 'OE2' => ' OE2', | ||||||||||||||||||||||||||||
| 540 | 'OG' => ' OG ', | ||||||||||||||||||||||||||||
| 541 | 'OG1' => ' OG1', | ||||||||||||||||||||||||||||
| 542 | 'OH' => ' OH ', | ||||||||||||||||||||||||||||
| 543 | 'OXT' => ' OXT', | ||||||||||||||||||||||||||||
| 544 | 'S' => ' S ', | ||||||||||||||||||||||||||||
| 545 | 'SD' => ' SD ', | ||||||||||||||||||||||||||||
| 546 | 'SG' => ' SG ' | ||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 550 | 2 | my $n = @_; | |||||||||||||||||||||||||||
| 551 | 2 | my $type; | |||||||||||||||||||||||||||
| 552 | my $anum; | ||||||||||||||||||||||||||||
| 553 | 2 | my $aname; | |||||||||||||||||||||||||||
| 554 | 2 | my $rname; | |||||||||||||||||||||||||||
| 555 | 2 | my $chain; | |||||||||||||||||||||||||||
| 556 | 2 | my $rnum; | |||||||||||||||||||||||||||
| 557 | 2 | my $xx; | |||||||||||||||||||||||||||
| 558 | 2 | my $yy; | |||||||||||||||||||||||||||
| 559 | 2 | my $zz; | |||||||||||||||||||||||||||
| 560 | 2 | my $coor; | |||||||||||||||||||||||||||
| 561 | 2 | my $beta; | |||||||||||||||||||||||||||
| 562 | 2 | local *OFIL; | |||||||||||||||||||||||||||
| 563 | 2 | my $nmodels = 0; | |||||||||||||||||||||||||||
| 564 | 2 | ▶ | if ($n == 0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 565 | { | ||||||||||||||||||||||||||||
| 566 | 2 | *OFIL = *STDOUT; | |||||||||||||||||||||||||||
| 567 | } | ||||||||||||||||||||||||||||
| 568 | else | ||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||
| 570 | #$nmodels=&models(0,"$_[0]") if (-e $_[0]); | ||||||||||||||||||||||||||||
| 571 | 0 | ▶ | open (OFIL,">>$_[0]") or die "Error in print $!\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||
| 573 | #$nmodels++; | ||||||||||||||||||||||||||||
| 574 | #printf OFIL "MODEL %8i\n",$nmodels; | ||||||||||||||||||||||||||||
| 575 | 2 | my $nm = $self -> size; | |||||||||||||||||||||||||||
| 576 | 2 | my $line; | |||||||||||||||||||||||||||
| 577 | 2 | ▶ | for (my $i = 0; $i < $nm; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||
| 579 | 58 | my $iatom = $self -> atom($i); | |||||||||||||||||||||||||||
| 580 | 58 | $type = $iatom->type; | |||||||||||||||||||||||||||
| 581 | 58 | $anum = $iatom->number; | |||||||||||||||||||||||||||
| 582 | 58 | $aname = $iatom->name; | |||||||||||||||||||||||||||
| 583 | 58 | $rname = $iatom->residue_name; | |||||||||||||||||||||||||||
| 584 | 58 | $chain = $iatom->chain; | |||||||||||||||||||||||||||
| 585 | 58 | $rnum = $iatom->residue_number; | |||||||||||||||||||||||||||
| 586 | 58 | $xx = $iatom->x; | |||||||||||||||||||||||||||
| 587 | 58 | $yy = $iatom->y; | |||||||||||||||||||||||||||
| 588 | 58 | $zz = $iatom->z; | |||||||||||||||||||||||||||
| 589 | 58 | $coor = $iatom->occupancy; | |||||||||||||||||||||||||||
| 590 | 58 | $beta = $iatom->beta; | |||||||||||||||||||||||||||
| 591 | #give the correct indentation to the atom name | ||||||||||||||||||||||||||||
| 592 | 58 | ▶ | $aname = $atom_name{$aname} if ( defined $atom_name{$aname} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 593 | 58 | $line = sprintf "%-6s%5i %4s %3s %1s%4i %8.3f%8.3f%8.3f%6.2f%6.2f\n",$type,$anum,$aname,$rname,$chain,$rnum,$xx,$yy,$zz,$coor,$beta; | |||||||||||||||||||||||||||
| 594 | 58 | print OFIL $line; | |||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||
| 596 | 2 | print OFIL "END\n"; | |||||||||||||||||||||||||||
| 597 | 2 | ▶ | close OFIL if ($n >= 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||
| 601 | #compute the geometric center of an atom selection | ||||||||||||||||||||||||||||
| 602 | sub center | ||||||||||||||||||||||||||||
| 603 | 3 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
center: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 604 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 605 | 3 | my $nrd = $self->size; | |||||||||||||||||||||||||||
| 606 | 3 | my $xx=0.00e0; | |||||||||||||||||||||||||||
| 607 | 3 | my $yy=0.00e0; | |||||||||||||||||||||||||||
| 608 | 3 | my $zz=0.00e0; | |||||||||||||||||||||||||||
| 609 | 3 | ▶ | for(my $i=0;$i < $nrd; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 610 | { | ||||||||||||||||||||||||||||
| 611 | 87 | my $iatom = $self -> atom($i); | |||||||||||||||||||||||||||
| 612 | 87 | $xx+=$iatom ->x; | |||||||||||||||||||||||||||
| 613 | 87 | $yy+=$iatom ->y; | |||||||||||||||||||||||||||
| 614 | 87 | $zz+=$iatom ->z; | |||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||
| 616 | 3 | ▶ | $xx /= $nrd if ( $nrd > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 617 | 3 | ▶ | $yy /= $nrd if ( $nrd > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 618 | 3 | ▶ | $zz /= $nrd if ( $nrd > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 619 | 3 | my $centroid = Bio::PDB::Structure::Atom -> new; | |||||||||||||||||||||||||||
| 620 | 3 | $centroid ->x($xx); | |||||||||||||||||||||||||||
| 621 | 3 | $centroid ->y($yy); | |||||||||||||||||||||||||||
| 622 | 3 | $centroid ->z($zz); | |||||||||||||||||||||||||||
| 623 | 3 | $centroid ->type("HETATM"); | |||||||||||||||||||||||||||
| 624 | 3 | $centroid ->name("CM"); | |||||||||||||||||||||||||||
| 625 | 3 | $centroid ->number(0); | |||||||||||||||||||||||||||
| 626 | 3 | $centroid ->residue_name("DUM"); | |||||||||||||||||||||||||||
| 627 | 3 | $centroid ->residue_number("0"); | |||||||||||||||||||||||||||
| 628 | 3 | $centroid ->chain(" "); | |||||||||||||||||||||||||||
| 629 | 3 | return $centroid; | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | #compute the center of mass of an atom selection | ||||||||||||||||||||||||||||
| 633 | sub cm | ||||||||||||||||||||||||||||
| 634 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
cm: called CC=11 SCAR=24.4
| |||||||||||||||||||||||||||||
| 635 | #These atoms usually have additional letters or numbers in their names | ||||||||||||||||||||||||||||
| 636 | 1 | my %mass1=( | |||||||||||||||||||||||||||
| 637 | H => 1, | ||||||||||||||||||||||||||||
| 638 | N => 14, | ||||||||||||||||||||||||||||
| 639 | C => 12, | ||||||||||||||||||||||||||||
| 640 | O => 16, | ||||||||||||||||||||||||||||
| 641 | P => 15, | ||||||||||||||||||||||||||||
| 642 | S => 32 | ||||||||||||||||||||||||||||
| 643 | ); | ||||||||||||||||||||||||||||
| 644 | #These atoms usually appear without extra characters in their names | ||||||||||||||||||||||||||||
| 645 | 1 | my %mass2=( | |||||||||||||||||||||||||||
| 646 | K => 39, | ||||||||||||||||||||||||||||
| 647 | FE => 56, | ||||||||||||||||||||||||||||
| 648 | CO => 59, | ||||||||||||||||||||||||||||
| 649 | CL => 35, | ||||||||||||||||||||||||||||
| 650 | MG => 24, | ||||||||||||||||||||||||||||
| 651 | NA => 23, | ||||||||||||||||||||||||||||
| 652 | NI => 59, | ||||||||||||||||||||||||||||
| 653 | CU => 64, | ||||||||||||||||||||||||||||
| 654 | ZN => 65 | ||||||||||||||||||||||||||||
| 655 | ); | ||||||||||||||||||||||||||||
| 656 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 657 | 1 | my $nrd = $self -> size; | |||||||||||||||||||||||||||
| 658 | 1 | my $ii; | |||||||||||||||||||||||||||
| 659 | my $jj; | ||||||||||||||||||||||||||||
| 660 | 1 | my $xx=0; | |||||||||||||||||||||||||||
| 661 | 1 | my $yy=0; | |||||||||||||||||||||||||||
| 662 | 1 | my $zz=0; | |||||||||||||||||||||||||||
| 663 | 1 | my $pre; | |||||||||||||||||||||||||||
| 664 | my $match; | ||||||||||||||||||||||||||||
| 665 | 1 | my $aname; | |||||||||||||||||||||||||||
| 666 | 1 | my $tmass =0; | |||||||||||||||||||||||||||
| 667 | 1 | my @kmass1 = keys %mass1; | |||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||
| 669 | 1 | ▶ | for(my $i=0;$i < $nrd; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 670 | { | ||||||||||||||||||||||||||||
| 671 | 29 | $pre = 0; | |||||||||||||||||||||||||||
| 672 | 29 | $match = 0; | |||||||||||||||||||||||||||
| 673 | 29 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 674 | 29 | $aname = uc($iatom -> name); | |||||||||||||||||||||||||||
| 675 | 29 | ▶ | $match = 2 if ( defined($mass2{$aname}) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 676 | 29 | ▶ | unless ($match) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 677 | { | ||||||||||||||||||||||||||||
| 678 | 29 | foreach $ii (@kmass1) | |||||||||||||||||||||||||||
| 679 | { | ||||||||||||||||||||||||||||
| 680 | 107 | ▶ | if ( $aname =~/$ii/ ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 681 | { | ||||||||||||||||||||||||||||
| 682 | 29 | $match = 1; | |||||||||||||||||||||||||||
| 683 | 29 | $jj = $ii; | |||||||||||||||||||||||||||
| 684 | 29 | last; | |||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||
| 688 | 29 | ▶ | if ($match == 1) | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 689 | { | ||||||||||||||||||||||||||||
| 690 | 29 | $pre = $mass1{$jj}; | |||||||||||||||||||||||||||
| 691 | } | ||||||||||||||||||||||||||||
| 692 | elsif ($match == 2) | ||||||||||||||||||||||||||||
| 693 | { | ||||||||||||||||||||||||||||
| 694 | 0 | $pre = $mass2{$aname}; | |||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||
| 696 | else | ||||||||||||||||||||||||||||
| 697 | { | ||||||||||||||||||||||||||||
| 698 | #atom's mass is not known, assume carbonlike | ||||||||||||||||||||||||||||
| 699 | 0 | $pre = 12; | |||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||
| 701 | 29 | $xx+= $pre * $iatom->x; | |||||||||||||||||||||||||||
| 702 | 29 | $yy+= $pre * $iatom->y; | |||||||||||||||||||||||||||
| 703 | 29 | $zz+= $pre * $iatom->z; | |||||||||||||||||||||||||||
| 704 | 29 | $tmass+=$pre; | |||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||
| 706 | 1 | ▶ | $xx /= $tmass if ( $tmass > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 707 | 1 | ▶ | $yy /= $tmass if ( $tmass > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 708 | 1 | ▶ | $zz /= $tmass if ( $tmass > 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 709 | 1 | my $centroid = Bio::PDB::Structure::Atom -> new; | |||||||||||||||||||||||||||
| 710 | 1 | $centroid ->x($xx); | |||||||||||||||||||||||||||
| 711 | 1 | $centroid ->y($yy); | |||||||||||||||||||||||||||
| 712 | 1 | $centroid ->z($zz); | |||||||||||||||||||||||||||
| 713 | 1 | $centroid ->type("HETATM"); | |||||||||||||||||||||||||||
| 714 | 1 | $centroid ->name("CM"); | |||||||||||||||||||||||||||
| 715 | 1 | $centroid ->number(0); | |||||||||||||||||||||||||||
| 716 | 1 | $centroid ->residue_name("DUM"); | |||||||||||||||||||||||||||
| 717 | 1 | $centroid ->residue_number("0"); | |||||||||||||||||||||||||||
| 718 | 1 | $centroid ->chain(" "); | |||||||||||||||||||||||||||
| 719 | 1 | return $centroid; | |||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | #translate an atom selection by the specified vector | ||||||||||||||||||||||||||||
| 724 | sub translate | ||||||||||||||||||||||||||||
| 725 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
translate: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 726 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 727 | 2 | my $n = @_; | |||||||||||||||||||||||||||
| 728 | 2 | ▶ | die "Error in translate: need an atom list an x,y,z\n" unless ($n == 3); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 729 | 2 | my $xt = shift; | |||||||||||||||||||||||||||
| 730 | 2 | my $yt = shift; | |||||||||||||||||||||||||||
| 731 | 2 | my $zt = shift; | |||||||||||||||||||||||||||
| 732 | 2 | my $nrd = $self->size; | |||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | 2 | ▶ | for (my $i=0; $i < $nrd; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 735 | { | ||||||||||||||||||||||||||||
| 736 | 58 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 737 | 58 | $iatom->x(($iatom->x + $xt)); | |||||||||||||||||||||||||||
| 738 | 58 | $iatom->y(($iatom->y + $yt)); | |||||||||||||||||||||||||||
| 739 | 58 | $iatom->z(($iatom->z + $zt)); | |||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||
| 741 | return | ||||||||||||||||||||||||||||
| 742 | 2 | } | |||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||
| 744 | #rotate an atom selection by the specified matrix, Ax = x'. | ||||||||||||||||||||||||||||
| 745 | #the matrix is specified by a flat list of the matrix elements. | ||||||||||||||||||||||||||||
| 746 | sub rotate | ||||||||||||||||||||||||||||
| 747 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
rotate: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 748 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 749 | 2 | my $n = @_; | |||||||||||||||||||||||||||
| 750 | 2 | ▶ | die "Error in rotate: need an atom list and a 9 element array\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 751 | unless ($n == 9); | ||||||||||||||||||||||||||||
| 752 | 2 | my $u11 = shift; | |||||||||||||||||||||||||||
| 753 | 2 | my $u12 = shift; | |||||||||||||||||||||||||||
| 754 | 2 | my $u13 = shift; | |||||||||||||||||||||||||||
| 755 | 2 | my $u21 = shift; | |||||||||||||||||||||||||||
| 756 | 2 | my $u22 = shift; | |||||||||||||||||||||||||||
| 757 | 2 | my $u23 = shift; | |||||||||||||||||||||||||||
| 758 | 2 | my $u31 = shift; | |||||||||||||||||||||||||||
| 759 | 2 | my $u32 = shift; | |||||||||||||||||||||||||||
| 760 | 2 | my $u33 = shift; | |||||||||||||||||||||||||||
| 761 | 2 | my ($x1,$y1,$z1); | |||||||||||||||||||||||||||
| 762 | 2 | my ($x2,$y2,$z2); | |||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||
| 764 | 2 | my $nrd = $self->size; | |||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||
| 766 | 2 | ▶ | for (my $i=0; $i < $nrd; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 767 | { | ||||||||||||||||||||||||||||
| 768 | 58 | my $iatom = $self -> atom($i); | |||||||||||||||||||||||||||
| 769 | 58 | $x1 = $iatom ->x; | |||||||||||||||||||||||||||
| 770 | 58 | $y1 = $iatom ->y; | |||||||||||||||||||||||||||
| 771 | 58 | $z1 = $iatom ->z; | |||||||||||||||||||||||||||
| 772 | 58 | $x2 = $u11*$x1 + $u12*$y1 + $u13*$z1; | |||||||||||||||||||||||||||
| 773 | 58 | $y2 = $u21*$x1 + $u22*$y1 + $u23*$z1; | |||||||||||||||||||||||||||
| 774 | 58 | $z2 = $u31*$x1 + $u32*$y1 + $u33*$z1; | |||||||||||||||||||||||||||
| 775 | 58 | $iatom->x($x2); | |||||||||||||||||||||||||||
| 776 | 58 | $iatom->y($y2); | |||||||||||||||||||||||||||
| 777 | 58 | $iatom->z($z2); | |||||||||||||||||||||||||||
| 778 | } | ||||||||||||||||||||||||||||
| 779 | return | ||||||||||||||||||||||||||||
| 780 | 2 | } | |||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||
| 782 | #combine rotate and translate to facilitate supperposition of structures | ||||||||||||||||||||||||||||
| 783 | #first 9 components represent rotation 3 last components rep. translation | ||||||||||||||||||||||||||||
| 784 | sub rotate_translate | ||||||||||||||||||||||||||||
| 785 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
rotate_translate: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 786 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 787 | 1 | my $n = @_; | |||||||||||||||||||||||||||
| 788 | 1 | ▶ | die "Error in rotate_translate: need a rotation matrix and a translation vector\n" unless ($n == 12); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 789 | 1 | my @mt; | |||||||||||||||||||||||||||
| 790 | my @vt; | ||||||||||||||||||||||||||||
| 791 | 1 | ▶ | for(my $i=0; $i < 9; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||
| 793 | 9 | $mt[$i] = shift; | |||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||
| 795 | 1 | ▶ | for(my $i=0; $i < 3; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 796 | { | ||||||||||||||||||||||||||||
| 797 | 3 | $vt[$i] = shift; | |||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||
| 799 | 1 | $self->rotate(@mt); | |||||||||||||||||||||||||||
| 800 | 1 | $self->translate(@vt); | |||||||||||||||||||||||||||
| 801 | return | ||||||||||||||||||||||||||||
| 802 | 1 | } | |||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||
| 804 | #do a superposition of an atom list to a reference (2nd argument) | ||||||||||||||||||||||||||||
| 805 | #selections must have the same number of atoms | ||||||||||||||||||||||||||||
| 806 | #Using method from: S. Kearsley, Acta Cryst. A45, 208-210 1989 | ||||||||||||||||||||||||||||
| 807 | sub superpose | ||||||||||||||||||||||||||||
| 808 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
superpose: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 809 | 1 | my $self1 = shift; | |||||||||||||||||||||||||||
| 810 | 1 | my $n = @_; | |||||||||||||||||||||||||||
| 811 | 1 | ▶ | die "Error in superpose: need an atom list (reference)\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 812 | unless ($n == 1); | ||||||||||||||||||||||||||||
| 813 | 1 | my $self2 = shift; | |||||||||||||||||||||||||||
| 814 | 1 | my $nrd1 = $self1->size; | |||||||||||||||||||||||||||
| 815 | 1 | my $nrd2 = $self2->size; | |||||||||||||||||||||||||||
| 816 | 1 | my ($x1,$y1,$z1); | |||||||||||||||||||||||||||
| 817 | 1 | my ($x2,$y2,$z2); | |||||||||||||||||||||||||||
| 818 | 1 | my ($xm,$ym,$zm); | |||||||||||||||||||||||||||
| 819 | 1 | my ($xp,$yp,$zp); | |||||||||||||||||||||||||||
| 820 | 1 | my ($Sxmxm, $Sxpxp, $Symym, $Sypyp, $Szmzm, $Szpzp); | |||||||||||||||||||||||||||
| 821 | 1 | my ($Sxmym, $Sxmyp, $Sxpym, $Sxpyp); | |||||||||||||||||||||||||||
| 822 | 1 | my ($Sxmzm, $Sxmzp, $Sxpzm, $Sxpzp); | |||||||||||||||||||||||||||
| 823 | 1 | my ($Symzm, $Symzp, $Sypzm, $Sypzp); | |||||||||||||||||||||||||||
| 824 | 1 | ▶ | die "superpose error: lists must have same number of atoms\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 825 | unless ($nrd1 == $nrd2); | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | #get the geometric center of the molecules | ||||||||||||||||||||||||||||
| 828 | 1 | my $gc1 = $self1 -> center; | |||||||||||||||||||||||||||
| 829 | 1 | my $gc2 = $self2 -> center; | |||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | #construct a 4X4 matrix in the quaternion representation | ||||||||||||||||||||||||||||
| 832 | 1 | ▶ | for(my $i=0; $i<$nrd1 ; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 833 | { | ||||||||||||||||||||||||||||
| 834 | 29 | my $iatom1=$self1->atom($i); | |||||||||||||||||||||||||||
| 835 | 29 | $x1 = $iatom1->x - $gc1->x; | |||||||||||||||||||||||||||
| 836 | 29 | $y1 = $iatom1->y - $gc1->y; | |||||||||||||||||||||||||||
| 837 | 29 | $z1 = $iatom1->z - $gc1->z; | |||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||
| 839 | 29 | my $iatom2=$self2->atom($i); | |||||||||||||||||||||||||||
| 840 | 29 | $x2 = $iatom2->x - $gc2->x; | |||||||||||||||||||||||||||
| 841 | 29 | $y2 = $iatom2->y - $gc2->y; | |||||||||||||||||||||||||||
| 842 | 29 | $z2 = $iatom2->z - $gc2->z; | |||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||
| 844 | 29 | $xm = ($x1 - $x2); | |||||||||||||||||||||||||||
| 845 | 29 | $xp = ($x1 + $x2); | |||||||||||||||||||||||||||
| 846 | 29 | $ym = ($y1 - $y2); | |||||||||||||||||||||||||||
| 847 | 29 | $yp = ($y1 + $y2); | |||||||||||||||||||||||||||
| 848 | 29 | $zm = ($z1 - $z2); | |||||||||||||||||||||||||||
| 849 | 29 | $zp = ($z1 + $z2); | |||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | 29 | $Sxmxm += $xm*$xm; | |||||||||||||||||||||||||||
| 852 | 29 | $Sxpxp += $xp*$xp; | |||||||||||||||||||||||||||
| 853 | 29 | $Symym += $ym*$ym; | |||||||||||||||||||||||||||
| 854 | 29 | $Sypyp += $yp*$yp; | |||||||||||||||||||||||||||
| 855 | 29 | $Szmzm += $zm*$zm; | |||||||||||||||||||||||||||
| 856 | 29 | $Szpzp += $zp*$zp; | |||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | 29 | $Sxmym += $xm*$ym; | |||||||||||||||||||||||||||
| 859 | 29 | $Sxmyp += $xm*$yp; | |||||||||||||||||||||||||||
| 860 | 29 | $Sxpym += $xp*$ym; | |||||||||||||||||||||||||||
| 861 | 29 | $Sxpyp += $xp*$yp; | |||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||
| 863 | 29 | $Sxmzm += $xm*$zm; | |||||||||||||||||||||||||||
| 864 | 29 | $Sxmzp += $xm*$zp; | |||||||||||||||||||||||||||
| 865 | 29 | $Sxpzm += $xp*$zm; | |||||||||||||||||||||||||||
| 866 | 29 | $Sxpzp += $xp*$zp; | |||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | 29 | $Symzm += $ym*$zm; | |||||||||||||||||||||||||||
| 869 | 29 | $Symzp += $ym*$zp; | |||||||||||||||||||||||||||
| 870 | 29 | $Sypzm += $yp*$zm; | |||||||||||||||||||||||||||
| 871 | 29 | $Sypzp += $yp*$zp; | |||||||||||||||||||||||||||
| 872 | } | ||||||||||||||||||||||||||||
| 873 | 1 | my @m; | |||||||||||||||||||||||||||
| 874 | 1 | $m[0]= $Sxmxm + $Symym + $Szmzm; | |||||||||||||||||||||||||||
| 875 | 1 | $m[1]= $Sypzm - $Symzp; | |||||||||||||||||||||||||||
| 876 | 1 | $m[2]= $Sxmzp - $Sxpzm; | |||||||||||||||||||||||||||
| 877 | 1 | $m[3]= $Sxpym - $Sxmyp; | |||||||||||||||||||||||||||
| 878 | 1 | $m[4]= $m[1]; | |||||||||||||||||||||||||||
| 879 | 1 | $m[5]= $Sypyp + $Szpzp + $Sxmxm; | |||||||||||||||||||||||||||
| 880 | 1 | $m[6]= $Sxmym - $Sxpyp; | |||||||||||||||||||||||||||
| 881 | 1 | $m[7]= $Sxmzm - $Sxpzp; | |||||||||||||||||||||||||||
| 882 | 1 | $m[8]= $m[2]; | |||||||||||||||||||||||||||
| 883 | 1 | $m[9]= $m[6]; | |||||||||||||||||||||||||||
| 884 | 1 | $m[10]= $Sxpxp + $Szpzp + $Symym; | |||||||||||||||||||||||||||
| 885 | 1 | $m[11]= $Symzm - $Sypzp; | |||||||||||||||||||||||||||
| 886 | 1 | $m[12]= $m[3]; | |||||||||||||||||||||||||||
| 887 | 1 | $m[13]= $m[7]; | |||||||||||||||||||||||||||
| 888 | 1 | $m[14]= $m[11]; | |||||||||||||||||||||||||||
| 889 | 1 | $m[15]=$Sxpxp + $Sypyp + $Szmzm; | |||||||||||||||||||||||||||
| 890 | #compute the egienvectors and eigenvalues of the matrix | ||||||||||||||||||||||||||||
| 891 | 1 | my ( $revec, $reval ) = &__diagonalize(@m); | |||||||||||||||||||||||||||
| 892 | #the smallest eigenvalue is the rmsd for the optimal alignment | ||||||||||||||||||||||||||||
| 893 | 1 | my $rmsd = sqrt(abs($reval->[0])/ $nrd1 ); | |||||||||||||||||||||||||||
| 894 | #fetch the optimal quaternion | ||||||||||||||||||||||||||||
| 895 | 1 | my @q; | |||||||||||||||||||||||||||
| 896 | 1 | $q[0]=$revec->[0][0]; | |||||||||||||||||||||||||||
| 897 | 1 | $q[1]=$revec->[1][0]; | |||||||||||||||||||||||||||
| 898 | 1 | $q[2]=$revec->[2][0]; | |||||||||||||||||||||||||||
| 899 | 1 | $q[3]=$revec->[3][0]; | |||||||||||||||||||||||||||
| 900 | #construct the rotation matrix given by the quaternion | ||||||||||||||||||||||||||||
| 901 | 1 | my @mt; | |||||||||||||||||||||||||||
| 902 | 1 | $mt[0] = $q[0]*$q[0] + $q[1]*$q[1] - $q[2]*$q[2] - $q[3]*$q[3]; | |||||||||||||||||||||||||||
| 903 | 1 | $mt[1] = 2.0 * ($q[1] * $q[2] - $q[0] * $q[3]); | |||||||||||||||||||||||||||
| 904 | 1 | $mt[2] = 2.0 * ($q[1] * $q[3] + $q[0] * $q[2]); | |||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||
| 907 | 1 | $mt[3] = 2.0 * ($q[2] * $q[1] + $q[0] * $q[3]); | |||||||||||||||||||||||||||
| 908 | 1 | $mt[4] = $q[0]*$q[0] - $q[1]*$q[1] + $q[2]*$q[2] - $q[3]*$q[3]; | |||||||||||||||||||||||||||
| 909 | 1 | $mt[5] = 2.0 * ($q[2] * $q[3] - $q[0] * $q[1]); | |||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | 1 | $mt[6] = 2.0 *($q[3] * $q[1] - $q[0] * $q[2]); | |||||||||||||||||||||||||||
| 912 | 1 | $mt[7] = 2.0 * ($q[3] * $q[2] + $q[0] * $q[1]); | |||||||||||||||||||||||||||
| 913 | 1 | $mt[8] = $q[0]*$q[0] - $q[1]*$q[1] - $q[2]*$q[2] + $q[3]*$q[3]; | |||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | #compute the displacement vector | ||||||||||||||||||||||||||||
| 916 | 1 | my @vt; | |||||||||||||||||||||||||||
| 917 | 1 | $vt[0] = $gc2->x - $mt[0]*$gc1->x - $mt[1]*$gc1->y - $mt[2]*$gc1->z; | |||||||||||||||||||||||||||
| 918 | 1 | $vt[1] = $gc2->y - $mt[3]*$gc1->x - $mt[4]*$gc1->y - $mt[5]*$gc1->z; | |||||||||||||||||||||||||||
| 919 | 1 | $vt[2] = $gc2->z - $mt[6]*$gc1->x - $mt[7]*$gc1->y - $mt[8]*$gc1->z; | |||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | #return the transformation as one list rotation first | ||||||||||||||||||||||||||||
| 922 | 1 | return ( @mt,@vt ); | |||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | #compute the rmsd between two atom selections (must have same number of atoms) | ||||||||||||||||||||||||||||
| 926 | sub rmsd | ||||||||||||||||||||||||||||
| 927 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
rmsd: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 928 | 1 | my $self1 =shift; | |||||||||||||||||||||||||||
| 929 | 1 | my $n = @_; | |||||||||||||||||||||||||||
| 930 | 1 | ▶ | die "Error in rmsd: an atom list\n" unless ($n == 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 931 | 1 | my $self2 = shift; | |||||||||||||||||||||||||||
| 932 | 1 | my $nrd1 = $self1 ->size; | |||||||||||||||||||||||||||
| 933 | 1 | my $nrd2 = $self2 ->size; | |||||||||||||||||||||||||||
| 934 | 1 | my ($dx,$dy,$dz); | |||||||||||||||||||||||||||
| 935 | 1 | my $rmsd=0; | |||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | 1 | ▶ | die "rmsd error: lists must have same number of atoms\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 938 | unless ($nrd1 == $nrd2); | ||||||||||||||||||||||||||||
| 939 | 1 | ▶ | for(my $i=0;$i<$nrd1;$i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 940 | { | ||||||||||||||||||||||||||||
| 941 | 29 | my $iatom1 = $self1->atom($i); | |||||||||||||||||||||||||||
| 942 | 29 | my $iatom2 = $self2->atom($i); | |||||||||||||||||||||||||||
| 943 | |||||||||||||||||||||||||||||
| 944 | 29 | $dx = $iatom1->x - $iatom2->x; | |||||||||||||||||||||||||||
| 945 | 29 | $dy = $iatom1->y - $iatom2->y; | |||||||||||||||||||||||||||
| 946 | 29 | $dz = $iatom1->z - $iatom2->z; | |||||||||||||||||||||||||||
| 947 | 29 | $rmsd += $dx**2 + $dy**2 + $dz**2; | |||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||
| 949 | 1 | ▶ | $rmsd =sqrt($rmsd /$nrd1) if ( $nrd1 > 0.0E0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 950 | 1 | return $rmsd; | |||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | #some predefined atom lists | ||||||||||||||||||||||||||||
| 954 | #return protein or nucleic acid atoms | ||||||||||||||||||||||||||||
| 955 | sub protein | ||||||||||||||||||||||||||||
| 956 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
protein: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 957 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 958 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 959 | 0 | my $mol= Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 960 | 0 | ▶ | for( my $i=0; $i < $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 961 | { | ||||||||||||||||||||||||||||
| 962 | 0 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 963 | 0 | ▶ | $mol -> push($iatom) if ( $iatom->type eq "ATOM"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 964 | } | ||||||||||||||||||||||||||||
| 965 | 0 | return $mol; | |||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | sub hetatoms | ||||||||||||||||||||||||||||
| 969 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
hetatoms: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 970 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 971 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 972 | 0 | my $mol= Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 973 | 0 | ▶ | for( my $i=0; $i < $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 974 | { | ||||||||||||||||||||||||||||
| 975 | 0 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 976 | 0 | ▶ | $mol -> push($iatom) if ( $iatom->type eq "HETATM"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 977 | } | ||||||||||||||||||||||||||||
| 978 | 0 | return $mol; | |||||||||||||||||||||||||||
| 979 | } | ||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||
| 981 | sub alpha | ||||||||||||||||||||||||||||
| 982 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
alpha: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 983 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 984 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 985 | 0 | my $mol= Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 986 | 0 | ▶ | for( my $i=0; $i < $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 987 | { | ||||||||||||||||||||||||||||
| 988 | 0 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 989 | 0 | ▶ | $mol -> push($iatom) if ( $iatom->type eq "ATOM" && $iatom->name eq "CA"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$iatom->type eq "ATOM" and $iatom->name eq "CA"
MC/DC0%0/2
$iatom->type eq "ATOM" and $iatom->name eq "CA"
$iatom->type eq "ATOM"
$iatom->name eq "CA"
Truth table0%0/3
A and B
A= $iatom->type eq "ATOM"B= $iatom->name eq "CA"
| |||||||||||||||||||||||||||||
| 990 | } | ||||||||||||||||||||||||||||
| 991 | 0 | return $mol; | |||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||
| 994 | sub backbone | ||||||||||||||||||||||||||||
| 995 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
backbone: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 996 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 997 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 998 | 0 | my $mol= Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 999 | 0 | my @batoms = ("N","C","CA","O","OXT"); | |||||||||||||||||||||||||||
| 1000 | 0 | ▶ | for( my $i=0; $i < $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1001 | { | ||||||||||||||||||||||||||||
| 1002 | 0 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 1003 | 0 | ▶ | next if ($iatom->type ne "ATOM"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1004 | 0 | my $name = $iatom->name; | |||||||||||||||||||||||||||
| 1005 | 0 | ▶ | $mol -> push($iatom) if ( grep /^$name$/,@batoms ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1006 | } | ||||||||||||||||||||||||||||
| 1007 | 0 | return $mol; | |||||||||||||||||||||||||||
| 1008 | } | ||||||||||||||||||||||||||||
| 1009 | |||||||||||||||||||||||||||||
| 1010 | sub sidechains | ||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
sidechains: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 1012 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 1013 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 1014 | 0 | my $mol= Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 1015 | 0 | my @batoms = ("N","C","CA","O","H","HA","OXT"); | |||||||||||||||||||||||||||
| 1016 | 0 | ▶ | for( my $i=0; $i < $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1017 | { | ||||||||||||||||||||||||||||
| 1018 | 0 | my $iatom = $self->atom($i); | |||||||||||||||||||||||||||
| 1019 | 0 | ▶ | next if ($iatom->type ne "ATOM"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1020 | 0 | my $name = $iatom->name; | |||||||||||||||||||||||||||
| 1021 | 0 | ▶ | $mol -> push($iatom) if (not grep /^$name$/,@batoms ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1022 | } | ||||||||||||||||||||||||||||
| 1023 | 0 | return $mol; | |||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||
| 1026 | #get a list of atoms specified by user input residue_name,residue_number, | ||||||||||||||||||||||||||||
| 1027 | #chain_name,atom_name,atom_number; | ||||||||||||||||||||||||||||
| 1028 | sub list_atoms | ||||||||||||||||||||||||||||
| 1029 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
list_atoms: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 1030 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 1031 | 0 | my $ni = @_; | |||||||||||||||||||||||||||
| 1032 | 0 | ▶ | die "Error in list_atom: need a logical expression\n" if ($ni != 1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1033 | 0 | my $logic = shift; | |||||||||||||||||||||||||||
| 1034 | 0 | my $n = $self->size; | |||||||||||||||||||||||||||
| 1035 | 0 | my @i2n = ( | |||||||||||||||||||||||||||
| 1036 | "RESIDUE_NAME", | ||||||||||||||||||||||||||||
| 1037 | "RESIDUE_NUMBER", | ||||||||||||||||||||||||||||
| 1038 | "TYPE", | ||||||||||||||||||||||||||||
| 1039 | "NUMBER", | ||||||||||||||||||||||||||||
| 1040 | "NAME", | ||||||||||||||||||||||||||||
| 1041 | "CHAIN", | ||||||||||||||||||||||||||||
| 1042 | "X", | ||||||||||||||||||||||||||||
| 1043 | "Y", | ||||||||||||||||||||||||||||
| 1044 | "Z", | ||||||||||||||||||||||||||||
| 1045 | "OCCUPANCY", | ||||||||||||||||||||||||||||
| 1046 | "BETA", | ||||||||||||||||||||||||||||
| 1047 | "ALT", | ||||||||||||||||||||||||||||
| 1048 | "INSERTION_CODE" | ||||||||||||||||||||||||||||
| 1049 | ); | ||||||||||||||||||||||||||||
| 1050 | 0 | my @i2v = ( | |||||||||||||||||||||||||||
| 1051 | '$iatom->residue_name', | ||||||||||||||||||||||||||||
| 1052 | '$iatom->residue_number', | ||||||||||||||||||||||||||||
| 1053 | '$iatom->type', | ||||||||||||||||||||||||||||
| 1054 | '$iatom->number', | ||||||||||||||||||||||||||||
| 1055 | '$iatom->name', | ||||||||||||||||||||||||||||
| 1056 | '$iatom->chain', | ||||||||||||||||||||||||||||
| 1057 | '$iatom->x', | ||||||||||||||||||||||||||||
| 1058 | '$iatom->y', | ||||||||||||||||||||||||||||
| 1059 | '$iatom->z', | ||||||||||||||||||||||||||||
| 1060 | '$iatom->occupancy', | ||||||||||||||||||||||||||||
| 1061 | '$iatom->beta', | ||||||||||||||||||||||||||||
| 1062 | '$iatom->alt', | ||||||||||||||||||||||||||||
| 1063 | '$iatom->insertion_code' | ||||||||||||||||||||||||||||
| 1064 | ); | ||||||||||||||||||||||||||||
| 1065 | #so as to be able to write logical expressions in a natural format we have | ||||||||||||||||||||||||||||
| 1066 | #to do a bit of extra processing | ||||||||||||||||||||||||||||
| 1067 | #save expressions between quotes to protect them | ||||||||||||||||||||||||||||
| 1068 | 0 | my @temp; | |||||||||||||||||||||||||||
| 1069 | 0 | ▶ | while ($logic =~s/(\"\w+\")/!!/) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1070 | { | ||||||||||||||||||||||||||||
| 1071 | 0 | CORE::push (@temp,$1); | |||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||
| 1073 | 0 | $logic= uc($logic); | |||||||||||||||||||||||||||
| 1074 | #now substitute with method calls | ||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | for (my $i =0; $i<13; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1076 | { | ||||||||||||||||||||||||||||
| 1077 | 0 | $logic =~ s/$i2n[$i]/$i2v[$i]/g; | |||||||||||||||||||||||||||
| 1078 | } | ||||||||||||||||||||||||||||
| 1079 | 0 | $logic= lc($logic); | |||||||||||||||||||||||||||
| 1080 | #restore expressions between quotes | ||||||||||||||||||||||||||||
| 1081 | 0 | foreach my $itemp (@temp) | |||||||||||||||||||||||||||
| 1082 | { | ||||||||||||||||||||||||||||
| 1083 | 0 | $logic=~s/!!/$itemp/; | |||||||||||||||||||||||||||
| 1084 | } | ||||||||||||||||||||||||||||
| 1085 | #print "$logic\n"; | ||||||||||||||||||||||||||||
| 1086 | 0 | my $mol = Bio::PDB::Structure::Molecule -> new; | |||||||||||||||||||||||||||
| 1087 | 0 | my $iatom= $self-> atom(0); | |||||||||||||||||||||||||||
| 1088 | 0 | eval $logic; | |||||||||||||||||||||||||||
| 1089 | 0 | ▶ | die "Error with logical expression for list_atoms call\n" if $@; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1090 | 0 | ▶ | for (my $i=0; $i< $n; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1091 | { | ||||||||||||||||||||||||||||
| 1092 | 0 | $iatom = $self-> atom($i); | |||||||||||||||||||||||||||
| 1093 | 0 | ▶ | $mol -> push($iatom) if ( eval $logic ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1094 | } | ||||||||||||||||||||||||||||
| 1095 | 0 | return $mol; | |||||||||||||||||||||||||||
| 1096 | } | ||||||||||||||||||||||||||||
| 1097 | |||||||||||||||||||||||||||||
| 1098 | #Jacobi diagonalizer | ||||||||||||||||||||||||||||
| 1099 | 1 | ▶ | sub __diagonalize { | ||||||||||||||||||||||||||
|
Subroutine
__diagonalize: called CC=22 SCAR=30.9
| |||||||||||||||||||||||||||||
| 1100 | 1 | my ($onorm, $dnorm); | |||||||||||||||||||||||||||
| 1101 | 1 | my ($b,$dma,$q,$t,$c,$s); | |||||||||||||||||||||||||||
| 1102 | 1 | my ($atemp, $vtemp, $dtemp); | |||||||||||||||||||||||||||
| 1103 | 1 | my ($i,$j,$k,$l); | |||||||||||||||||||||||||||
| 1104 | 1 | my @a; | |||||||||||||||||||||||||||
| 1105 | 1 | my @v; | |||||||||||||||||||||||||||
| 1106 | 1 | my @d; | |||||||||||||||||||||||||||
| 1107 | 1 | my $nrot = 30; #number of sweeps | |||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||
| 1109 | 1 | ▶ | for ($i = 0; $i < 4; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1110 | { | ||||||||||||||||||||||||||||
| 1111 | 4 | ▶ | for ($j = 0; $j < 4; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1112 | { | ||||||||||||||||||||||||||||
| 1113 | 16 | $a[$i][$j] =$_[4*$i + $j]; | |||||||||||||||||||||||||||
| 1114 | 16 | $v[$i][$j] = 0.0; | |||||||||||||||||||||||||||
| 1115 | } | ||||||||||||||||||||||||||||
| 1116 | } | ||||||||||||||||||||||||||||
| 1117 | |||||||||||||||||||||||||||||
| 1118 | 1 | ▶ | for ($j = 0; $j <= 3; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1119 | { | ||||||||||||||||||||||||||||
| 1120 | 4 | $v[$j][$j] = 1.0; | |||||||||||||||||||||||||||
| 1121 | 4 | $d[$j] = $a[$j][$j]; | |||||||||||||||||||||||||||
| 1122 | } | ||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||
| 1124 | 1 | ▶ | for ($l = 1; $l <= $nrot; $l++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1125 | { | ||||||||||||||||||||||||||||
| 1126 | 5 | $dnorm = 0.0; | |||||||||||||||||||||||||||
| 1127 | 5 | $onorm = 0.0; | |||||||||||||||||||||||||||
| 1128 | 5 | ▶ | for ($j = 0; $j <= 3; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1129 | { | ||||||||||||||||||||||||||||
| 1130 | 20 | $dnorm += abs($d[$j]); | |||||||||||||||||||||||||||
| 1131 | 20 | ▶ | for ($i = 0; $i <= $j - 1; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1132 | { | ||||||||||||||||||||||||||||
| 1133 | 30 | $onorm += abs($a[$i][$j]); | |||||||||||||||||||||||||||
| 1134 | } | ||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||
| 1136 | 5 | ▶ | last if(($onorm/$dnorm) <= 1.0e-12); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1137 | 4 | ▶ | for ($j = 1; $j <= 3; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1138 | { | ||||||||||||||||||||||||||||
| 1139 | 12 | ▶ | for ($i = 0; $i <= $j - 1; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1140 | { | ||||||||||||||||||||||||||||
| 1141 | 24 | $b = $a[$i][$j]; | |||||||||||||||||||||||||||
| 1142 | 24 | ▶ | if(abs($b) > 0.0) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1143 | { | ||||||||||||||||||||||||||||
| 1144 | 24 | $dma = $d[$j] - $d[$i]; | |||||||||||||||||||||||||||
| 1145 | 24 | ▶ | if((abs($dma) + abs($b)) <= abs($dma)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1146 | { | ||||||||||||||||||||||||||||
| 1147 | 2 | $t = $b / $dma; | |||||||||||||||||||||||||||
| 1148 | } | ||||||||||||||||||||||||||||
| 1149 | else | ||||||||||||||||||||||||||||
| 1150 | { | ||||||||||||||||||||||||||||
| 1151 | 22 | $q = 0.5 * $dma / $b; | |||||||||||||||||||||||||||
| 1152 | 22 | $t = 1.0/(abs($q) + sqrt(1.0+$q*$q)); | |||||||||||||||||||||||||||
| 1153 | 22 | ▶ | $t *= -1.0 if($q < 0.0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1154 | } | ||||||||||||||||||||||||||||
| 1155 | 24 | $c = 1.0/sqrt($t * $t + 1.0); | |||||||||||||||||||||||||||
| 1156 | 24 | $s = $t * $c; | |||||||||||||||||||||||||||
| 1157 | 24 | $a[$i][$j] = 0.0; | |||||||||||||||||||||||||||
| 1158 | 24 | ▶ | for ($k = 0; $k <= $i-1; $k++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1159 | { | ||||||||||||||||||||||||||||
| 1160 | 16 | $atemp = $c * $a[$k][$i] - $s * $a[$k][$j]; | |||||||||||||||||||||||||||
| 1161 | 16 | $a[$k][$j] = $s * $a[$k][$i] + $c * $a[$k][$j]; | |||||||||||||||||||||||||||
| 1162 | 16 | $a[$k][$i] = $atemp; | |||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||
| 1164 | 24 | ▶ | for ($k = $i+1; $k <= $j-1; $k++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1165 | { | ||||||||||||||||||||||||||||
| 1166 | 16 | $atemp = $c * $a[$i][$k] - $s * $a[$k][$j]; | |||||||||||||||||||||||||||
| 1167 | 16 | $a[$k][$j] = $s * $a[$i][$k] + $c * $a[$k][$j]; | |||||||||||||||||||||||||||
| 1168 | 16 | $a[$i][$k] = $atemp; | |||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||
| 1170 | 24 | ▶ | for ($k = $j+1; $k <= 3; $k++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1171 | { | ||||||||||||||||||||||||||||
| 1172 | 16 | $atemp = $c * $a[$i][$k] - $s * $a[$j][$k]; | |||||||||||||||||||||||||||
| 1173 | 16 | $a[$j][$k] = $s * $a[$i][$k] + $c * $a[$j][$k]; | |||||||||||||||||||||||||||
| 1174 | 16 | $a[$i][$k] = $atemp; | |||||||||||||||||||||||||||
| 1175 | } | ||||||||||||||||||||||||||||
| 1176 | 24 | ▶ | for ($k = 0; $k <= 3; $k++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1177 | { | ||||||||||||||||||||||||||||
| 1178 | 96 | $vtemp = $c * $v[$k][$i] - $s * $v[$k][$j]; | |||||||||||||||||||||||||||
| 1179 | 96 | $v[$k][$j] = $s * $v[$k][$i] + $c * $v[$k][$j]; | |||||||||||||||||||||||||||
| 1180 | 96 | $v[$k][$i] = $vtemp; | |||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||
| 1182 | 24 | $dtemp = $c*$c*$d[$i] + $s*$s*$d[$j] - 2.0*$c*$s*$b; | |||||||||||||||||||||||||||
| 1183 | 24 | $d[$j] = $s*$s*$d[$i] + $c*$c*$d[$j] + 2.0*$c*$s*$b; | |||||||||||||||||||||||||||
| 1184 | 24 | $d[$i] = $dtemp; | |||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||
| 1187 | } | ||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||
| 1190 | 1 | $nrot = $l; | |||||||||||||||||||||||||||
| 1191 | 1 | ▶ | for ($j = 0; $j <= 2; $j++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1192 | { | ||||||||||||||||||||||||||||
| 1193 | 3 | $k = $j; | |||||||||||||||||||||||||||
| 1194 | 3 | $dtemp = $d[$k]; | |||||||||||||||||||||||||||
| 1195 | 3 | ▶ | for ($i = $j+1; $i <= 3; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1196 | { | ||||||||||||||||||||||||||||
| 1197 | 6 | ▶ | if($d[$i] < $dtemp) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1198 | { | ||||||||||||||||||||||||||||
| 1199 | 2 | $k = $i; | |||||||||||||||||||||||||||
| 1200 | 2 | $dtemp = $d[$k]; | |||||||||||||||||||||||||||
| 1201 | } | ||||||||||||||||||||||||||||
| 1202 | } | ||||||||||||||||||||||||||||
| 1203 | |||||||||||||||||||||||||||||
| 1204 | 3 | ▶ | if($k > $j) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1205 | { | ||||||||||||||||||||||||||||
| 1206 | 2 | $d[$k] = $d[$j]; | |||||||||||||||||||||||||||
| 1207 | 2 | $d[$j] = $dtemp; | |||||||||||||||||||||||||||
| 1208 | 2 | ▶ | for ($i = 0; $i <= 3; $i++) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1209 | { | ||||||||||||||||||||||||||||
| 1210 | 8 | $dtemp = $v[$i][$k]; | |||||||||||||||||||||||||||
| 1211 | 8 | $v[$i][$k] = $v[$i][$j]; | |||||||||||||||||||||||||||
| 1212 | 8 | $v[$i][$j] = $dtemp; | |||||||||||||||||||||||||||
| 1213 | } | ||||||||||||||||||||||||||||
| 1214 | } | ||||||||||||||||||||||||||||
| 1215 | } | ||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||
| 1217 | 1 | return (\@v,\@d) | |||||||||||||||||||||||||||
| 1218 | } | ||||||||||||||||||||||||||||
| 1219 | |||||||||||||||||||||||||||||
| 1220 | 1 | 1; | |||||||||||||||||||||||||||
| 1221 | __END__ | ||||||||||||||||||||||||||||