| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Chemistry::File::InChI; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
15796
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
67
|
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
145
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
11
|
use base 'Chemistry::File'; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
1294
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
62348
|
use Chemistry::File::InChI::Parser; |
|
|
2
|
|
|
|
|
11
|
|
|
|
2
|
|
|
|
|
580
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: InChI identifier reader |
|
11
|
|
|
|
|
|
|
our $VERSION = '0.10'; # VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Chemistry::File::InChI - InChI identifier reader |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use Chemistry::File::InChI; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# read a molecule |
|
22
|
|
|
|
|
|
|
my $mol = Chemistry::Mol->parse('InChI=1S/H2N2/c1-2/h1-2H', format => 'inchi'); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
InChI identifier reader written according to L. |
|
27
|
|
|
|
|
|
|
Only formula, C, C, C, C and C layers are supported at the moment. |
|
28
|
|
|
|
|
|
|
Certain InChI concepts do not map into the concepts of C, thus they are stored as molecule and atom attributes. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Count multiplier of a molecule is stored in molecule attribute C. |
|
31
|
|
|
|
|
|
|
Stereochemistry setting of C<1> or C<2> is stored in molecule attribute C. |
|
32
|
|
|
|
|
|
|
Charges are stored in molecule attribute C. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Tetrahedral center setting C<+> or C<-> is stored in atom attribute C. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Chemistry::Mol->register_format(inchi => __PACKAGE__); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub read_mol |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
60
|
|
|
60
|
1
|
607038
|
my ($self, $fh, %opts) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
60
|
|
|
|
|
337
|
my $line = <$fh>; |
|
45
|
60
|
100
|
|
|
|
285
|
return unless defined $line; |
|
46
|
30
|
|
|
|
|
127
|
$line =~ s/\r\n//g; |
|
47
|
|
|
|
|
|
|
|
|
48
|
30
|
|
|
|
|
301
|
my $parser = Chemistry::File::InChI::Parser->new; |
|
49
|
30
|
|
|
|
|
140
|
return $parser->parse( $line ); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub name_is { |
|
53
|
0
|
|
|
0
|
1
|
|
my ($self, $fname) = @_; |
|
54
|
0
|
|
|
|
|
|
$fname =~ /\.inchi$/i; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub file_is { |
|
58
|
0
|
|
|
0
|
1
|
|
my ($self, $fname) = @_; |
|
59
|
0
|
|
|
|
|
|
$fname =~ /\.inchi$/i; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 SOURCE CODE REPOSITORY |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
L |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
L, L |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
InChI grammar L |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 AUTHOR |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Andrius Merkys |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copyright (c) 2022-2026 Andrius Merkys. All rights reserved. This program is |
|
79
|
|
|
|
|
|
|
free software; you can redistribute it and/or modify it under the same terms as |
|
80
|
|
|
|
|
|
|
Perl itself. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |