line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# @File CUI.pm |
4
|
|
|
|
|
|
|
# @Author andriy |
5
|
|
|
|
|
|
|
# @Created Jun 27, 2016 1:16:36 PM |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
9
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
308
|
|
10
|
|
|
|
|
|
|
package CUI; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
0
|
|
|
0
|
|
|
my $class = shift;; |
14
|
0
|
|
|
|
|
|
my $self = { |
15
|
|
|
|
|
|
|
_ID => shift, |
16
|
|
|
|
|
|
|
_preferredname => shift, |
17
|
|
|
|
|
|
|
_strength => 0, |
18
|
|
|
|
|
|
|
_pathlength => -1, |
19
|
|
|
|
|
|
|
_prevCUI => 0, |
20
|
|
|
|
|
|
|
_prevPredicate => 0, |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
}; |
23
|
0
|
|
|
|
|
|
bless $self, $class; |
24
|
0
|
|
|
|
|
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
#returns id of cui |
27
|
|
|
|
|
|
|
sub getId { |
28
|
0
|
|
|
0
|
|
|
return shift->{_ID}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
#returns preferred name of cui |
31
|
|
|
|
|
|
|
sub getPreferredName { |
32
|
0
|
|
|
0
|
|
|
return shift->{_preferredname}; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#returns aggregate path length, -1 if vertex has not been reached |
36
|
|
|
|
|
|
|
sub getPathLength(){ |
37
|
0
|
|
|
0
|
|
|
return shift->{_pathlength}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub getStrength(){ |
41
|
0
|
|
|
0
|
|
|
return shift->{_strength}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#updates aggregate path length |
45
|
|
|
|
|
|
|
sub setPathLength(){ |
46
|
0
|
|
|
0
|
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
$self->{_pathlength} = shift; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub setPrevCUI(){ |
52
|
0
|
|
|
0
|
|
|
my $self = shift; |
53
|
0
|
|
|
|
|
|
$self->{_prevCUI} = shift; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub setStrength(){ |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
$self->{_strength} = shift; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub getPrevCUI(){ |
62
|
0
|
|
|
0
|
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
return $self->{_prevCUI}; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub setPrevPredicate{ |
67
|
0
|
|
|
0
|
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
$self->{_prevPredicate} = shift; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub getPath{ |
72
|
0
|
|
|
0
|
|
|
my $self = shift; |
73
|
0
|
|
|
|
|
|
my $length = $self->{_pathlength}; |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $path = $self->getPreferredName(); |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
while($self->getPrevCUI()){ |
78
|
0
|
|
|
|
|
|
$path = $self->getPrevCUI()->getPreferredName() . " ".$self->{_prevPredicate}." ".$path; |
79
|
0
|
|
|
|
|
|
$self = $self->getPrevCUI(); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
return $path; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
#test method for printing |
86
|
|
|
|
|
|
|
sub _print{ |
87
|
0
|
|
|
0
|
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
print $self->{_ID} ." ".$self->{_preferredname}." ".$self. " ". $self->{_pathlength}."\n"; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
#checks if two cui's are equivalent i.e. have the same id's |
95
|
|
|
|
|
|
|
sub equals { |
96
|
0
|
|
|
0
|
|
|
return shift-> {_ID}== shift-> {_ID}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
1; |