lib/SemMed/Interface/CUI.pm

filter: Statementstmt 20.0% 7 / 35 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 13.3% 2 / 15 Podpod n/a totaltotal 17.3% 9 / 52 SCAR 14.2
CC
2
Cov
19%
getPath
6.0
new
2.0
getId
2.0
CRAP 4.1
↑ Summary lib/SemMed/Interface/DataAccess.pm »
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 package CUI;
11  
12 sub new {
13 0 ▶ my $class = shift;;
Subroutine new: not called CC=1 SCAR=6.9
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 ▶ return shift->{_ID};
Subroutine getId: not called CC=1 SCAR=6.9
29 }
30 #returns preferred name of cui
31 sub getPreferredName {
32 0 ▶ return shift->{_preferredname};
Subroutine getPreferredName: not called CC=1 SCAR=6.9
33 }
34  
35 #returns aggregate path length, -1 if vertex has not been reached
36 sub getPathLength(){
37 0 ▶ return shift->{_pathlength};
Subroutine getPathLength: not called CC=1 SCAR=6.9
38 }
39  
40 sub getStrength(){
41 0 ▶ return shift->{_strength};
Subroutine getStrength: not called CC=1 SCAR=6.9
42 }
43  
44 #updates aggregate path length
45 sub setPathLength(){
46 0 ▶ my $self = shift;
Subroutine setPathLength: not called CC=1 SCAR=6.9
47 0 $self->{_pathlength} = shift;
48 }
49  
50  
51 sub setPrevCUI(){
52 0 ▶ my $self = shift;
Subroutine setPrevCUI: not called CC=1 SCAR=6.9
53 0 $self->{_prevCUI} = shift;
54 }
55  
56 sub setStrength(){
57 0 ▶ my $self = shift;
Subroutine setStrength: not called CC=1 SCAR=6.9
58 0 $self->{_strength} = shift;
59 }
60  
61 sub getPrevCUI(){
62 0 ▶ my $self = shift;
Subroutine getPrevCUI: not called CC=1 SCAR=6.9
63 0 return $self->{_prevCUI};
64 }
65  
66 sub setPrevPredicate{
67 0 ▶ my $self = shift;
Subroutine setPrevPredicate: not called CC=1 SCAR=6.9
68 0 $self->{_prevPredicate} = shift;
69 }
70  
71 sub getPath{
72 0 ▶ my $self = shift;
Subroutine getPath: not called CC=2 SCAR=17.9
73 0 my $length = $self->{_pathlength};
74
75 0 my $path = $self->getPreferredName();
76
77 0 ▶ while($self->getPrevCUI()){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->getPrevCUI) 0 0 0
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 ▶ my $self = shift;
Subroutine _print: not called CC=1 SCAR=6.9
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 ▶ return shift-> {_ID}== shift-> {_ID};
Subroutine equals: not called CC=1 SCAR=6.9
97 }
98 1 1;
↑ Summary lib/SemMed/Interface/DataAccess.pm »