line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$HackaMol::Roles::MolReadRole::VERSION = '0.052'; |
2
|
|
|
|
|
|
|
# ABSTRACT: Read files with molecular information |
3
|
|
|
|
|
|
|
use Moose::Role; |
4
|
11
|
|
|
11
|
|
9569
|
use Carp; |
|
11
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
154
|
|
5
|
11
|
|
|
11
|
|
53939
|
use Math::Vector::Real; |
|
11
|
|
|
|
|
32
|
|
|
11
|
|
|
|
|
745
|
|
6
|
11
|
|
|
11
|
|
87
|
use HackaMol::PeriodicTable qw(%KNOWN_NAMES); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
540
|
|
7
|
11
|
|
|
11
|
|
84
|
use FileHandle; |
|
11
|
|
|
|
|
37
|
|
|
11
|
|
|
|
|
1346
|
|
8
|
11
|
|
|
11
|
|
78
|
use YAML::XS qw(LoadFile); |
|
11
|
|
|
|
|
19
|
|
|
11
|
|
|
|
|
105
|
|
9
|
11
|
|
|
11
|
|
8754
|
use HackaMol::Atom; #add the code,the Role may better to understand |
|
11
|
|
|
|
|
29604
|
|
|
11
|
|
|
|
|
653
|
|
10
|
11
|
|
|
11
|
|
108
|
|
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
6684
|
|
11
|
|
|
|
|
|
|
with qw( |
12
|
|
|
|
|
|
|
HackaMol::Roles::ReadYAMLRole |
13
|
|
|
|
|
|
|
HackaMol::Roles::ReadZmatRole |
14
|
|
|
|
|
|
|
HackaMol::Roles::ReadPdbRole |
15
|
|
|
|
|
|
|
HackaMol::Roles::ReadPdbxRole |
16
|
|
|
|
|
|
|
HackaMol::Roles::ReadPdbqtRole |
17
|
|
|
|
|
|
|
HackaMol::Roles::ReadXyzRole |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has 'hush_read' => ( |
21
|
|
|
|
|
|
|
is => 'rw', |
22
|
|
|
|
|
|
|
isa => 'Int', |
23
|
|
|
|
|
|
|
lazy => 1, |
24
|
|
|
|
|
|
|
default => 0, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
my $string = shift; |
30
|
6
|
|
|
6
|
1
|
16
|
my $type = shift or croak "must pass format: xyz, pdb, cif, pdbqt, zmat, yaml"; |
31
|
6
|
|
|
|
|
10
|
|
32
|
6
|
50
|
|
|
|
16
|
open (my $fh, '<', \$string) or croak "unable to open string"; |
33
|
|
|
|
|
|
|
|
34
|
6
|
50
|
|
3
|
|
426
|
my $atoms; |
|
3
|
|
|
|
|
27
|
|
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
23
|
|
35
|
|
|
|
|
|
|
|
36
|
6
|
|
|
|
|
2631
|
if ( $type eq 'pdb' ) { |
37
|
|
|
|
|
|
|
($atoms) = $self->read_pdb_atoms($fh); |
38
|
6
|
100
|
|
|
|
37
|
} |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
39
|
3
|
|
|
|
|
15
|
elsif ( $type eq 'pdbqt') { |
40
|
|
|
|
|
|
|
$atoms = $self->read_pdbqt_atoms($fh); |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
0
|
elsif ( $type eq 'xyz') { |
43
|
|
|
|
|
|
|
$atoms = $self->read_xyz_atoms($fh); |
44
|
|
|
|
|
|
|
} |
45
|
2
|
|
|
|
|
17
|
elsif ( $type eq 'zmat') { |
46
|
|
|
|
|
|
|
$atoms = $self->read_zmat_atoms($fh); |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
0
|
elsif ( $type eq 'cif') { |
49
|
|
|
|
|
|
|
$atoms = $self->read_cif_atoms($fh); |
50
|
|
|
|
|
|
|
} |
51
|
1
|
|
|
|
|
10
|
elsif ( $type eq 'yaml') { |
52
|
|
|
|
|
|
|
$fh->close; |
53
|
|
|
|
|
|
|
$fh = Loadtype($type); |
54
|
0
|
|
|
|
|
0
|
$atoms = $self->read_yaml_atoms($fh); |
55
|
0
|
|
|
|
|
0
|
} |
56
|
0
|
|
|
|
|
0
|
else { |
57
|
|
|
|
|
|
|
croak "$type format not supported"; |
58
|
|
|
|
|
|
|
} |
59
|
0
|
|
|
|
|
0
|
return (@{$atoms}); |
60
|
|
|
|
|
|
|
} |
61
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
68
|
|
62
|
|
|
|
|
|
|
my $self = shift; |
63
|
|
|
|
|
|
|
my $file = shift; |
64
|
|
|
|
|
|
|
|
65
|
1
|
|
|
1
|
0
|
2
|
my $fh = FileHandle->new("<$file") or croak "unable to open $file"; |
66
|
1
|
|
|
|
|
3
|
return $self->read_pdb_parts($fh); |
67
|
|
|
|
|
|
|
} |
68
|
1
|
50
|
|
|
|
14
|
|
69
|
1
|
|
|
|
|
171
|
# temporary, this is getting out of hand! |
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
my $file = shift; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $fh = FileHandle->new("<$file") or croak "unable to open $file"; |
74
|
0
|
|
|
0
|
0
|
0
|
my $info = $self->read_cif_info($fh); |
75
|
0
|
|
|
|
|
0
|
my @models = $self->read_cif_atoms($fh); |
76
|
|
|
|
|
|
|
#$info = $self->read_cif_info($fh,$info); |
77
|
0
|
0
|
|
|
|
0
|
my @mols = map { |
78
|
0
|
|
|
|
|
0
|
HackaMol::Molecule->new( |
79
|
0
|
|
|
|
|
0
|
name => "model." . $_->[0]->model_num, |
80
|
|
|
|
|
|
|
atoms => $_ |
81
|
|
|
|
|
|
|
) } @models; |
82
|
0
|
|
|
|
|
0
|
return ($info, \@mols); |
|
0
|
|
|
|
|
0
|
|
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my $self = shift; |
86
|
0
|
|
|
|
|
0
|
my $file = shift; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my $fh = FileHandle->new("<$file") or croak "unable to open $file"; |
89
|
|
|
|
|
|
|
|
90
|
24
|
|
|
24
|
1
|
3976
|
my $atoms; |
91
|
24
|
|
|
|
|
55
|
|
92
|
|
|
|
|
|
|
if ( $file =~ m/\.pdb$/ ) { |
93
|
24
|
100
|
|
|
|
238
|
($atoms) = $self->read_pdb_atoms($fh); |
94
|
|
|
|
|
|
|
} |
95
|
23
|
|
|
|
|
2571
|
elsif ( $file =~ m/\.pdbqt$/ ) { |
96
|
|
|
|
|
|
|
$atoms = $self->read_pdbqt_atoms($fh); |
97
|
23
|
100
|
|
|
|
217
|
} |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
98
|
11
|
|
|
|
|
90
|
elsif ( $file =~ m/\.cif$/ ) { |
99
|
|
|
|
|
|
|
$atoms = $self->read_cif_atoms($fh); |
100
|
|
|
|
|
|
|
} |
101
|
1
|
|
|
|
|
8
|
elsif ( $file =~ m/\.xyz$/ ) { |
102
|
|
|
|
|
|
|
$atoms = $self->read_xyz_atoms($fh); |
103
|
|
|
|
|
|
|
} |
104
|
0
|
|
|
|
|
0
|
elsif ( $file =~ m/\.zmat$/ ) { |
105
|
|
|
|
|
|
|
$atoms = $self->read_zmat_atoms($fh); |
106
|
|
|
|
|
|
|
} |
107
|
11
|
|
|
|
|
64
|
elsif ( $file =~ m/\.yaml$/) { |
108
|
|
|
|
|
|
|
$fh->close; |
109
|
|
|
|
|
|
|
$fh = LoadFile($file); |
110
|
0
|
|
|
|
|
0
|
$atoms = $self->read_yaml_atoms($fh); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
else { |
113
|
0
|
|
|
|
|
0
|
croak "$file format not supported"; |
114
|
0
|
|
|
|
|
0
|
} |
115
|
0
|
|
|
|
|
0
|
return (@{$atoms}); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
no Moose::Role; |
119
|
|
|
|
|
|
|
|
120
|
20
|
|
|
|
|
60
|
1; |
|
20
|
|
|
|
|
1460
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
11
|
|
|
11
|
|
86
|
=pod |
|
11
|
|
|
|
|
31
|
|
|
11
|
|
|
|
|
116
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 NAME |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
HackaMol::Roles::MolReadRole - Read files with molecular information |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 VERSION |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
version 0.052 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SYNOPSIS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use HackaMol; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $hack = HackaMol->new( name => "hackitup" ); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# build array of carbon atoms from pdb [xyz,pdbqt] file |
140
|
|
|
|
|
|
|
my @carbons = grep { |
141
|
|
|
|
|
|
|
$_->symbol eq "C" |
142
|
|
|
|
|
|
|
} $hack->read_file_atoms("t/lib/1L2Y.pdb"); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
my $Cmol = HackaMol::Molecule->new( |
145
|
|
|
|
|
|
|
name => "carbonprotein", |
146
|
|
|
|
|
|
|
atoms => [ @carbons ] |
147
|
|
|
|
|
|
|
); |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
$Cmol->print_pdb; |
150
|
|
|
|
|
|
|
$Cmol->print_xyz; |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# build molecule from xyz [pdb,pdbqt] file |
153
|
|
|
|
|
|
|
my $mol = $hack->read_file_mol("some.xyz"); |
154
|
|
|
|
|
|
|
$mol->print_pdb; # |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head1 DESCRIPTION |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
The HackaMol::Role::MolReadRole role provides methods for reading common structural files. Currently, |
159
|
|
|
|
|
|
|
pdb, pdbqt, Z-matrix, and xyz are provided. The methods are all provided in separate roles. Adding |
160
|
|
|
|
|
|
|
additional formats is straightforward: |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
1. Add a Role that parses the file and returns a list of HackaMol::Atoms. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
2. Add the code here to consume the role and call the method based on the file ending. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 METHODS |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 read_file_atoms |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
one argument: the name of a file (.xyz, .pdb, .pdbqt, .zmat) |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
returns a list of HackaMol::Atom objects |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 read_string_atoms |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
two arguments: 1. a string with coordinates properly formatted; 2. format (xyz, pdb, pdbqt, zmat, yaml) |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
returns a list of HackaMol::Atom objects |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=head2 hush_read |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
isa Int that is lazy (default 0). $hack->hush_read(1) will quiet some warnings that may be ignored under some instances. |
185
|
|
|
|
|
|
|
$hack->hush_read(-1) will increase info printed out for some warnings. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 SEE ALSO |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=over 4 |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=item * |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
L<HackaMol> |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
L<HackaMol::Roles::ReadXyzRole> |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=item * |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
L<HackaMol::Roles::ReadPdbRole> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item * |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
L<HackaMol::Roles::ReadPdbqtRole> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item * |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
L<HackaMol::Roles::ReadZmatRole> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=item * |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
L<HackaMol::Atom> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
=item * |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
L<HackaMol::Molecule> |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=back |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 CONSUMES |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over 4 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::NERFRole> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadPdbRole> |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadPdbqtRole> |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadPdbxRole> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadXyzRole> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadYAMLRole> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadYAMLRole|HackaMol::Roles::ReadZmatRole|HackaMol::Roles::ReadPdbRole|HackaMol::Roles::ReadPdbxRole|HackaMol::Roles::ReadPdbqtRole|HackaMol::Roles::ReadXyzRole> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * L<HackaMol::Roles::ReadZmatRole> |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=back |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 AUTHOR |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Demian Riccardi <demianriccardi@gmail.com> |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Demian Riccardi. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
252
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |