line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: IDspace.pm 2011-09-29 erick.antezana $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Module : IDspace.pm |
4
|
|
|
|
|
|
|
# Purpose : A mapping between a "local" ID space and a "global" ID space. |
5
|
|
|
|
|
|
|
# License : Copyright (c) 2006-2015 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
|
|
|
|
|
|
|
package OBO::Core::IDspace; |
11
|
|
|
|
|
|
|
|
12
|
9
|
|
|
9
|
|
11660
|
use Carp; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
537
|
|
13
|
9
|
|
|
9
|
|
43
|
use strict; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
182
|
|
14
|
9
|
|
|
9
|
|
43
|
use warnings; |
|
9
|
|
|
|
|
15
|
|
|
9
|
|
|
|
|
6036
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub new { |
17
|
19
|
|
|
19
|
0
|
108
|
my $class = shift; |
18
|
19
|
|
|
|
|
32
|
my $self = {}; |
19
|
|
|
|
|
|
|
|
20
|
19
|
|
|
|
|
52
|
$self->{LOCAL_IDSPACE} = ''; # required, scalar (1) |
21
|
19
|
|
|
|
|
34
|
$self->{URI} = ''; # required, scalar (1) |
22
|
19
|
|
|
|
|
35
|
$self->{DESCRIPTION} = undef; # optional scalar (0..1) |
23
|
|
|
|
|
|
|
|
24
|
19
|
|
|
|
|
36
|
bless ($self, $class); |
25
|
19
|
|
|
|
|
46
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 local_idspace |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Usage - print $idspace->local_idspace() or $idspace->local_idspace($local_idspace) |
31
|
|
|
|
|
|
|
Returns - the local ID space (string) |
32
|
|
|
|
|
|
|
Args - the local ID space (string) |
33
|
|
|
|
|
|
|
Function - gets/sets the local ID space |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub local_idspace { |
38
|
10
|
100
|
|
10
|
1
|
57
|
if ($_[1]) { |
39
|
5
|
|
|
|
|
24
|
$_[0]->{LOCAL_IDSPACE} = $_[1]; |
40
|
|
|
|
|
|
|
} else { # get-mode |
41
|
5
|
50
|
|
|
|
21
|
croak 'The local ID space of this ID space is not defined.' if (!defined($_[0]->{LOCAL_IDSPACE})); |
42
|
|
|
|
|
|
|
} |
43
|
10
|
|
|
|
|
51
|
return $_[0]->{LOCAL_IDSPACE}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 uri |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Usage - print $idspace->uri() or $idspace->uri($uri) |
49
|
|
|
|
|
|
|
Returns - the URI (string) of this ID space |
50
|
|
|
|
|
|
|
Args - the URI (string) of this ID space |
51
|
|
|
|
|
|
|
Function - gets/sets the URI of this ID space |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub uri { |
56
|
7
|
100
|
|
7
|
1
|
27
|
if ($_[1]) { |
57
|
5
|
|
|
|
|
13
|
$_[0]->{URI} = $_[1]; |
58
|
|
|
|
|
|
|
} else { # get-mode |
59
|
2
|
50
|
|
|
|
9
|
croak 'The URI of this ID space is not defined.' if (!defined($_[0]->{URI})); |
60
|
|
|
|
|
|
|
} |
61
|
7
|
|
|
|
|
29
|
return $_[0]->{URI}; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 description |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Usage - print $idspace->description() or $idspace->description($description) |
67
|
|
|
|
|
|
|
Returns - the idspace description (string) |
68
|
|
|
|
|
|
|
Args - the idspace description (string) |
69
|
|
|
|
|
|
|
Function - gets/sets the idspace description |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub description { |
74
|
7
|
100
|
|
7
|
1
|
22
|
if ($_[1]) { |
75
|
5
|
|
|
|
|
13
|
$_[0]->{DESCRIPTION} = $_[1]; |
76
|
|
|
|
|
|
|
} else { # get-mode |
77
|
2
|
50
|
33
|
|
|
14
|
croak 'Neither the local idspace nor the URI of this idspace is defined.' if (!defined($_[0]->{LOCAL_IDSPACE}) || !defined($_[0]->{URI})); |
78
|
|
|
|
|
|
|
} |
79
|
7
|
|
|
|
|
21
|
return $_[0]->{DESCRIPTION}; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 as_string |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Usage - print $idspace->as_string() |
85
|
|
|
|
|
|
|
Returns - returns this idspace (local_idspace uri "description") as string if it is defined; otherwise, undef |
86
|
|
|
|
|
|
|
Args - none |
87
|
|
|
|
|
|
|
Function - returns this idspace as string |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub as_string { |
92
|
21
|
100
|
66
|
21
|
1
|
132
|
if ($_[1] && $_[2]){ |
93
|
12
|
|
|
|
|
38
|
$_[0]->{LOCAL_IDSPACE} = $_[1]; |
94
|
12
|
|
|
|
|
20
|
$_[0]->{URI} = $_[2]; |
95
|
12
|
50
|
|
|
|
39
|
$_[0]->{DESCRIPTION} = $_[3] if ($_[3]); |
96
|
12
|
|
|
|
|
24
|
return; # set mode |
97
|
|
|
|
|
|
|
} else { |
98
|
9
|
50
|
33
|
|
|
59
|
croak 'Neither the local idspace nor the URI of this idspace is defined.' if (!defined($_[0]->{LOCAL_IDSPACE}) || !defined($_[0]->{URI})); |
99
|
9
|
|
|
|
|
31
|
my $result = $_[0]->{LOCAL_IDSPACE}.' '.$_[0]->{URI}; |
100
|
9
|
100
|
66
|
|
|
87
|
$result .= ' "'.$_[0]->{DESCRIPTION}.'"' if (defined $_[0]->{DESCRIPTION} && $_[0]->{DESCRIPTION} ne ''); |
101
|
9
|
100
|
|
|
|
69
|
$result = '' if ($result =~ /^\s*$/); |
102
|
9
|
|
|
|
|
42
|
return $result; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 equals |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Usage - print $idspace->equals($another_idspace) |
109
|
|
|
|
|
|
|
Returns - either 1(true) or 0 (false) |
110
|
|
|
|
|
|
|
Args - the idspace (OBO::Core::IDspace) to compare with |
111
|
|
|
|
|
|
|
Function - tells whether this idspace is equal to the parameter |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub equals { |
116
|
100
|
50
|
33
|
100
|
1
|
292
|
if ($_[1] && eval { $_[1]->isa('OBO::Core::IDspace') }) { |
|
100
|
|
|
|
|
534
|
|
117
|
|
|
|
|
|
|
|
118
|
100
|
50
|
33
|
|
|
376
|
croak 'Neither the local idspace or the URI of this idspace is defined.' if (!defined($_[0]->{LOCAL_IDSPACE}) || !defined($_[0]->{URI})); |
119
|
100
|
50
|
33
|
|
|
349
|
croak 'Neither the local idspace or the URI of this idspace is defined.' if (!defined($_[1]->{LOCAL_IDSPACE}) || !defined($_[1]->{URI})); |
120
|
100
|
|
100
|
|
|
612
|
my $result = ((defined $_[0]->{DESCRIPTION} && defined $_[1]->{DESCRIPTION}) && ($_[0]->{DESCRIPTION} eq $_[1]->{DESCRIPTION})); |
121
|
|
|
|
|
|
|
return $result && (($_[0]->{LOCAL_IDSPACE} eq $_[1]->{LOCAL_IDSPACE}) && |
122
|
100
|
|
66
|
|
|
615
|
($_[0]->{URI} eq $_[1]->{URI})); |
123
|
|
|
|
|
|
|
} else { |
124
|
0
|
|
|
|
|
|
croak "An unrecognized object type (not a OBO::Core::IDspace) was found: '", $_[1], "'"; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
|
|
|
|
|
return 0; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
__END__ |