line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# UMLS::Association::ErrorHandler |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Perl module that provides a perl interface to the CUI network extracted |
4
|
|
|
|
|
|
|
# from the MetaMapped Medline Baseline |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This program borrows heavily from the UMLS::Interface package. |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# Copyright (c) 2015, |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
# Bridget T. McInnes, Virginia Commonwealth University |
11
|
|
|
|
|
|
|
# btmcinnes at vcu.edu |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Keith Herbert, Virginia Commonwealth University |
14
|
|
|
|
|
|
|
# herbertkb at vcu.edu |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
# Sam Henry, Virginia Commonwealth University |
17
|
|
|
|
|
|
|
# henryst at vcu.edu |
18
|
|
|
|
|
|
|
# |
19
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
20
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License |
21
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 |
22
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
25
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
26
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
27
|
|
|
|
|
|
|
# GNU General Public License for more details. |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
30
|
|
|
|
|
|
|
# along with this program; if not, write to |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# The Free Software Foundation, Inc., |
33
|
|
|
|
|
|
|
# 59 Temple Place - Suite 330, |
34
|
|
|
|
|
|
|
# Boston, MA 02111-1307, USA. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
package UMLS::Association::ErrorHandler; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
5
|
use Fcntl; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
153
|
|
39
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
40
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
41
|
1
|
|
|
1
|
|
4
|
use bytes; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
3
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Errors and their error codes |
44
|
|
|
|
|
|
|
my $e1 = "Database error (Error Code 1)."; |
45
|
|
|
|
|
|
|
my $e2 = "Self is undefined (Error Code 2)."; |
46
|
|
|
|
|
|
|
my $e3 = "A db is required (Error Code 3)."; |
47
|
|
|
|
|
|
|
my $e4 = "Undefined input value (Error Code 4)."; |
48
|
|
|
|
|
|
|
my $e5 = "NPP is zero or less error (Error Code 5)."; |
49
|
|
|
|
|
|
|
my $e6 = "Invalid CUI (Error Code 6)."; |
50
|
|
|
|
|
|
|
my $e7 = "UMLS::Association Database Content Error (Error Code 7)."; |
51
|
|
|
|
|
|
|
my $e8 = "UMLS::Association Package Error (Error Code 8)."; |
52
|
|
|
|
|
|
|
my $e9 = "Index Error (Error Code 9)."; |
53
|
|
|
|
|
|
|
my $e10 = "Option Error (Error Code 10)."; |
54
|
|
|
|
|
|
|
my $e11 = "Unsupported Option Error (Error Code 11)."; |
55
|
|
|
|
|
|
|
my $e12 = "Input parameter error (Error Code 12)."; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# throws an error and exits the program |
58
|
|
|
|
|
|
|
# input : $pkg <- package the error originated |
59
|
|
|
|
|
|
|
# $function <- function the error originated |
60
|
|
|
|
|
|
|
# $string <- error message |
61
|
|
|
|
|
|
|
# $errorcode <- error code |
62
|
|
|
|
|
|
|
# output: |
63
|
|
|
|
|
|
|
sub _error { |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
66
|
0
|
|
|
|
|
0
|
my $pkg = shift; |
67
|
0
|
|
|
|
|
0
|
my $function = shift; |
68
|
0
|
|
|
|
|
0
|
my $string = shift; |
69
|
0
|
|
|
|
|
0
|
my $errorcode = shift; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
0
|
my $errorstring = ""; |
72
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 1) { $errorstring = $e1; } |
|
0
|
|
|
|
|
0
|
|
74
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 2) { $errorstring = $e2; } |
|
0
|
|
|
|
|
0
|
|
75
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 3) { $errorstring = $e3; } |
|
0
|
|
|
|
|
0
|
|
76
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 4) { $errorstring = $e4; } |
|
0
|
|
|
|
|
0
|
|
77
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 5) { $errorstring = $e5; } |
|
0
|
|
|
|
|
0
|
|
78
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 6) { $errorstring = $e6; } |
|
0
|
|
|
|
|
0
|
|
79
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 7) { $errorstring = $e7; } |
|
0
|
|
|
|
|
0
|
|
80
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 8) { $errorstring = $e8; } |
|
0
|
|
|
|
|
0
|
|
81
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 9) { $errorstring = $e9; } |
|
0
|
|
|
|
|
0
|
|
82
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 10) { $errorstring = $e10; } |
|
0
|
|
|
|
|
0
|
|
83
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 11) { $errorstring = $e11; } |
|
0
|
|
|
|
|
0
|
|
84
|
0
|
0
|
|
|
|
0
|
if($errorcode eq 12) { $errorstring = $e12; } |
|
0
|
|
|
|
|
0
|
|
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
print STDERR "ERROR: $pkg->$function\n"; |
87
|
0
|
|
|
|
|
0
|
print STDERR "$errorstring\n"; |
88
|
0
|
|
|
|
|
0
|
print STDERR "$string\n"; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
exit; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# checks the database for an error |
94
|
|
|
|
|
|
|
# input : $pkg => the Finder program |
95
|
|
|
|
|
|
|
# $function => the function in the finder program |
96
|
|
|
|
|
|
|
# $db => the database handler |
97
|
|
|
|
|
|
|
# output: |
98
|
|
|
|
|
|
|
sub _checkDbError { |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
101
|
0
|
|
|
|
|
0
|
my $pkg = shift; |
102
|
0
|
|
|
|
|
0
|
my $function = shift; |
103
|
0
|
|
|
|
|
0
|
my $db = shift; |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
my $errorcode = 1; |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
0
|
if($db->err()) { |
108
|
0
|
|
|
|
|
0
|
my $errstring = "Error executing database query: $db->errstr())."; |
109
|
0
|
|
|
|
|
0
|
$self->_error($pkg, $function, $errstring, $errorcode); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
else { |
112
|
0
|
|
|
|
|
0
|
return; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# subroutine to check if CUI is valid |
117
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
118
|
|
|
|
|
|
|
# output: true | false <- integer indicating if the cui is valid |
119
|
|
|
|
|
|
|
sub _validCui { |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
122
|
0
|
|
|
|
|
0
|
my $concept = shift; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
0
|
if($concept=~/C[0-9][0-9][0-9][0-9][0-9][0-9][0-9]/) { |
125
|
0
|
|
|
|
|
0
|
return 1; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
else { |
128
|
0
|
|
|
|
|
0
|
return 0; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# sets up the error handler module |
133
|
|
|
|
|
|
|
# input : $parameters <- reference to a hash |
134
|
|
|
|
|
|
|
# output: $self |
135
|
|
|
|
|
|
|
sub new { |
136
|
|
|
|
|
|
|
|
137
|
48
|
|
|
48
|
0
|
49
|
my $self = {}; |
138
|
48
|
|
|
|
|
47
|
my $className = shift; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
# Bless the object. |
141
|
48
|
|
|
|
|
47
|
bless($self, $className); |
142
|
|
|
|
|
|
|
|
143
|
48
|
|
|
|
|
58
|
return $self; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
1; |
146
|
|
|
|
|
|
|
__END__ |