| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# $Id: APO_ID.pm 2010-09-29 erick.antezana $ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Module : APO_ID.pm |
|
4
|
|
|
|
|
|
|
# Purpose : A APO_ID. |
|
5
|
|
|
|
|
|
|
# License : Copyright (c) 2006-2014 by Erick Antezana. All rights reserved. |
|
6
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
|
7
|
|
|
|
|
|
|
# modify it under the same terms as Perl itself. |
|
8
|
|
|
|
|
|
|
# Contact : Erick Antezana |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package OBO::APO::APO_ID; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
OBO::APO::APO_ID - A module for describing Application Ontology (APO) identifiers. Its idspace, subnamespace and localID are stored. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
use OBO::APO::APO_ID; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$id = APO_ID->new(); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
$id->idspace("APO"); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$id->subnamespace("X"); |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$id->localID("0000001"); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$idspace = $id->idspace(); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$subnamespace = $id->subnamespace(); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$localID = $id->localID(); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
print $id->id_as_string(); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$id->id_as_string("APO:P1234567"); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
The OBO::APO::APO_ID class implements an Application Ontology identifier. |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
A APO ID holds: IDSPACE, SUBNAMESPACE and a NUMBER in the following form: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
APO:[A-Z][a-z]?nnnnnnn |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
For instance: APO:Pa1234567 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
The SUBNAMESPACE may be one of the following: |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
C Cellular component |
|
52
|
|
|
|
|
|
|
F Molecular Function |
|
53
|
|
|
|
|
|
|
P Biological Process |
|
54
|
|
|
|
|
|
|
B Protein |
|
55
|
|
|
|
|
|
|
G Gene |
|
56
|
|
|
|
|
|
|
I Interaction |
|
57
|
|
|
|
|
|
|
R Reference |
|
58
|
|
|
|
|
|
|
T Taxon |
|
59
|
|
|
|
|
|
|
N Instance |
|
60
|
|
|
|
|
|
|
U Upper Level Ontology (APO) |
|
61
|
|
|
|
|
|
|
L Relationship type (e.g. is_a) |
|
62
|
|
|
|
|
|
|
Y Interaction type |
|
63
|
|
|
|
|
|
|
Z Unknown |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
plus an extra (optional) qualifier could be added to explicitly capture the organism: |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
a Arabidopsis thaliana |
|
68
|
|
|
|
|
|
|
h Homo sapiens |
|
69
|
|
|
|
|
|
|
y Saccharomyces cerevisiae |
|
70
|
|
|
|
|
|
|
s Schizosaccharomyces pombe |
|
71
|
|
|
|
|
|
|
c Caenorhabditis elegans |
|
72
|
|
|
|
|
|
|
d Drosophila melanogaster |
|
73
|
|
|
|
|
|
|
m Mus musculus |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 AUTHOR |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Erick Antezana, Eerick.antezana -@- gmail.comE |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Copyright (c) 2006-2014 by Erick Antezana |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
84
|
|
|
|
|
|
|
it under the same terms as Perl itself, either Perl version 5.8.7 or, |
|
85
|
|
|
|
|
|
|
at your option, any later version of Perl 5 you may have available. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
our @ISA = qw(OBO::XO::OBO_ID); |
|
90
|
3
|
|
|
3
|
|
4415
|
use OBO::XO::OBO_ID; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
81
|
|
|
91
|
3
|
|
|
3
|
|
11
|
use strict; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
66
|
|
|
92
|
3
|
|
|
3
|
|
10
|
use Carp; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
1214
|
|
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new { |
|
95
|
27
|
|
|
27
|
0
|
127
|
my $class = shift; |
|
96
|
27
|
|
|
|
|
28
|
my $self = {}; |
|
97
|
|
|
|
|
|
|
|
|
98
|
27
|
|
|
|
|
40
|
$self->{IDSPACE} = undef; # string |
|
99
|
27
|
|
|
|
|
30
|
$self->{SUBNAMESPACE} = undef; # subnamespace |
|
100
|
27
|
|
|
|
|
21
|
$self->{LOCALID} = undef; # 7 digits |
|
101
|
|
|
|
|
|
|
|
|
102
|
27
|
|
|
|
|
38
|
bless ($self, $class); |
|
103
|
27
|
|
|
|
|
41
|
return $self; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 subnamespace |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Usage - print $id->subnamespace() or $id->subnamespace($name) |
|
109
|
|
|
|
|
|
|
Returns - the subnamespace (string) |
|
110
|
|
|
|
|
|
|
Args - the subnamespace (string) |
|
111
|
|
|
|
|
|
|
Function - gets/sets the subnamespace |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub subnamespace { |
|
116
|
2
|
|
|
2
|
1
|
5
|
my ($self, $sns) = @_; |
|
117
|
2
|
50
|
|
|
|
4
|
if ($sns) { $self->{SUBNAMESPACE} = $sns } |
|
|
2
|
|
|
|
|
3
|
|
|
118
|
2
|
|
|
|
|
4
|
return $self->{SUBNAMESPACE}; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 id_as_string |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Usage - print $id->id_as_string() or $id->id_as_string("APO:X0000001") |
|
124
|
|
|
|
|
|
|
Returns - the id as string (scalar) |
|
125
|
|
|
|
|
|
|
Args - the id as string |
|
126
|
|
|
|
|
|
|
Function - gets/sets the id as string |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub id_as_string () { |
|
131
|
125
|
|
|
125
|
1
|
119
|
my ($self, $id_as_string) = @_; |
|
132
|
125
|
100
|
66
|
|
|
776
|
if ( defined $id_as_string && $id_as_string =~ /(APO):([A-Z][a-z]?)([0-9]{7})/ ) { |
|
|
|
100
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
133
|
23
|
|
|
|
|
48
|
$self->{IDSPACE} = $1; |
|
134
|
23
|
|
|
|
|
28
|
$self->{SUBNAMESPACE} = $2; |
|
135
|
23
|
|
|
|
|
109
|
$self->{LOCALID} = substr($3 + 10000000, 1, 7); # trick: forehead zeros |
|
136
|
|
|
|
|
|
|
} elsif ($self->{IDSPACE} && $self->{SUBNAMESPACE} && $self->{LOCALID}) { |
|
137
|
101
|
|
|
|
|
269
|
return $self->{IDSPACE}.':'.$self->{SUBNAMESPACE}.$self->{LOCALID}; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
*id = \&id_as_string; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 equals |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Usage - print $id->equals($id) |
|
145
|
|
|
|
|
|
|
Returns - 1 (true) or 0 (false) |
|
146
|
|
|
|
|
|
|
Args - the other ID (OBO::APO::APO_ID) |
|
147
|
|
|
|
|
|
|
Function - tells if two IDs are equal |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub equals () { |
|
152
|
1
|
|
|
1
|
1
|
5
|
my ($self, $target) = @_; |
|
153
|
1
|
|
33
|
|
|
14
|
return (($self->{IDSPACE} eq $target->{IDSPACE}) && |
|
154
|
|
|
|
|
|
|
($self->{SUBNAMESPACE} eq $target->{SUBNAMESPACE}) && |
|
155
|
|
|
|
|
|
|
($self->{LOCALID} == $target->{LOCALID})); |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 next_id |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Usage - $id->next_id() |
|
161
|
|
|
|
|
|
|
Returns - the next ID (OBO::APO::APO_ID) |
|
162
|
|
|
|
|
|
|
Args - none |
|
163
|
|
|
|
|
|
|
Function - returns the next ID, which is new |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub next_id () { |
|
168
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
169
|
1
|
|
|
|
|
3
|
my $next_id = OBO::APO::APO_ID->new(); |
|
170
|
1
|
|
|
|
|
3
|
$next_id->{IDSPACE} = $self->{IDSPACE}; |
|
171
|
1
|
|
|
|
|
1
|
$next_id->{SUBNAMESPACE} = $self->{SUBNAMESPACE}; |
|
172
|
1
|
|
|
|
|
3
|
$next_id->{LOCALID} = substr(10000001 + $self->{LOCALID}, 1, 7); # trick: forehead zeros |
|
173
|
1
|
|
|
|
|
6
|
return $next_id; |
|
174
|
|
|
|
|
|
|
} |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 previous_id |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Usage - $id->previous_id() |
|
179
|
|
|
|
|
|
|
Returns - the previous ID (OBO::APO::APO_ID) |
|
180
|
|
|
|
|
|
|
Args - none |
|
181
|
|
|
|
|
|
|
Function - returns the previous ID, which is new |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub previous_id () { |
|
186
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
187
|
1
|
|
|
|
|
2
|
my $previous_id = OBO::APO::APO_ID->new (); |
|
188
|
1
|
|
|
|
|
2
|
$previous_id->{IDSPACE} = $self->{IDSPACE}; |
|
189
|
1
|
|
|
|
|
2
|
$previous_id->{SUBNAMESPACE} = $self->{SUBNAMESPACE}; |
|
190
|
1
|
|
|
|
|
3
|
$previous_id->{LOCALID} = substr((10000000 + $self->{LOCALID}) - 1, 1, 7); # trick: forehead zeros |
|
191
|
1
|
|
|
|
|
3
|
return $previous_id; |
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
1; |