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