line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
$HackaMol::Roles::ReadXyzRole::VERSION = '0.053'; |
2
|
|
|
|
|
|
|
# ABSTRACT: Read files with molecular information |
3
|
|
|
|
|
|
|
use Moose::Role; |
4
|
11
|
|
|
11
|
|
5407
|
use Carp; |
|
11
|
|
|
|
|
29
|
|
|
11
|
|
|
|
|
75
|
|
5
|
11
|
|
|
11
|
|
47741
|
use Math::Vector::Real; |
|
11
|
|
|
|
|
26
|
|
|
11
|
|
|
|
|
599
|
|
6
|
11
|
|
|
11
|
|
66
|
use FileHandle; |
|
11
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
442
|
|
7
|
11
|
|
|
11
|
|
80
|
|
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
103
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
#read xyz file and generate list of Atom objects |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
my $fh = shift; |
12
|
13
|
|
|
13
|
1
|
31
|
# my $file = shift; |
13
|
13
|
|
|
|
|
24
|
# my $fh = FileHandle->new("<$file") or croak "unable to open $file"; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my @atoms; |
16
|
|
|
|
|
|
|
my ( $n, $t ) = ( 0, 0 ); |
17
|
13
|
|
|
|
|
26
|
|
18
|
13
|
|
|
|
|
38
|
my $nat = undef; |
19
|
|
|
|
|
|
|
while (<$fh>) { |
20
|
13
|
|
|
|
|
27
|
|
21
|
13
|
|
|
|
|
412
|
if (/^(\s*\d+\s*)$/) { |
22
|
|
|
|
|
|
|
$n = (split)[0]; |
23
|
669
|
100
|
|
|
|
4098
|
if ( defined($nat) ) { |
|
|
100
|
|
|
|
|
|
24
|
16
|
|
|
|
|
67
|
croak "number of atoms has changed\n" unless ( $nat == $n ); |
25
|
16
|
100
|
|
|
|
50
|
$t++; |
26
|
5
|
100
|
|
|
|
25
|
} |
27
|
4
|
|
|
|
|
8
|
$nat = $n; |
28
|
|
|
|
|
|
|
$n = 0; |
29
|
15
|
|
|
|
|
37
|
} |
30
|
15
|
|
|
|
|
65
|
elsif (/(\w+|\d+)(\s+-*\d+\.\d+){3}/) { |
31
|
|
|
|
|
|
|
my @stuff = split; |
32
|
|
|
|
|
|
|
my $sym = $stuff[0]; |
33
|
638
|
|
|
|
|
1638
|
my $xyz = V( @stuff[ 1, 2, 3 ] ); |
34
|
638
|
|
|
|
|
864
|
if ( $t == 0 ) { |
35
|
638
|
|
|
|
|
3115
|
if ( $sym =~ /\d/ ) { |
36
|
638
|
100
|
|
|
|
1194
|
$atoms[$n] = HackaMol::Atom->new( |
37
|
624
|
100
|
|
|
|
1154
|
name => "at$n", |
38
|
12
|
|
|
|
|
299
|
Z => $sym, |
39
|
|
|
|
|
|
|
coords => [$xyz] |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
else { |
43
|
|
|
|
|
|
|
$atoms[$n] = HackaMol::Atom->new( |
44
|
|
|
|
|
|
|
name => "at$n", |
45
|
612
|
|
|
|
|
13971
|
symbol => $sym, |
46
|
|
|
|
|
|
|
coords => [$xyz] |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else { |
51
|
|
|
|
|
|
|
if ( $sym =~ /\d/ ) { |
52
|
|
|
|
|
|
|
croak "atoms have changed from last model to current: $t\n" |
53
|
14
|
100
|
|
|
|
38
|
if ( $sym != $atoms[$n]->Z ); |
54
|
10
|
100
|
|
|
|
218
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
|
|
|
|
|
|
croak "atoms have changed from last model to current: $t\n" |
57
|
|
|
|
|
|
|
if ( $sym ne $atoms[$n]->symbol ); |
58
|
4
|
100
|
|
|
|
92
|
} |
59
|
|
|
|
|
|
|
$atoms[$n]->set_coords( $t, $xyz ); |
60
|
|
|
|
|
|
|
|
61
|
12
|
|
|
|
|
328
|
} |
62
|
|
|
|
|
|
|
$n++; |
63
|
|
|
|
|
|
|
} |
64
|
636
|
|
|
|
|
3565
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# set iatom to track the array. diff from serial which refers to pdb |
67
|
|
|
|
|
|
|
$atoms[$_]->iatom($_) foreach ( 0 .. $#atoms ); |
68
|
|
|
|
|
|
|
return (\@atoms); |
69
|
10
|
|
|
|
|
356
|
} |
70
|
10
|
|
|
|
|
72
|
|
71
|
|
|
|
|
|
|
no Moose::Role; |
72
|
|
|
|
|
|
|
|
73
|
11
|
|
|
11
|
|
8071
|
1; |
|
11
|
|
|
|
|
30
|
|
|
11
|
|
|
|
|
67
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
HackaMol::Roles::ReadXyzRole - Read files with molecular information |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.053 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SYNOPSIS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
my @atoms = HackaMol->new |
89
|
|
|
|
|
|
|
->read_xyz_atoms("some.xyz"); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 DESCRIPTION |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
The HackaMol::Roles::ReadXyzRole provides read_xyz_atoms reading xyz files. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 read_xyz_atoms |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
One argument: the filename |
100
|
|
|
|
|
|
|
Returns a list of HackaMol::Atom objects. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SEE ALSO |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
L<HackaMol> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
L<HackaMol::Atom> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
L<HackaMol::Roles::MolReadRole> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 AUTHOR |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Demian Riccardi <demianriccardi@gmail.com> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Demian Riccardi. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
129
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |