HackaMol/Roles/PdbRole.pm

filter: Statementstmt 97.9% 47 / 48 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 2 / 2 totaltotal 93.6% 59 / 63 SCAR 16.1
CC
5
Cov
93%
aa321
4.1
pdb_rename
2.0
BEGIN
1.0
CRAP 5.0
« HackaMol/Roles/NERFRole.pm ↑ Summary HackaMol/Angle.pm »
1 package HackaMol::Roles::PdbRole;
2 19 $HackaMol::Roles::PdbRole::VERSION = '0.051';
3 #ABSTRACT: PdbRole of lazy attributes for HackaMol atoms
4 19 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 19 has 'record_name', is => 'rw', isa => 'Str', lazy => 1, default => 'HETATM';
9 19 has 'occ', is => 'rw', isa => 'Num', lazy => 1, default => 1.0;
10 19 has 'bfact', is => 'rw', isa => 'Num', lazy => 1, default => 20.0;
11 # b_iso
12 # b_aniso (vector) would be better here
13 19 has 'bfp', is => 'rw', isa => 'Num' ; # bfactor profile
14 # (10.1016/j.jmb.2015.09.024)
15 19 has 'resname', is => 'rw', isa => 'Str', lazy => 1, default => 'UNK';
16 # cif label_asym_id
17 19 has 'chain', is => 'rw', isa => 'Str', lazy => 1, default => ' ';
18 # cif label_alt_id
19 19 has 'altloc', is => 'rw', isa => 'Str', lazy => 1, default => ' ';
20 19 has 'icode', is => 'rw', isa => 'Str', lazy => 1, default => ' ';
21 19 has 'pdbid', is => 'rw', isa => 'Str', lazy => 1, default => ' ';
22 # cif label_seq_id
23 19 has 'segid', is => 'rw', isa => 'Str', lazy => 1, default => ' ';
24 19 has 'iatom', is => 'rw', isa => 'Int', lazy => 1, default => 0;
25 19 has 'resid', is => 'rw', isa => 'Str', lazy => 1, default => 1;
26 19 has 'serial', is => 'rw', isa => 'Int', lazy => 1, default => 1;
27 19 has 'sasa', is => 'rw', isa => 'Num', lazy => 1, default => 0.0;
28 19 has 'model_num', is => 'rw', isa => 'Num'; # cif
29 19 has 'auth_seq_id', is => 'rw', isa => 'Int'; # cif, -> author fudged resid
30 19 has 'auth_comp_id', is => 'rw', isa => 'Str'; # cif, -> author fudged resname
31 19 has 'auth_asym_id', is => 'rw', isa => 'Str'; # cif
32 19 has 'auth_atom_id', is => 'rw', isa => 'Str'; # cif -> author fudged name
33 19 has 'entity_id', is => 'rw', isa => 'Int'; # cif, e.g. virus, main chains of 1 entity
34 19 has 'pdb_formal_charge', is => 'rw', isa => 'Num'; # cif, e.g. virus, main chains of 1 entity
35  
36 19 my %aa321 = (
37 ALA=>'A', ARG=>'R', ASN=>'N', ASP=>'D', CYS=>'C',
38 GLU=>'E', GLN=>'Q', GLY=>'G', HIS=>'H', ILE=>'I',
39 LEU=>'L', LYS=>'K', MET=>'M', PHE=>'F', PRO=>'P',
40 SER=>'S', THR=>'T', TRP=>'W', TYR=>'Y', VAL=>'V',
41 SEC=>'U',
42 );
43  
44 sub aa321 {
45 43 ▶ my $self = shift;
Subroutine aa321: called CC=4 SCAR=14.2
Pod documented
46 43 my $x_flag = shift;
47 43 ▶ $x_flag = 1 unless defined($x_flag);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $x_flag 43 0 43
48  
49 43 my $resname = uc($self->resname);
50
51 43 ▶ unless ( exists($aa321{$resname}) ){
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $aa321{$resname}) 1 42 43
52 1 carp "PDBRole> residue $resname name has no 1 letter code";
53 1 ▶ return ('X') if $x_flag;
Branch: 1 branch
BranchTrueFalseTotal
if $x_flag 1 0 1
54 0 return ("($resname)");
55 }
56 42 return ($aa321{$resname});
57 }
58 #following map lifted from Bio::PDB::Structure::Atom
59  
60 19 my %pdb_atom_names = (
61 'C' => ' C ',
62 'C1' => ' C1 ',
63 'C1A' => ' C1A',
64 'C1B' => ' C1B',
65 'C1C' => ' C1C',
66 'C1D' => ' C1D',
67 'C2' => ' C2 ',
68 'C2A' => ' C2A',
69 'C2B' => ' C2B',
70 'C2C' => ' C2C',
71 'C2D' => ' C2D',
72 'C3' => ' C3 ',
73 'C3A' => ' C3A',
74 'C3B' => ' C3B',
75 'C3C' => ' C3C',
76 'C3D' => ' C3D',
77 'C4' => ' C4 ',
78 'C4A' => ' C4A',
79 'C4A' => ' C4A',
80 'C4B' => ' C4B',
81 'C4C' => ' C4C',
82 'C4D' => ' C4D',
83 'C5' => ' C5 ',
84 'C6' => ' C6 ',
85 'CA' => ' CA ',
86 'CAA' => ' CAA',
87 'CAB' => ' CAB',
88 'CAC' => ' CAC',
89 'CAD' => ' CAD',
90 'CB' => ' CB ',
91 'CBA' => ' CBA',
92 'CBB' => ' CBB',
93 'CBC' => ' CBC',
94 'CBD' => ' CBD',
95 'CD' => ' CD ',
96 'CD1' => ' CD1',
97 'CD2' => ' CD2',
98 'CE' => ' CE ',
99 'CE1' => ' CE1',
100 'CE2' => ' CE2',
101 'CE3' => ' CE3',
102 'CG' => ' CG ',
103 'CG1' => ' CG1',
104 'CG2' => ' CG2',
105 'CGA' => ' CGA',
106 'CGD' => ' CGD',
107 'CH2' => ' CH2',
108 'CHA' => ' CHA',
109 'CHB' => ' CHB',
110 'CHC' => ' CHC',
111 'CHD' => ' CHD',
112 'CMA' => ' CMA',
113 'CMB' => ' CMB',
114 'CMC' => ' CMC',
115 'CMD' => ' CMD',
116 'CZ' => ' CZ ',
117 'CZ2' => ' CZ2',
118 'CZ3' => ' CZ3',
119 'FE' => 'FE ',
120 'H' => ' H ',
121 'HA' => ' HA ',
122 'HB' => ' HB ',
123 'HG' => ' HG ',
124 'HE' => ' HE ',
125 'HZ' => ' HZ ',
126 'HH' => ' HH ',
127 '1H' => '1H ',
128 '2H' => '2H ',
129 '3H' => '3H ',
130 '1HA' => '1HA ',
131 '1HB' => '1HB ',
132 '1HD' => '1HD ',
133 '1HE' => '1HE ',
134 '1HG' => '1HG ',
135 '1HZ' => '1HZ ',
136 '2HA' => '2HA ',
137 '2HB' => '2HB ',
138 '2HD' => '2HD ',
139 '2HE' => '2HE ',
140 '2HG' => '2HG ',
141 '1HZ' => '1HZ ',
142 '2HZ' => '2HZ ',
143 '3HB' => '3HB ',
144 '3HE' => '3HE ',
145 '3HZ' => '3HZ ',
146 'N' => ' N ',
147 'NA' => ' NA ',
148 'NB' => ' NB ',
149 'NC' => ' NC ',
150 'ND' => ' ND ',
151 'N A' => ' N A',
152 'N B' => ' N B',
153 'N C' => ' N C',
154 'N D' => ' N D',
155 'N1' => ' N1 ',
156 'N2' => ' N2 ',
157 'N3' => ' N3 ',
158 'ND1' => ' ND1',
159 'ND2' => ' ND2',
160 'NE' => ' NE ',
161 'NE1' => ' NE1',
162 'NE2' => ' NE2',
163 'NH1' => ' NH1',
164 'NH2' => ' NH2',
165 'NZ' => ' NZ ',
166 'O' => ' O ',
167 'O1' => ' O1 ',
168 'O1A' => ' O1A',
169 'O1D' => ' O1D',
170 'O2' => ' O2 ',
171 'O2A' => ' O2A',
172 'O2D' => ' O2D',
173 'O3' => ' O3 ',
174 'O4' => ' O4 ',
175 'O5' => ' O5 ',
176 'O6' => ' O6 ',
177 'OD1' => ' OD1',
178 'OD2' => ' OD2',
179 'OE1' => ' OE1',
180 'OE2' => ' OE2',
181 'OG' => ' OG ',
182 'OG1' => ' OG1',
183 'OH' => ' OH ',
184 'OXT' => ' OXT',
185 'S' => ' S ',
186 'SD' => ' SD ',
187 'SG' => ' SG '
188 );
189  
190 sub pdb_rename{
191 5 ▶ my $self = shift;
Subroutine pdb_rename: called CC=2 SCAR=7.0
Pod documented
192 5 my $name = $self->name;
193 5 ▶ if(exists($pdb_atom_names{$self->name})){
Branch: 1 branch
BranchTrueFalseTotal
if (exists $pdb_atom_names{$self->name}) 5 0 5
194 5 $self->name($pdb_atom_names{$self->name});
195 }
196 5 return $name;
197 }
198  
199 19 ▶no Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
200 19 1;
201  
202 # added attributes for parsing a PDB file
203 # Histidine 64 for Human Carbonic Anhydrase II from pdbid: 2CBA
204 #some lines for reference that did not translate well into POD
205 #my $lines_H64_2cba = '
206 # 1 2 3 4 5 6 7 8
207 #12345678901234567890123456789012345678901234567890123456789012345678901234567890
208 #ATOM 504 N HIS A 64 -0.822 -1.995 6.439 1.00 10.63 N
209 #ATOM 505 CA HIS A 64 -0.847 -2.773 7.721 1.00 10.22 C
210 #ATOM 506 C HIS A 64 -2.270 -3.278 7.949 1.00 9.51 C
211 #ATOM 507 O HIS A 64 -2.449 -4.225 8.736 1.00 11.94 O
212 #ATOM 508 CB AHIS A 64 -0.335 -2.173 8.991 0.70 10.98 C
213 #ATOM 509 CB BHIS A 64 -0.409 -1.888 8.917 0.20 9.21 C
214 #ATOM 510 CG AHIS A 64 -0.736 -0.782 9.258 0.70 12.16 C
215 #ATOM 511 CG BHIS A 64 0.714 -0.964 8.521 0.20 8.70 C
216 #ATOM 512 ND1AHIS A 64 -1.795 -0.353 10.014 0.70 14.34 N
217 #ATOM 513 ND1BHIS A 64 0.513 0.338 8.162 0.20 8.57 N
218 #ATOM 514 CD2AHIS A 64 -0.117 0.344 8.805 0.70 12.79 C
219 #ATOM 515 CD2BHIS A 64 2.037 -1.198 8.364 0.20 8.90 C
220 #ATOM 516 CE1AHIS A 64 -1.809 0.971 10.061 0.70 13.80 C
221 #ATOM 517 CE1BHIS A 64 1.691 0.868 7.814 0.20 8.65 C
222 #ATOM 518 NE2AHIS A 64 -0.844 1.403 9.281 0.70 15.45 N
223 #ATOM 519 NE2BHIS A 64 2.615 -0.026 7.936 0.20 6.94 N
224 #';
225 #
226 #my $ATOM_record_format = '
227 #Record Format: http://www.wwpdb.org/documentation/format23/sect9.html
228 #COLUMNS DATA TYPE FIELD DEFINITION
229 #------------------------------------------------------
230 # 1 - 6 Record name "ATOM "
231 # 7 - 11 Integer serial Atom serial number.
232 #13 - 16 Atom name Atom name.
233 #17 Character altLoc Alternate location indicator.
234 #18 - 20 Residue name resName Residue name.
235 #22 Character chainID Chain identifier.
236 #23 - 26 Integer resSeq Residue sequence number.
237 #27 AChar iCode Code for insertion of residues.
238 #31 - 38 Real(8.3) x Orthogonal coordinates for X in
239 # Angstroms
240 #39 - 46 Real(8.3) y Orthogonal coordinates for Y in
241 # Angstroms
242 #47 - 54 Real(8.3) z Orthogonal coordinates for Z in
243 # Angstroms
244 #55 - 60 Real(6.2) occupancy Occupancy.
245 #61 - 66 Real(6.2) tempFactor Temperature factor.
246 #77 - 78 LString(2) element Element symbol, right-justified.
247 #79 - 80 LString(2) charge Charge on the atom.
248 #';
249 #
250  
251 __END__
252  
253 =pod
254  
255 =head1 NAME
256  
257 HackaMol::Roles::PdbRole - PdbRole of lazy attributes for HackaMol atoms
258  
259 =head1 VERSION
260  
261 version 0.051
262  
263 =head1 SYNOPSIS
264  
265 use HackaMol::Atom;
266  
267 my $atom = Atom->new(Z=>6);
268  
269 print $atom->$_ foreach ( qw(
270 record_name
271 serial
272 occ
273 bfact
274 resname
275 chain
276 altloc
277 resid
278 iatom
279 pdbid
280 segid
281 )
282 );
283
284 foreach my $resn (qw(TRP TYR GLN ASN ETC)){
285 $atom->resname($resn);
286 print $atom->aa321;
287 }
288  
289 =head1 DESCRIPTION
290  
291 PdbRole provides atom attributes for PDB parsing. All attributes are 'rw' and
292 lazy, so they will not contaminate the namespace unless called upon. The
293 functionality of the PdbRole may be extended in the future. An extension
294 (HackaMolX::PDB or HackaMol::X::PDB) will be released soon.
295  
296 =head1 METHODS
297  
298 =head2 pdb_rename
299  
300 no arguments. Returns the current name. Renames the atom based on names used by the PDB (if exists). This is useful for programs that render the secondary structure of molecules.
301  
302 =head2 aa321
303  
304 returns 1 letter code for amino acid. Generated from resname attribute. throws a warning and returns 'X' if residue name is unrecognized.
305  
306 =head1 ATTRIBUTES
307  
308 =head2 record_name
309  
310 pdb cols 1-6: ATOM|HETATM. default = 'HETATM'
311  
312 =head2 serial
313  
314 pdb cols 7-11: index. default = 0
315  
316 =head2 occ
317  
318 pdb cols 55-60: occupancy. range 0 to 1. default = 1.0 (all there)
319  
320 =head2 bfact
321  
322 pdb cols 61-66: temperature factor. see Willis and Pryor. default = 20.0
323  
324 =head2 altloc
325  
326 pdb col 17. is AHIS and BHIS above. default = ' '
327  
328 =head2 resname
329  
330 pdb cols 18-20: residue name. defaults to 'ALA'
331  
332 =head2 chain
333  
334 pdb cols 22. protein chain. default = ' '
335  
336 =head2 resid
337  
338 pdb cols 23-26. residue index. PDB calls is resSeq, but resid is more familiar
339 (to me). default = 64
340  
341 =head2 icode
342  
343 pdb cols 27. see code comments or
344 L<http://www.wwpdb.org/documentation/format23/sect9.html>
345  
346 =head2 pdbid
347  
348 a place to store which PDB it came from
349  
350 =head2 segid
351  
352 a CHARMMish parameter that may not belong here. default = 'TIP3'
353  
354 =head2 iatom
355  
356 this is a place for the actual index. Segid does not have to start from 0 (cut
357 and paste as above, etc).
358  
359 =head2 sasa
360  
361 Solvent accessible surface area; isa 'Num'. A place for storing results from such calculations.
362  
363 =head1 SEE ALSO
364  
365 =over 4
366  
367 =item *
368  
369 L<http://www.pdb.org>
370  
371 =item *
372  
373 L<Bio::PDB::Structure::Atom>
374  
375 =back
376  
377 =head1 AUTHOR
378  
379 Demian Riccardi <demianriccardi@gmail.com>
380  
381 =head1 COPYRIGHT AND LICENSE
382  
383 This software is copyright (c) 2017 by Demian Riccardi.
384  
385 This is free software; you can redistribute it and/or modify it under
386 the same terms as the Perl 5 programming language system itself.
387  
388 =cut
« HackaMol/Roles/NERFRole.pm ↑ Summary HackaMol/Angle.pm »