line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: OBO_ID_Set.pm 2010-09-29 erick.antezana $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Module : OBO_ID_Set.pm |
4
|
|
|
|
|
|
|
# Purpose : A set of OBO id's. |
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::XO::OBO_ID_Set; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw(OBO::Util::ObjectSet); |
14
|
5
|
|
|
5
|
|
6276
|
use OBO::Util::ObjectSet; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
145
|
|
15
|
5
|
|
|
5
|
|
1505
|
use OBO::XO::OBO_ID; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
101
|
|
16
|
|
|
|
|
|
|
|
17
|
5
|
|
|
5
|
|
22
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
226
|
|
18
|
5
|
|
|
5
|
|
17
|
use strict; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
99
|
|
19
|
5
|
|
|
5
|
|
19
|
use warnings; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
1358
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 add_as_string |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Usage - $set->add_as_string($id) |
24
|
|
|
|
|
|
|
Returns - the added id (OBO::XO::OBO_ID) |
25
|
|
|
|
|
|
|
Args - the OBO id (string) to be added |
26
|
|
|
|
|
|
|
Function - adds an OBO_ID to this set |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub add_as_string () { |
31
|
29
|
|
|
29
|
1
|
27
|
my ($self, $id_as_string) = @_; |
32
|
29
|
|
|
|
|
24
|
my $result; |
33
|
29
|
50
|
|
|
|
40
|
if ($id_as_string) { |
34
|
29
|
|
|
|
|
56
|
my $new_obo_id_obj = OBO::XO::OBO_ID->new(); |
35
|
29
|
|
|
|
|
43
|
$new_obo_id_obj->id_as_string($id_as_string); |
36
|
29
|
|
|
|
|
52
|
$result = $self->add($new_obo_id_obj); |
37
|
|
|
|
|
|
|
} |
38
|
29
|
|
|
|
|
42
|
return $result; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 add_all_as_string |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Usage - $set->add_all_as_string($id1, $id2, ...) |
44
|
|
|
|
|
|
|
Returns - the last added id (OBO::XO::OBO_ID) |
45
|
|
|
|
|
|
|
Args - the id(s) (strings) to be added |
46
|
|
|
|
|
|
|
Function - adds a series of OBO_IDs to this set |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub add_all_as_string () { |
51
|
5
|
|
|
5
|
1
|
58
|
my $self = shift; |
52
|
5
|
|
|
|
|
6
|
my $result; |
53
|
5
|
|
|
|
|
14
|
foreach (@_) { |
54
|
32
|
|
|
|
|
48
|
$result = $self->add_as_string ($_); |
55
|
|
|
|
|
|
|
} |
56
|
5
|
|
|
|
|
9
|
return $result; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 get_new_id |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Usage - $set->get_new_id($idspace) |
62
|
|
|
|
|
|
|
Returns - a new OBO id (string) |
63
|
|
|
|
|
|
|
Args - none |
64
|
|
|
|
|
|
|
Function - returns a new OBO ID as string and adds this id to the set |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_new_id { |
69
|
0
|
|
|
0
|
1
|
|
my ($self, $local_idspace) = @_; |
70
|
0
|
|
|
|
|
|
my $new_obo_id = OBO::XO::OBO_ID->new(); |
71
|
0
|
0
|
|
|
|
|
croak 'The local idspace is invalid: ', $local_idspace if ($local_idspace !~ /\w+/); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
$new_obo_id->idspace($local_idspace); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
# get the last 'localID' |
77
|
|
|
|
|
|
|
# |
78
|
0
|
0
|
|
|
|
|
if ($self->is_empty()){ |
79
|
0
|
|
|
|
|
|
$new_obo_id->localID('0000001'); # use 7 'numeric placeholders' |
80
|
|
|
|
|
|
|
} else { |
81
|
0
|
|
|
|
|
|
my @arr = sort {$a cmp $b} keys %{$self->{MAP}}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
$new_obo_id->localID( $self->{MAP}->{$arr[$#arr]}->localID() ); |
83
|
|
|
|
|
|
|
} |
84
|
0
|
|
|
|
|
|
while (!defined ($self -> add( $new_obo_id = $new_obo_id->next_id() ))) {} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return $new_obo_id->id_as_string (); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |