line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# UMLS::Interface::CuiFinder |
2
|
|
|
|
|
|
|
# (Last Updated $Id: CuiFinder.pm,v 1.84 2016/09/13 17:15:51 btmcinnes Exp $) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# Perl module that provides a perl interface to the |
5
|
|
|
|
|
|
|
# Unified Medical Language System (UMLS) |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (c) 2004-2011, |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Bridget T. McInnes, University of Minnesota, Twin Cities |
10
|
|
|
|
|
|
|
# bthomson at cs.umn.edu |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# Siddharth Patwardhan, University of Utah, Salt Lake City |
13
|
|
|
|
|
|
|
# sidd at cs.utah.edu |
14
|
|
|
|
|
|
|
# |
15
|
|
|
|
|
|
|
# Serguei Pakhomov, University of Minnesota, Twin Cities |
16
|
|
|
|
|
|
|
# pakh0002 at umn.edu |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# Ted Pedersen, University of Minnesota, Duluth |
19
|
|
|
|
|
|
|
# tpederse at d.umn.edu |
20
|
|
|
|
|
|
|
# |
21
|
|
|
|
|
|
|
# Ying Liu, University of Minnesota, Twin Cities |
22
|
|
|
|
|
|
|
# liux0935 at umn.edu |
23
|
|
|
|
|
|
|
# |
24
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or |
25
|
|
|
|
|
|
|
# modify it under the terms of the GNU General Public License |
26
|
|
|
|
|
|
|
# as published by the Free Software Foundation; either version 2 |
27
|
|
|
|
|
|
|
# of the License, or (at your option) any later version. |
28
|
|
|
|
|
|
|
# |
29
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
30
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
31
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
32
|
|
|
|
|
|
|
# GNU General Public License for more details. |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
35
|
|
|
|
|
|
|
# along with this program; if not, write to |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
# The Free Software Foundation, Inc., |
38
|
|
|
|
|
|
|
# 59 Temple Place - Suite 330, |
39
|
|
|
|
|
|
|
# Boston, MA 02111-1307, USA. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package UMLS::Interface::CuiFinder; |
42
|
|
|
|
|
|
|
|
43
|
24
|
|
|
24
|
|
88
|
use Fcntl; |
|
24
|
|
|
|
|
30
|
|
|
24
|
|
|
|
|
4213
|
|
44
|
24
|
|
|
24
|
|
99
|
use strict; |
|
24
|
|
|
|
|
23
|
|
|
24
|
|
|
|
|
400
|
|
45
|
24
|
|
|
24
|
|
71
|
use warnings; |
|
24
|
|
|
|
|
26
|
|
|
24
|
|
|
|
|
646
|
|
46
|
24
|
|
|
24
|
|
65
|
use DBI; |
|
24
|
|
|
|
|
25
|
|
|
24
|
|
|
|
|
719
|
|
47
|
24
|
|
|
24
|
|
70
|
use bytes; |
|
24
|
|
|
|
|
23
|
|
|
24
|
|
|
|
|
79
|
|
48
|
|
|
|
|
|
|
|
49
|
24
|
|
|
24
|
|
9589
|
use Digest::SHA1 qw(sha1 sha1_hex sha1_base64); |
|
24
|
|
|
|
|
13811
|
|
|
24
|
|
|
|
|
409607
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# error handling variables |
52
|
|
|
|
|
|
|
my $errorhandler = ""; |
53
|
|
|
|
|
|
|
my $pkg = "UMLS::Interface::CuiFinder"; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# debug variables |
56
|
|
|
|
|
|
|
local(*DEBUG_FILE); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# global variables |
59
|
|
|
|
|
|
|
my $debug = 0; |
60
|
|
|
|
|
|
|
my $umlsRoot = "C0000000"; |
61
|
|
|
|
|
|
|
my $version = ""; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# list of allowable sources |
64
|
|
|
|
|
|
|
my $sources = ""; |
65
|
|
|
|
|
|
|
my %sabHash = (); |
66
|
|
|
|
|
|
|
my %sabnamesHash = (); |
67
|
|
|
|
|
|
|
my $sabstring = ""; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# list of allowable relations |
70
|
|
|
|
|
|
|
my $relations = ""; |
71
|
|
|
|
|
|
|
my $childRelations = ""; |
72
|
|
|
|
|
|
|
my $parentRelations = ""; |
73
|
|
|
|
|
|
|
my $relstring = ""; |
74
|
|
|
|
|
|
|
my $relastring = ""; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# upper level taxonomy |
77
|
|
|
|
|
|
|
my %parentTaxonomyArray = (); |
78
|
|
|
|
|
|
|
my %childTaxonomyArray = (); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# list of interested cuis - default is |
81
|
|
|
|
|
|
|
# all given the specified set of sources |
82
|
|
|
|
|
|
|
# and relations. |
83
|
|
|
|
|
|
|
my %cuiListHash = (); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# initialize the semantic groups and relations hash |
86
|
|
|
|
|
|
|
my %semanticGroups = (); |
87
|
|
|
|
|
|
|
my %semanticRelations = (); |
88
|
|
|
|
|
|
|
my %sgConversion = (); |
89
|
|
|
|
|
|
|
my %sgConversion1 = (); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# database |
92
|
|
|
|
|
|
|
my $indexDB = "umlsinterfaceindex"; |
93
|
|
|
|
|
|
|
my $umlsinterface = $ENV{UMLSINTERFACE_CONFIGFILE_DIR}; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# table names |
96
|
|
|
|
|
|
|
my $tableName = ""; |
97
|
|
|
|
|
|
|
my $intrinsicTable = ""; |
98
|
|
|
|
|
|
|
my $parentTable = ""; |
99
|
|
|
|
|
|
|
my $childTable = ""; |
100
|
|
|
|
|
|
|
my $tableFile = ""; |
101
|
|
|
|
|
|
|
my $intrinsicTableHuman= ""; |
102
|
|
|
|
|
|
|
my $parentTableHuman = ""; |
103
|
|
|
|
|
|
|
my $childTableHuman = ""; |
104
|
|
|
|
|
|
|
my $tableNameHuman = ""; |
105
|
|
|
|
|
|
|
my $configFile = ""; |
106
|
|
|
|
|
|
|
my $childFile = ""; |
107
|
|
|
|
|
|
|
my $parentFile = ""; |
108
|
|
|
|
|
|
|
my $infoTable = ""; |
109
|
|
|
|
|
|
|
my $infoTableHuman = ""; |
110
|
|
|
|
|
|
|
my $cacheTable = ""; |
111
|
|
|
|
|
|
|
my $cacheTableHuman = ""; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# flags and options |
114
|
|
|
|
|
|
|
my $umlsall = 0; |
115
|
|
|
|
|
|
|
my $sabdef_umlsall = 0; |
116
|
|
|
|
|
|
|
my $option_verbose = 0; |
117
|
|
|
|
|
|
|
my $option_cuilist = 0; |
118
|
|
|
|
|
|
|
my $option_t = 0; |
119
|
|
|
|
|
|
|
my $option_config = 0; |
120
|
|
|
|
|
|
|
my $defflag = 0; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# definition containers |
123
|
|
|
|
|
|
|
my $sabdefsources = ""; |
124
|
|
|
|
|
|
|
my %relDefHash = (); |
125
|
|
|
|
|
|
|
my %sabDefHash = (); |
126
|
|
|
|
|
|
|
my $reldefstring = ""; |
127
|
|
|
|
|
|
|
my $sabdefstring = ""; |
128
|
|
|
|
|
|
|
my $reladefchildren = ""; |
129
|
|
|
|
|
|
|
my $reladefparents = ""; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
my %parameters = (); |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
###################################################################### |
134
|
|
|
|
|
|
|
# functions to initialize the package |
135
|
|
|
|
|
|
|
###################################################################### |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# method to create a new UMLS::Interface object |
138
|
|
|
|
|
|
|
# input : $parameters <- reference to a hash |
139
|
|
|
|
|
|
|
# output: $self |
140
|
|
|
|
|
|
|
sub new { |
141
|
|
|
|
|
|
|
|
142
|
22
|
|
|
22
|
0
|
42
|
my $self = {}; |
143
|
22
|
|
|
|
|
31
|
my $className = shift; |
144
|
22
|
|
|
|
|
37
|
my $params = shift; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# bless the object. |
147
|
22
|
|
|
|
|
53
|
bless($self, $className); |
148
|
|
|
|
|
|
|
|
149
|
22
|
|
|
|
|
74
|
$self->_initializeGlobalVariables(); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# initialize error handler |
152
|
22
|
|
|
|
|
69
|
$errorhandler = UMLS::Interface::ErrorHandler->new(); |
153
|
22
|
50
|
|
|
|
79
|
if(! defined $errorhandler) { |
154
|
0
|
|
|
|
|
0
|
print STDERR "The error handler did not get passed properly.\n"; |
155
|
0
|
|
|
|
|
0
|
exit; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# initialize the object. |
159
|
22
|
|
|
|
|
69
|
$self->_initialize($params); |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# set the semantic groups |
162
|
0
|
|
|
|
|
0
|
$self->_setSemanticGroups(); |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
0
|
return $self; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# method to re-initialize the UMLS::Interface parameters |
168
|
|
|
|
|
|
|
sub _reConfig { |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
171
|
0
|
|
|
|
|
0
|
my $params = shift; |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
my $function = "_reConfig"; |
174
|
0
|
|
|
|
|
0
|
&_debug($function); |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
# re initialize the global variables |
177
|
0
|
|
|
|
|
0
|
$self->_initializeGlobalVariables(); |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# initialize the object. |
180
|
0
|
|
|
|
|
0
|
$self->_initialize($params); |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
0
|
return $self; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
# method to initialize the UMLS::Interface global variables |
187
|
|
|
|
|
|
|
sub _initializeGlobalVariables { |
188
|
|
|
|
|
|
|
|
189
|
22
|
|
|
22
|
|
35
|
my $self = shift; |
190
|
|
|
|
|
|
|
|
191
|
22
|
|
|
|
|
46
|
my $function = "_initializeGlobalVariables"; |
192
|
22
|
|
|
|
|
75
|
&_debug($function); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# global variables |
195
|
22
|
|
|
|
|
33
|
$debug = 0; |
196
|
22
|
|
|
|
|
47
|
$version = ""; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# list of allowable sources |
199
|
22
|
|
|
|
|
49
|
$sources = ""; |
200
|
22
|
|
|
|
|
42
|
%sabHash = (); |
201
|
22
|
|
|
|
|
33
|
%sabnamesHash = (); |
202
|
22
|
|
|
|
|
33
|
$sabstring = ""; |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# list of allowable relations |
205
|
22
|
|
|
|
|
38
|
$relations = ""; |
206
|
22
|
|
|
|
|
39
|
$childRelations = ""; |
207
|
22
|
|
|
|
|
32
|
$parentRelations = ""; |
208
|
22
|
|
|
|
|
41
|
$relstring = ""; |
209
|
22
|
|
|
|
|
41
|
$relastring = ""; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# upper level taxonomy |
212
|
22
|
|
|
|
|
31
|
%parentTaxonomyArray = (); |
213
|
22
|
|
|
|
|
34
|
%childTaxonomyArray = (); |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# list of interested cuis - default is |
216
|
|
|
|
|
|
|
# all given the specified set of sources |
217
|
|
|
|
|
|
|
# and relations. |
218
|
22
|
|
|
|
|
32
|
%cuiListHash = (); |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
# table names |
222
|
22
|
|
|
|
|
48
|
$tableName = ""; |
223
|
22
|
|
|
|
|
35
|
$parentTable = ""; |
224
|
22
|
|
|
|
|
32
|
$intrinsicTable = ""; |
225
|
22
|
|
|
|
|
33
|
$childTable = ""; |
226
|
22
|
|
|
|
|
34
|
$tableFile = ""; |
227
|
22
|
|
|
|
|
30
|
$intrinsicTableHuman= ""; |
228
|
22
|
|
|
|
|
30
|
$parentTableHuman = ""; |
229
|
22
|
|
|
|
|
34
|
$childTableHuman = ""; |
230
|
22
|
|
|
|
|
27
|
$tableNameHuman = ""; |
231
|
22
|
|
|
|
|
38
|
$configFile = ""; |
232
|
22
|
|
|
|
|
39
|
$childFile = ""; |
233
|
22
|
|
|
|
|
33
|
$parentFile = ""; |
234
|
22
|
|
|
|
|
34
|
$infoTable = ""; |
235
|
22
|
|
|
|
|
36
|
$infoTableHuman = ""; |
236
|
22
|
|
|
|
|
26
|
$cacheTable = ""; |
237
|
22
|
|
|
|
|
30
|
$cacheTableHuman = ""; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# flags and options |
240
|
22
|
|
|
|
|
30
|
$umlsall = 0; |
241
|
22
|
|
|
|
|
28
|
$option_verbose = 0; |
242
|
22
|
|
|
|
|
24
|
$option_cuilist = 0; |
243
|
22
|
|
|
|
|
31
|
$option_t = 0; |
244
|
22
|
|
|
|
|
24
|
$option_config = 0; |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
# definition containers |
247
|
22
|
|
|
|
|
39
|
$sabdefsources = ""; |
248
|
22
|
|
|
|
|
30
|
%relDefHash = (); |
249
|
22
|
|
|
|
|
34
|
%sabDefHash = (); |
250
|
22
|
|
|
|
|
306
|
$reldefstring = ""; |
251
|
22
|
|
|
|
|
40
|
$sabdefstring = ""; |
252
|
22
|
|
|
|
|
29
|
$reladefchildren = ""; |
253
|
22
|
|
|
|
|
33
|
$reladefparents = ""; |
254
|
22
|
|
|
|
|
45
|
%parameters = (); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
# method to initialize the UMLS::Interface object. |
259
|
|
|
|
|
|
|
# input : $parameters <- reference to a hash |
260
|
|
|
|
|
|
|
# output: |
261
|
|
|
|
|
|
|
sub _initialize { |
262
|
|
|
|
|
|
|
|
263
|
22
|
|
|
22
|
|
39
|
my $self = shift; |
264
|
22
|
|
|
|
|
29
|
my $params = shift; |
265
|
|
|
|
|
|
|
|
266
|
22
|
|
|
|
|
33
|
my $function = "_initialize"; |
267
|
22
|
|
|
|
|
54
|
&_debug($function); |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
# check self |
270
|
22
|
50
|
33
|
|
|
129
|
if(!defined $self || !ref $self) { |
271
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
22
|
50
|
|
|
|
55
|
$params = {} if(!defined $params); |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
# get some of the parameters |
278
|
22
|
|
|
|
|
53
|
my $config = $params->{'config'}; |
279
|
22
|
|
|
|
|
40
|
my $cuilist = $params->{'cuilist'}; |
280
|
22
|
|
|
|
|
28
|
my $database = $params->{'database'}; |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# to store the database object |
283
|
22
|
|
|
|
|
90
|
my $db = $self->_setDatabase($params); |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# set up the options |
286
|
0
|
|
|
|
|
0
|
$self->_setOptions($params); |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
# check that all of the tables required exist in the db |
289
|
0
|
|
|
|
|
0
|
$self->_checkTablesExist(); |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# set the version information |
292
|
0
|
|
|
|
|
0
|
$self->_setVersion(); |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# set the configuration |
295
|
0
|
|
|
|
|
0
|
$self->_config($config); |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
# set the umls interface configuration variable |
298
|
0
|
|
|
|
|
0
|
$self->_setEnvironmentVariable(); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# set the table and file names for indexing |
301
|
0
|
|
|
|
|
0
|
$self->_setConfigurationFile(); |
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
# set the configfile |
304
|
0
|
|
|
|
|
0
|
$self->_setConfigFile(); |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
# load the cuilist if it has been defined |
307
|
0
|
|
|
|
|
0
|
$self->_loadCuiList($cuilist); |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
# create the index database |
310
|
0
|
|
|
|
|
0
|
$self->_createIndexDB(); |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
# connect to the index database |
313
|
0
|
|
|
|
|
0
|
$self->_connectIndexDB(); |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
# set the upper level taxonomy |
316
|
0
|
|
|
|
|
0
|
$self->_setUpperLevelTaxonomy(); |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
# set the cache tables |
319
|
0
|
|
|
|
|
0
|
$self->_setCacheTable(); |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
# this function returns the umls root |
323
|
|
|
|
|
|
|
# input : |
324
|
|
|
|
|
|
|
# output: $string <- string containing the root |
325
|
|
|
|
|
|
|
sub _root { |
326
|
|
|
|
|
|
|
|
327
|
0
|
|
|
0
|
|
0
|
return $umlsRoot; |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# this function sets the upper level taxonomy between |
331
|
|
|
|
|
|
|
# the sources and the root UMLS node |
332
|
|
|
|
|
|
|
# input : |
333
|
|
|
|
|
|
|
# output: |
334
|
|
|
|
|
|
|
sub _setCacheTable { |
335
|
|
|
|
|
|
|
|
336
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
337
|
|
|
|
|
|
|
|
338
|
0
|
|
|
|
|
0
|
my $function = "_setCacheTable"; |
339
|
0
|
|
|
|
|
0
|
&_debug($function); |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
# check self |
342
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
343
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
# set the sourceDB handler |
347
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
348
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
349
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
# check if the cache table exists |
351
|
|
|
|
|
|
|
# if does just return otherwise create it |
352
|
0
|
0
|
|
|
|
0
|
if($self->_checkTableExists($cacheTable)) { |
353
|
0
|
|
|
|
|
0
|
return; |
354
|
|
|
|
|
|
|
} |
355
|
|
|
|
|
|
|
else { |
356
|
|
|
|
|
|
|
# create cache table |
357
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS $cacheTable (CUI1 char(8), CUI2 char(8), LENGTH char(8))"); |
358
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
359
|
|
|
|
|
|
|
# store the name in the table index |
360
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO tableindex (TABLENAME, HEX) VALUES ('$cacheTableHuman', '$cacheTable')"); |
361
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
362
|
|
|
|
|
|
|
} |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
# this function sets the upper level taxonomy between |
366
|
|
|
|
|
|
|
# the sources and the root UMLS node |
367
|
|
|
|
|
|
|
# input : |
368
|
|
|
|
|
|
|
# output: |
369
|
|
|
|
|
|
|
sub _setUpperLevelTaxonomy { |
370
|
|
|
|
|
|
|
|
371
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
372
|
|
|
|
|
|
|
|
373
|
0
|
|
|
|
|
0
|
my $function = "_setUpperLevelTaxonomy"; |
374
|
0
|
|
|
|
|
0
|
&_debug($function); |
375
|
|
|
|
|
|
|
|
376
|
|
|
|
|
|
|
# check self |
377
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
378
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
# set the sourceDB handler |
382
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
383
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
384
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
# check if the taxonomy is already set |
386
|
0
|
|
|
|
|
0
|
my $ckeys = keys %childTaxonomyArray; |
387
|
0
|
|
|
|
|
0
|
my $pkeys = keys %parentTaxonomyArray; |
388
|
0
|
0
|
|
|
|
0
|
if($pkeys > 0) { return; } |
|
0
|
|
|
|
|
0
|
|
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
# check if the parent and child tables exist and |
391
|
|
|
|
|
|
|
# if they do just return otherwise create them |
392
|
0
|
0
|
0
|
|
|
0
|
if($self->_checkTableExists($childTable) and |
393
|
|
|
|
|
|
|
$self->_checkTableExists($parentTable)) { |
394
|
0
|
|
|
|
|
0
|
$self->_loadTaxonomyArrays(); |
395
|
0
|
|
|
|
|
0
|
return; |
396
|
|
|
|
|
|
|
} |
397
|
|
|
|
|
|
|
else { |
398
|
0
|
|
|
|
|
0
|
$self->_createTaxonomyTables(); |
399
|
|
|
|
|
|
|
} |
400
|
|
|
|
|
|
|
|
401
|
|
|
|
|
|
|
# if the parent and child files exist just load them into the database |
402
|
0
|
0
|
0
|
|
|
0
|
if( (-e $childFile) and (-e $parentFile) ) { |
403
|
0
|
|
|
|
|
0
|
$self->_loadTaxonomyTables(); |
404
|
|
|
|
|
|
|
} |
405
|
|
|
|
|
|
|
# otherwise we need to create them |
406
|
|
|
|
|
|
|
else { |
407
|
0
|
|
|
|
|
0
|
$self->_createUpperLevelTaxonomy(); |
408
|
|
|
|
|
|
|
} |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
# this function creates the upper level taxonomy between the |
412
|
|
|
|
|
|
|
# the sources and the root UMLS node |
413
|
|
|
|
|
|
|
# this function creates the upper level taxonomy between the |
414
|
|
|
|
|
|
|
# the sources and the root UMLS node |
415
|
|
|
|
|
|
|
# input : |
416
|
|
|
|
|
|
|
# output: |
417
|
|
|
|
|
|
|
sub _createUpperLevelTaxonomy { |
418
|
|
|
|
|
|
|
|
419
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
420
|
|
|
|
|
|
|
|
421
|
0
|
|
|
|
|
0
|
my $function = "_createUpperLevelTaxonomy"; |
422
|
0
|
|
|
|
|
0
|
&_debug($function); |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
# check self |
425
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
426
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
# set the index DB handler |
430
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
431
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
# set up the database |
434
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
435
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
# open the parent and child files to store the upper level |
438
|
|
|
|
|
|
|
# taxonomy information if the verbose option is defined |
439
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
440
|
0
|
0
|
|
|
|
0
|
open(CHD, ">$childFile") || die "Could not open $childFile\n"; |
441
|
0
|
0
|
|
|
|
0
|
open(PAR, ">$parentFile") || die "Could not open $parentFile\n"; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
|
444
|
0
|
|
|
|
|
0
|
foreach my $sab (sort keys %sabnamesHash) { |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
# get the sab's cui |
447
|
0
|
|
|
|
|
0
|
my $sab_cui = $self->_getSabCui($sab); |
448
|
|
|
|
|
|
|
|
449
|
|
|
|
|
|
|
# select all the CUIs from MRREL |
450
|
0
|
|
|
|
|
0
|
my $allCuis = $self->_getCuis($sab); |
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
# select all the CUI1s from MRREL that have a parent link |
453
|
|
|
|
|
|
|
# if a parent relation exists |
454
|
0
|
|
|
|
|
0
|
my $parCuis = ""; |
455
|
0
|
|
|
|
|
0
|
my %parCuisHash = (); |
456
|
0
|
0
|
|
|
|
0
|
if( !($parentRelations=~/\(\)/) ) { |
457
|
0
|
|
|
|
|
0
|
$parCuis = $db->selectcol_arrayref("select CUI1 from MRREL where ($parentRelations) and (SAB=\'$sab\') and SUPPRESS='N'"); |
458
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
# load the cuis that have a parent into a temporary hash |
461
|
0
|
|
|
|
|
0
|
foreach my $cui (@{$parCuis}) { $parCuisHash{$cui}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
462
|
|
|
|
|
|
|
} |
463
|
|
|
|
|
|
|
|
464
|
|
|
|
|
|
|
# load the cuis that do not have a parent into the parent |
465
|
|
|
|
|
|
|
# and chilren taxonomy for the upper level |
466
|
0
|
|
|
|
|
0
|
foreach my $cui (@{$allCuis}) { |
|
0
|
|
|
|
|
0
|
|
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
# if the cui has a parent move on |
469
|
0
|
0
|
|
|
|
0
|
if(exists $parCuisHash{$cui}) { next; } |
|
0
|
|
|
|
|
0
|
|
470
|
|
|
|
|
|
|
|
471
|
|
|
|
|
|
|
# already seen this cui so move on |
472
|
0
|
0
|
|
|
|
0
|
if(exists $parentTaxonomyArray{$cui}) { next; } |
|
0
|
|
|
|
|
0
|
|
473
|
|
|
|
|
|
|
|
474
|
|
|
|
|
|
|
|
475
|
0
|
0
|
|
|
|
0
|
if($sab_cui eq $cui) { next; } |
|
0
|
|
|
|
|
0
|
|
476
|
|
|
|
|
|
|
|
477
|
0
|
|
|
|
|
0
|
push @{$parentTaxonomyArray{$cui}}, $sab_cui; |
|
0
|
|
|
|
|
0
|
|
478
|
0
|
|
|
|
|
0
|
push @{$childTaxonomyArray{$sab_cui}}, $cui; |
|
0
|
|
|
|
|
0
|
|
479
|
|
|
|
|
|
|
|
480
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO $parentTable (CUI1, CUI2) VALUES ('$cui', '$sab_cui')"); |
481
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
482
|
|
|
|
|
|
|
|
483
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO $childTable (CUI1, CUI2) VALUES ('$sab_cui', '$cui')"); |
484
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
# print this information to the parent and child |
487
|
|
|
|
|
|
|
# file is the verbose option has been set |
488
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
489
|
0
|
|
|
|
|
0
|
print PAR "$cui $sab_cui\n"; |
490
|
0
|
|
|
|
|
0
|
print CHD "$sab_cui $cui\n"; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
# add the sab cuis to the parent and children Taxonomy |
495
|
0
|
|
|
|
|
0
|
push @{$parentTaxonomyArray{$sab_cui}}, $umlsRoot; |
|
0
|
|
|
|
|
0
|
|
496
|
0
|
|
|
|
|
0
|
push @{$childTaxonomyArray{$umlsRoot}}, $sab_cui; |
|
0
|
|
|
|
|
0
|
|
497
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
# print it to the table if the verbose option is set |
499
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
500
|
0
|
|
|
|
|
0
|
print PAR "$sab_cui $umlsRoot\n"; |
501
|
0
|
|
|
|
|
0
|
print CHD "$umlsRoot $sab_cui\n"; |
502
|
|
|
|
|
|
|
} |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
# store this information in the database |
505
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO $parentTable (CUI1, CUI2) VALUES ('$sab_cui', '$umlsRoot')"); |
506
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
507
|
|
|
|
|
|
|
|
508
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO $childTable (CUI1, CUI2) VALUES ('$umlsRoot', '$sab_cui')"); |
509
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
510
|
|
|
|
|
|
|
} |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
# close the parent and child tables if opened |
513
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { close PAR; close CHD; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
# print out some information |
516
|
0
|
|
|
|
|
0
|
my $pkey = keys %parentTaxonomyArray; |
517
|
0
|
|
|
|
|
0
|
my $ckey = keys %childTaxonomyArray; |
518
|
|
|
|
|
|
|
|
519
|
0
|
0
|
|
|
|
0
|
if($debug) { |
520
|
0
|
|
|
|
|
0
|
print STDERR "Taxonomy is set:\n"; |
521
|
0
|
|
|
|
|
0
|
print STDERR " parentTaxonomyArray: $pkey\n"; |
522
|
0
|
|
|
|
|
0
|
print STDERR " childTaxonomyArray: $ckey\n\n"; |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
} |
525
|
|
|
|
|
|
|
|
526
|
|
|
|
|
|
|
# this function creates the taxonomy tables if they don't |
527
|
|
|
|
|
|
|
# already exist in the umlsinterfaceindex database |
528
|
|
|
|
|
|
|
# input : |
529
|
|
|
|
|
|
|
# output: |
530
|
|
|
|
|
|
|
sub _createTaxonomyTables { |
531
|
|
|
|
|
|
|
|
532
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
533
|
|
|
|
|
|
|
|
534
|
0
|
|
|
|
|
0
|
my $function = "_createTaxonomyTables"; |
535
|
0
|
|
|
|
|
0
|
&_debug($function); |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
# check self |
538
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
539
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
540
|
|
|
|
|
|
|
} |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
# set the index DB handler |
543
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
544
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
# create intrinsic table |
547
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS $intrinsicTable (CUI char(8), LEAVES int, SUBSUMERS int, INDEX(CUI))"); |
548
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
549
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
# create parent table |
551
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS $parentTable (CUI1 char(8), CUI2 char(8))"); |
552
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
553
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
# create child table |
555
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS $childTable (CUI1 char(8), CUI2 char(8))"); |
556
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
# create info table |
559
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS $infoTable (ITEM char(8), INFO char(8))"); |
560
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
# create the index table if it doesn't already exist |
563
|
0
|
|
|
|
|
0
|
$sdb->do("CREATE TABLE IF NOT EXISTS tableindex (TABLENAME blob(1000000), HEX char(41))"); |
564
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
# add them to the index table |
567
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO tableindex (TABLENAME, HEX) VALUES ('$intrinsicTableHuman', '$intrinsicTable')"); |
568
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
569
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO tableindex (TABLENAME, HEX) VALUES ('$parentTableHuman', '$parentTable')"); |
570
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
571
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO tableindex (TABLENAME, HEX) VALUES ('$childTableHuman', '$childTable')"); |
572
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
573
|
0
|
|
|
|
|
0
|
$sdb->do("INSERT INTO tableindex (TABLENAME, HEX) VALUES ('$infoTableHuman', '$infoTable')"); |
574
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
575
|
|
|
|
|
|
|
} |
576
|
|
|
|
|
|
|
|
577
|
|
|
|
|
|
|
# this function loads the taxonomy tables if the |
578
|
|
|
|
|
|
|
# configuration files exist for them |
579
|
|
|
|
|
|
|
# input : |
580
|
|
|
|
|
|
|
# output: |
581
|
|
|
|
|
|
|
sub _loadTaxonomyTables { |
582
|
|
|
|
|
|
|
|
583
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
584
|
|
|
|
|
|
|
|
585
|
0
|
|
|
|
|
0
|
my $function = "_loadTaxonomyTables"; |
586
|
0
|
|
|
|
|
0
|
&_debug($function); |
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
# check self |
589
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
590
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
591
|
|
|
|
|
|
|
} |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
# set the index DB handler |
594
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
595
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
596
|
|
|
|
|
|
|
|
597
|
0
|
0
|
|
|
|
0
|
open(PAR, $parentFile) || die "Could not open $parentFile\n"; |
598
|
0
|
0
|
|
|
|
0
|
open(CHD, $childFile) || die "Could not open $childFile\n"; |
599
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
# load parent table |
601
|
0
|
|
|
|
|
0
|
while() { |
602
|
0
|
|
|
|
|
0
|
chomp; |
603
|
0
|
0
|
|
|
|
0
|
if($_=~/^\s*$/) { next; } |
|
0
|
|
|
|
|
0
|
|
604
|
0
|
|
|
|
|
0
|
my ($cui1, $cui2) = split/\s+/; |
605
|
|
|
|
|
|
|
|
606
|
0
|
|
|
|
|
0
|
my $arrRef = $sdb->do("INSERT INTO $parentTable (CUI1, CUI2) VALUES ('$cui1', '$cui2')"); |
607
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
# load child table |
611
|
0
|
|
|
|
|
0
|
while() { |
612
|
0
|
|
|
|
|
0
|
chomp; |
613
|
0
|
0
|
|
|
|
0
|
if($_=~/^\s*$/) { next; } |
|
0
|
|
|
|
|
0
|
|
614
|
0
|
|
|
|
|
0
|
my ($cui1, $cui2) = split/\s+/; |
615
|
0
|
|
|
|
|
0
|
my $arrRef = $sdb->do("INSERT INTO $childTable (CUI1, CUI2) VALUES ('$cui1', '$cui2')"); |
616
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
617
|
|
|
|
|
|
|
} |
618
|
0
|
|
|
|
|
0
|
close PAR; close CHD; |
|
0
|
|
|
|
|
0
|
|
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# this function sets the taxonomy arrays |
622
|
|
|
|
|
|
|
# input : |
623
|
|
|
|
|
|
|
# output: |
624
|
|
|
|
|
|
|
sub _loadTaxonomyArrays { |
625
|
|
|
|
|
|
|
|
626
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
627
|
|
|
|
|
|
|
|
628
|
0
|
|
|
|
|
0
|
my $function = "_loadTaxonomyArrays"; |
629
|
0
|
|
|
|
|
0
|
&_debug($function); |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
# check self |
632
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
633
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
# set the index DB handler |
637
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
638
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
# set the parent taxonomy |
641
|
0
|
|
|
|
|
0
|
my $sql = qq{ SELECT CUI1, CUI2 FROM $parentTable}; |
642
|
0
|
|
|
|
|
0
|
my $sth = $sdb->prepare( $sql ); |
643
|
0
|
|
|
|
|
0
|
$sth->execute(); |
644
|
0
|
|
|
|
|
0
|
my($cui1, $cui2); |
645
|
0
|
|
|
|
|
0
|
$sth->bind_columns( undef, \$cui1, \$cui2 ); |
646
|
0
|
|
|
|
|
0
|
while( $sth->fetch() ) { |
647
|
0
|
|
|
|
|
0
|
push @{$parentTaxonomyArray{$cui1}}, $cui2; |
|
0
|
|
|
|
|
0
|
|
648
|
|
|
|
|
|
|
} |
649
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
650
|
0
|
|
|
|
|
0
|
$sth->finish(); |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
# set the child taxonomy |
653
|
0
|
|
|
|
|
0
|
$sql = qq{ SELECT CUI1, CUI2 FROM $childTable}; |
654
|
0
|
|
|
|
|
0
|
$sth = $sdb->prepare( $sql ); |
655
|
0
|
|
|
|
|
0
|
$sth->execute(); |
656
|
0
|
|
|
|
|
0
|
$sth->bind_columns( undef, \$cui1, \$cui2 ); |
657
|
0
|
|
|
|
|
0
|
while( $sth->fetch() ) { |
658
|
0
|
|
|
|
|
0
|
push @{$childTaxonomyArray{$cui1}}, $cui2; |
|
0
|
|
|
|
|
0
|
|
659
|
|
|
|
|
|
|
} |
660
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
661
|
0
|
|
|
|
|
0
|
$sth->finish(); |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
|
664
|
|
|
|
|
|
|
# function checks to see if a given table exists |
665
|
|
|
|
|
|
|
# input : $table <- string |
666
|
|
|
|
|
|
|
# output: 0 | 1 <- integers |
667
|
|
|
|
|
|
|
sub _checkTableExists { |
668
|
|
|
|
|
|
|
|
669
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
670
|
0
|
|
|
|
|
0
|
my $table = shift; |
671
|
|
|
|
|
|
|
|
672
|
0
|
|
|
|
|
0
|
my $function = "_checkTableExists"; |
673
|
0
|
|
|
|
|
0
|
&_debug($function); |
674
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
# check self |
676
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
677
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
678
|
|
|
|
|
|
|
} |
679
|
|
|
|
|
|
|
|
680
|
0
|
0
|
|
|
|
0
|
if(!defined $table) { |
681
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Error with input variable \$table.", 4); |
682
|
|
|
|
|
|
|
} |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# check that the database exists |
685
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
686
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
687
|
|
|
|
|
|
|
|
688
|
|
|
|
|
|
|
# set an execute the query to show all of the tables |
689
|
0
|
|
|
|
|
0
|
my $sth = $sdb->prepare("show tables"); |
690
|
0
|
|
|
|
|
0
|
$sth->execute(); |
691
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
692
|
|
|
|
|
|
|
|
693
|
0
|
|
|
|
|
0
|
my $t = ""; |
694
|
0
|
|
|
|
|
0
|
my %tables = (); |
695
|
0
|
|
|
|
|
0
|
while(($t) = $sth->fetchrow()) { |
696
|
0
|
|
|
|
|
0
|
$tables{lc($t)} = 1; |
697
|
|
|
|
|
|
|
} |
698
|
0
|
|
|
|
|
0
|
$sth->finish(); |
699
|
|
|
|
|
|
|
|
700
|
0
|
0
|
|
|
|
0
|
if(! (exists$tables{lc($table)})) { return 0; } |
|
0
|
|
|
|
|
0
|
|
701
|
0
|
|
|
|
|
0
|
else { return 1; } |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
} |
704
|
|
|
|
|
|
|
|
705
|
|
|
|
|
|
|
# connect the database to the source db that holds |
706
|
|
|
|
|
|
|
# the path tables for user specified source(s) and |
707
|
|
|
|
|
|
|
# relation(s) |
708
|
|
|
|
|
|
|
# input : |
709
|
|
|
|
|
|
|
# output: $sdb <- reference to the database |
710
|
|
|
|
|
|
|
sub _connectIndexDB { |
711
|
|
|
|
|
|
|
|
712
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
713
|
|
|
|
|
|
|
|
714
|
0
|
|
|
|
|
0
|
my $function = "_connectIndexDB"; |
715
|
0
|
|
|
|
|
0
|
&_debug($function); |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
# check self |
718
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
719
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
720
|
|
|
|
|
|
|
} |
721
|
|
|
|
|
|
|
|
722
|
0
|
|
|
|
|
0
|
my $sdb = ""; |
723
|
0
|
0
|
|
|
|
0
|
if(defined $self->{'username'}) { |
724
|
|
|
|
|
|
|
|
725
|
0
|
|
|
|
|
0
|
my $username = $self->{'username'}; |
726
|
0
|
|
|
|
|
0
|
my $password = $self->{'password'}; |
727
|
0
|
|
|
|
|
0
|
my $hostname = $self->{'hostname'}; |
728
|
0
|
|
|
|
|
0
|
my $socket = $self->{'socket'}; |
729
|
|
|
|
|
|
|
|
730
|
0
|
|
|
|
|
0
|
eval{$sdb = DBI->connect("DBI:mysql:database=$indexDB;mysql_socket=$socket;host=$hostname", |
|
0
|
|
|
|
|
0
|
|
731
|
|
|
|
|
|
|
$username, $password, |
732
|
|
|
|
|
|
|
{RaiseError => 1, PrintError => 1, AutoCommit => 0 });}; |
733
|
|
|
|
|
|
|
|
734
|
0
|
0
|
|
|
|
0
|
if($@) { $errorhandler->_error($pkg, $function, "No database to connect to", 1); } |
|
0
|
|
|
|
|
0
|
|
735
|
|
|
|
|
|
|
} |
736
|
|
|
|
|
|
|
else { |
737
|
0
|
|
|
|
|
0
|
my $dsn = "DBI:mysql:$indexDB;mysql_read_default_group=client;"; |
738
|
0
|
|
|
|
|
0
|
eval{$sdb = DBI->connect($dsn);}; |
|
0
|
|
|
|
|
0
|
|
739
|
0
|
0
|
|
|
|
0
|
if($@) { $errorhandler->_error($pkg, $function, "No database to connect to", 1); } |
|
0
|
|
|
|
|
0
|
|
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
|
742
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
743
|
|
|
|
|
|
|
|
744
|
|
|
|
|
|
|
# set database parameters |
745
|
0
|
|
|
|
|
0
|
$sdb->{'mysql_enable_utf8'} = 1; |
746
|
0
|
|
|
|
|
0
|
$sdb->do('SET NAMES utf8'); |
747
|
0
|
|
|
|
|
0
|
$sdb->{mysql_auto_reconnect} = 1; |
748
|
|
|
|
|
|
|
|
749
|
0
|
|
|
|
|
0
|
$self->{'sdb'} = $sdb; |
750
|
|
|
|
|
|
|
|
751
|
0
|
|
|
|
|
0
|
return $sdb; |
752
|
|
|
|
|
|
|
} |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
# return the database connection to the umlsinterfaceindex |
755
|
|
|
|
|
|
|
# input : |
756
|
|
|
|
|
|
|
# output: $sdb <- database handler |
757
|
|
|
|
|
|
|
sub _getIndexDB { |
758
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
759
|
|
|
|
|
|
|
|
760
|
0
|
|
|
|
|
0
|
my $function = "_getIndexDB"; |
761
|
0
|
|
|
|
|
0
|
&_debug($function); |
762
|
|
|
|
|
|
|
|
763
|
|
|
|
|
|
|
# check self |
764
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
765
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
766
|
|
|
|
|
|
|
} |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
# get the databawse |
769
|
0
|
|
|
|
|
0
|
my $sdb = $self->{'sdb'}; |
770
|
0
|
0
|
|
|
|
0
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
0
|
|
771
|
|
|
|
|
|
|
|
772
|
|
|
|
|
|
|
# return the database |
773
|
0
|
|
|
|
|
0
|
return $sdb; |
774
|
|
|
|
|
|
|
} |
775
|
|
|
|
|
|
|
|
776
|
|
|
|
|
|
|
# return the database connection to the umls database |
777
|
|
|
|
|
|
|
# input : |
778
|
|
|
|
|
|
|
# output: $db <- database handler |
779
|
|
|
|
|
|
|
sub _getDB { |
780
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
781
|
|
|
|
|
|
|
|
782
|
0
|
|
|
|
|
0
|
my $function = "_getDB"; |
783
|
0
|
|
|
|
|
0
|
&_debug($function); |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
# check self |
786
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
787
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
788
|
|
|
|
|
|
|
} |
789
|
|
|
|
|
|
|
|
790
|
|
|
|
|
|
|
# get the databawse |
791
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
792
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
793
|
|
|
|
|
|
|
|
794
|
|
|
|
|
|
|
# return the database |
795
|
0
|
|
|
|
|
0
|
return $db; |
796
|
|
|
|
|
|
|
} |
797
|
|
|
|
|
|
|
|
798
|
|
|
|
|
|
|
# this function creates the umlsinterfaceindex database connection |
799
|
|
|
|
|
|
|
# input : |
800
|
|
|
|
|
|
|
# output: |
801
|
|
|
|
|
|
|
sub _createIndexDB { |
802
|
|
|
|
|
|
|
|
803
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
804
|
|
|
|
|
|
|
|
805
|
0
|
|
|
|
|
0
|
my $function = "_createIndexDB"; |
806
|
0
|
|
|
|
|
0
|
&_debug($function); |
807
|
|
|
|
|
|
|
|
808
|
|
|
|
|
|
|
# check self |
809
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
810
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
811
|
|
|
|
|
|
|
} |
812
|
|
|
|
|
|
|
|
813
|
|
|
|
|
|
|
# check that the database exists |
814
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
815
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
816
|
|
|
|
|
|
|
|
817
|
|
|
|
|
|
|
# show all of the databases |
818
|
0
|
|
|
|
|
0
|
my $sth = $db->prepare("show databases"); |
819
|
0
|
|
|
|
|
0
|
$sth->execute(); |
820
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
821
|
|
|
|
|
|
|
|
822
|
|
|
|
|
|
|
# get all the databases in mysql |
823
|
0
|
|
|
|
|
0
|
my $database = ""; |
824
|
0
|
|
|
|
|
0
|
my %databases = (); |
825
|
0
|
|
|
|
|
0
|
while(($database) = $sth->fetchrow()) { |
826
|
0
|
|
|
|
|
0
|
$databases{$database}++; |
827
|
|
|
|
|
|
|
} |
828
|
0
|
|
|
|
|
0
|
$sth->finish(); |
829
|
|
|
|
|
|
|
|
830
|
|
|
|
|
|
|
# removing any spaces that may have been |
831
|
|
|
|
|
|
|
# introduced in while creating its name |
832
|
0
|
|
|
|
|
0
|
$indexDB=~s/\s+//g; |
833
|
|
|
|
|
|
|
|
834
|
|
|
|
|
|
|
# if the database doesn't exist create it |
835
|
0
|
0
|
|
|
|
0
|
if(! (exists $databases{$indexDB})) { |
836
|
0
|
|
|
|
|
0
|
$db->do("create database $indexDB"); |
837
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
838
|
|
|
|
|
|
|
} |
839
|
|
|
|
|
|
|
} |
840
|
|
|
|
|
|
|
|
841
|
|
|
|
|
|
|
# gets the DUI of a given CUI |
842
|
|
|
|
|
|
|
# input: $concept -> string containing the cui |
843
|
|
|
|
|
|
|
# output: $dui -> string containing the dui |
844
|
|
|
|
|
|
|
sub _getDUI { |
845
|
|
|
|
|
|
|
|
846
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
847
|
0
|
|
|
|
|
0
|
my $concept = shift; |
848
|
|
|
|
|
|
|
|
849
|
0
|
|
|
|
|
0
|
my $function = "_getDUI"; |
850
|
|
|
|
|
|
|
|
851
|
|
|
|
|
|
|
# check input values |
852
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
853
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
854
|
|
|
|
|
|
|
} |
855
|
|
|
|
|
|
|
|
856
|
|
|
|
|
|
|
# check parameters |
857
|
0
|
0
|
|
|
|
0
|
if(!defined $concept) { |
858
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
859
|
|
|
|
|
|
|
} |
860
|
|
|
|
|
|
|
|
861
|
|
|
|
|
|
|
# set the database |
862
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
863
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
864
|
|
|
|
|
|
|
|
865
|
0
|
|
|
|
|
0
|
my $duis = $db->selectcol_arrayref("select SDUI from MRCONSO where CUI=\'$concept\' and SAB=\'MSH\'"); |
866
|
|
|
|
|
|
|
|
867
|
0
|
|
|
|
|
0
|
my $dui = shift @{$duis}; |
|
0
|
|
|
|
|
0
|
|
868
|
|
|
|
|
|
|
|
869
|
0
|
|
|
|
|
0
|
return $dui; |
870
|
|
|
|
|
|
|
} |
871
|
|
|
|
|
|
|
|
872
|
|
|
|
|
|
|
|
873
|
|
|
|
|
|
|
# checks to see if a concept is in the CuiList |
874
|
|
|
|
|
|
|
# input : $concept -> string containing the cui |
875
|
|
|
|
|
|
|
# output: 1|0 -> indicating if the cui is in the cuilist |
876
|
|
|
|
|
|
|
sub _inCuiList { |
877
|
|
|
|
|
|
|
|
878
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
879
|
0
|
|
|
|
|
0
|
my $concept = shift; |
880
|
|
|
|
|
|
|
|
881
|
0
|
|
|
|
|
0
|
my $function = "_inCuiList"; |
882
|
|
|
|
|
|
|
|
883
|
|
|
|
|
|
|
# check input vluaes |
884
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
885
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
886
|
|
|
|
|
|
|
} |
887
|
|
|
|
|
|
|
|
888
|
|
|
|
|
|
|
# check parameters |
889
|
0
|
0
|
|
|
|
0
|
if(!defined $concept) { |
890
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
891
|
|
|
|
|
|
|
} |
892
|
|
|
|
|
|
|
|
893
|
0
|
0
|
|
|
|
0
|
if(exists $cuiListHash{$concept}) { return 1; } |
|
0
|
|
|
|
|
0
|
|
894
|
0
|
|
|
|
|
0
|
else { return 0; } |
895
|
|
|
|
|
|
|
} |
896
|
|
|
|
|
|
|
|
897
|
|
|
|
|
|
|
|
898
|
|
|
|
|
|
|
# if the cuilist option is specified load the information |
899
|
|
|
|
|
|
|
# input : $cuilist <- file containing the list of cuis |
900
|
|
|
|
|
|
|
# output: |
901
|
|
|
|
|
|
|
sub _loadCuiList { |
902
|
|
|
|
|
|
|
|
903
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
904
|
0
|
|
|
|
|
0
|
my $cuilist = shift; |
905
|
|
|
|
|
|
|
|
906
|
0
|
|
|
|
|
0
|
my $function = "_loadCuiList"; |
907
|
|
|
|
|
|
|
|
908
|
|
|
|
|
|
|
# check the input values |
909
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
910
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
911
|
|
|
|
|
|
|
} |
912
|
|
|
|
|
|
|
|
913
|
0
|
0
|
|
|
|
0
|
if(defined $cuilist) { |
914
|
0
|
0
|
|
|
|
0
|
open(CUILIST, $cuilist) || die "Could not open the cuilist file: $cuilist\n"; |
915
|
0
|
|
|
|
|
0
|
while() { |
916
|
0
|
|
|
|
|
0
|
chomp; |
917
|
|
|
|
|
|
|
|
918
|
0
|
0
|
|
|
|
0
|
if(! ($errorhandler->_validCui($_)) ) { |
919
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Incorrect input value ($_) in cuilist.", 6); |
920
|
|
|
|
|
|
|
} |
921
|
|
|
|
|
|
|
|
922
|
0
|
|
|
|
|
0
|
$cuiListHash{$_}++; |
923
|
|
|
|
|
|
|
} |
924
|
|
|
|
|
|
|
} |
925
|
|
|
|
|
|
|
} |
926
|
|
|
|
|
|
|
|
927
|
|
|
|
|
|
|
# create the configuration file |
928
|
|
|
|
|
|
|
# input : |
929
|
|
|
|
|
|
|
# output: |
930
|
|
|
|
|
|
|
sub _setConfigFile { |
931
|
|
|
|
|
|
|
|
932
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
933
|
|
|
|
|
|
|
|
934
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
935
|
|
|
|
|
|
|
|
936
|
0
|
|
|
|
|
0
|
my $function = "_setConfigFile"; |
937
|
0
|
|
|
|
|
0
|
&_debug($function); |
938
|
|
|
|
|
|
|
|
939
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
940
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
941
|
|
|
|
|
|
|
} |
942
|
|
|
|
|
|
|
|
943
|
0
|
0
|
|
|
|
0
|
if(! (-e $configFile)) { |
944
|
|
|
|
|
|
|
|
945
|
0
|
0
|
|
|
|
0
|
open(CONFIG, ">$configFile") || |
946
|
|
|
|
|
|
|
die "Could not open configuration file: $configFile\n"; |
947
|
|
|
|
|
|
|
|
948
|
0
|
|
|
|
|
0
|
my @sarray = (); |
949
|
0
|
|
|
|
|
0
|
my @rarray = (); |
950
|
|
|
|
|
|
|
|
951
|
0
|
|
|
|
|
0
|
print CONFIG "SAB :: include "; |
952
|
0
|
|
|
|
|
0
|
while($sources=~/=\'(.*?)\'/g) { push @sarray, $1; } |
|
0
|
|
|
|
|
0
|
|
953
|
0
|
|
|
|
|
0
|
my $slist = join ", ", @sarray; |
954
|
0
|
|
|
|
|
0
|
print CONFIG "$slist\n"; |
955
|
|
|
|
|
|
|
|
956
|
0
|
|
|
|
|
0
|
print CONFIG "REL :: include "; |
957
|
0
|
|
|
|
|
0
|
while($relations=~/=\'(.*?)\'/g) { push @rarray, $1; } |
|
0
|
|
|
|
|
0
|
|
958
|
0
|
|
|
|
|
0
|
my $rlist = join ", ", @rarray; |
959
|
0
|
|
|
|
|
0
|
print CONFIG "$rlist\n"; |
960
|
|
|
|
|
|
|
|
961
|
0
|
|
|
|
|
0
|
close CONFIG; |
962
|
|
|
|
|
|
|
|
963
|
0
|
|
|
|
|
0
|
my $temp = chmod 0777, $configFile; |
964
|
|
|
|
|
|
|
} |
965
|
|
|
|
|
|
|
} |
966
|
|
|
|
|
|
|
} |
967
|
|
|
|
|
|
|
|
968
|
|
|
|
|
|
|
|
969
|
|
|
|
|
|
|
# set the table and file names that store the upper level taxonomy and path information |
970
|
|
|
|
|
|
|
# input : |
971
|
|
|
|
|
|
|
# output: |
972
|
|
|
|
|
|
|
sub _setConfigurationFile { |
973
|
|
|
|
|
|
|
|
974
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
975
|
|
|
|
|
|
|
|
976
|
0
|
|
|
|
|
0
|
my $function = "_setConfigurationFile"; |
977
|
0
|
|
|
|
|
0
|
&_debug($function); |
978
|
|
|
|
|
|
|
|
979
|
|
|
|
|
|
|
# check self |
980
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
981
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
982
|
|
|
|
|
|
|
} |
983
|
|
|
|
|
|
|
|
984
|
|
|
|
|
|
|
# get the database name that we are using |
985
|
0
|
|
|
|
|
0
|
my $database = $self->{'database'}; |
986
|
|
|
|
|
|
|
|
987
|
|
|
|
|
|
|
# set appropriate version output |
988
|
0
|
|
|
|
|
0
|
my $ver = $version; |
989
|
0
|
|
|
|
|
0
|
$ver=~s/-/_/g; |
990
|
|
|
|
|
|
|
|
991
|
|
|
|
|
|
|
# set table and upper level relations files as well the |
992
|
|
|
|
|
|
|
# output of the configuration information for the user |
993
|
0
|
|
|
|
|
0
|
$childFile = "$umlsinterface/$ver"; |
994
|
0
|
|
|
|
|
0
|
$parentFile = "$umlsinterface/$ver"; |
995
|
0
|
|
|
|
|
0
|
$tableFile = "$umlsinterface/$ver"; |
996
|
|
|
|
|
|
|
|
997
|
0
|
|
|
|
|
0
|
$configFile = "$umlsinterface/$ver"; |
998
|
|
|
|
|
|
|
|
999
|
0
|
|
|
|
|
0
|
$tableName = "$ver"; |
1000
|
0
|
|
|
|
|
0
|
$intrinsicTable= "$ver"; |
1001
|
0
|
|
|
|
|
0
|
$parentTable = "$ver"; |
1002
|
0
|
|
|
|
|
0
|
$childTable = "$ver"; |
1003
|
0
|
|
|
|
|
0
|
$infoTable = "$ver"; |
1004
|
0
|
|
|
|
|
0
|
$cacheTable = "$ver"; |
1005
|
|
|
|
|
|
|
|
1006
|
0
|
|
|
|
|
0
|
my $output = ""; |
1007
|
0
|
|
|
|
|
0
|
$output .= "UMLS-Interface Configuration Information\n"; |
1008
|
|
|
|
|
|
|
|
1009
|
0
|
|
|
|
|
0
|
my $saboutput = ""; |
1010
|
0
|
|
|
|
|
0
|
my %sabs = (); |
1011
|
0
|
0
|
|
|
|
0
|
if($defflag == 1) { |
1012
|
0
|
|
|
|
|
0
|
$output .= " Sources (SABDEF):\n"; |
1013
|
0
|
|
|
|
|
0
|
foreach my $sab (sort keys %sabDefHash) { $saboutput .= " $sab\n"; } |
|
0
|
|
|
|
|
0
|
|
1014
|
|
|
|
|
|
|
} |
1015
|
|
|
|
|
|
|
else { |
1016
|
0
|
|
|
|
|
0
|
$output .= " Sources (SAB):\n"; |
1017
|
0
|
|
|
|
|
0
|
foreach my $sab (sort keys %sabnamesHash) { $saboutput .= " $sab\n"; } |
|
0
|
|
|
|
|
0
|
|
1018
|
|
|
|
|
|
|
} |
1019
|
|
|
|
|
|
|
|
1020
|
|
|
|
|
|
|
|
1021
|
0
|
|
|
|
|
0
|
foreach my $sab (sort keys %sabnamesHash) { |
1022
|
0
|
|
|
|
|
0
|
$tableFile .= "_$sab"; |
1023
|
0
|
|
|
|
|
0
|
$childFile .= "_$sab"; |
1024
|
0
|
|
|
|
|
0
|
$parentFile .= "_$sab"; |
1025
|
0
|
|
|
|
|
0
|
$configFile .= "_$sab"; |
1026
|
0
|
|
|
|
|
0
|
$tableName .= "_$sab"; |
1027
|
0
|
|
|
|
|
0
|
$intrinsicTable.= "_$sab"; |
1028
|
0
|
|
|
|
|
0
|
$parentTable .= "_$sab"; |
1029
|
0
|
|
|
|
|
0
|
$childTable .= "_$sab"; |
1030
|
0
|
|
|
|
|
0
|
$cacheTable .= "_$sab"; |
1031
|
0
|
|
|
|
|
0
|
$infoTable .= "_$sab"; |
1032
|
|
|
|
|
|
|
} |
1033
|
|
|
|
|
|
|
|
1034
|
0
|
0
|
|
|
|
0
|
if($umlsall) { |
1035
|
0
|
|
|
|
|
0
|
$output .= " UMLS_ALL\n"; |
1036
|
|
|
|
|
|
|
} |
1037
|
|
|
|
|
|
|
else { |
1038
|
0
|
|
|
|
|
0
|
$output .= $saboutput; |
1039
|
|
|
|
|
|
|
} |
1040
|
|
|
|
|
|
|
|
1041
|
|
|
|
|
|
|
# seperate the RELs and the RELAs from $relations |
1042
|
0
|
|
|
|
|
0
|
my %rels = (); my %relas = (); |
|
0
|
|
|
|
|
0
|
|
1043
|
|
|
|
|
|
|
|
1044
|
|
|
|
|
|
|
|
1045
|
0
|
0
|
|
|
|
0
|
if($defflag == 1) { |
1046
|
0
|
|
|
|
|
0
|
$output .= " Relations (RELDEF):\n"; |
1047
|
0
|
|
|
|
|
0
|
foreach my $rel (sort keys %relDefHash) { $rels{$rel}++; } |
|
0
|
|
|
|
|
0
|
|
1048
|
|
|
|
|
|
|
} |
1049
|
|
|
|
|
|
|
else { |
1050
|
0
|
|
|
|
|
0
|
$output .= " Relations (REL):\n"; |
1051
|
0
|
|
|
|
|
0
|
while($relations=~/=\'(.*?)\'/g) { |
1052
|
0
|
|
|
|
|
0
|
my $rel = $1; |
1053
|
0
|
0
|
|
|
|
0
|
if($rel=~/[a-z\_]+/) { $relas{$rel}++; } |
|
0
|
|
|
|
|
0
|
|
1054
|
0
|
|
|
|
|
0
|
else { $rels{$rel}++; } |
1055
|
|
|
|
|
|
|
} |
1056
|
|
|
|
|
|
|
} |
1057
|
|
|
|
|
|
|
|
1058
|
0
|
|
|
|
|
0
|
foreach my $rel (sort keys %rels) { |
1059
|
0
|
|
|
|
|
0
|
$tableFile .= "_$rel"; |
1060
|
0
|
|
|
|
|
0
|
$childFile .= "_$rel"; |
1061
|
0
|
|
|
|
|
0
|
$parentFile .= "_$rel"; |
1062
|
0
|
|
|
|
|
0
|
$configFile .= "_$rel"; |
1063
|
0
|
|
|
|
|
0
|
$tableName .= "_$rel"; |
1064
|
0
|
|
|
|
|
0
|
$intrinsicTable.= "_$rel"; |
1065
|
0
|
|
|
|
|
0
|
$parentTable .= "_$rel"; |
1066
|
0
|
|
|
|
|
0
|
$childTable .= "_$rel"; |
1067
|
0
|
|
|
|
|
0
|
$cacheTable .= "_$rel"; |
1068
|
0
|
|
|
|
|
0
|
$infoTable .= "_$rel"; |
1069
|
|
|
|
|
|
|
|
1070
|
0
|
|
|
|
|
0
|
$output .= " $rel\n"; |
1071
|
|
|
|
|
|
|
} |
1072
|
|
|
|
|
|
|
|
1073
|
0
|
|
|
|
|
0
|
my $rak = keys %relas; |
1074
|
0
|
0
|
|
|
|
0
|
if($rak > 0) { |
1075
|
0
|
0
|
|
|
|
0
|
if($defflag == 1) { |
1076
|
0
|
|
|
|
|
0
|
$output .= " Relations (RELADEF):\n"; |
1077
|
|
|
|
|
|
|
} |
1078
|
|
|
|
|
|
|
else { |
1079
|
0
|
|
|
|
|
0
|
$output .= " Relations (RELA):\n"; |
1080
|
|
|
|
|
|
|
} |
1081
|
|
|
|
|
|
|
} |
1082
|
0
|
|
|
|
|
0
|
foreach my $rel (sort keys %relas) { |
1083
|
0
|
|
|
|
|
0
|
$tableFile .= "_$rel"; |
1084
|
0
|
|
|
|
|
0
|
$childFile .= "_$rel"; |
1085
|
0
|
|
|
|
|
0
|
$parentFile .= "_$rel"; |
1086
|
0
|
|
|
|
|
0
|
$configFile .= "_$rel"; |
1087
|
0
|
|
|
|
|
0
|
$tableName .= "_$rel"; |
1088
|
0
|
|
|
|
|
0
|
$intrinsicTable.= "_$rel"; |
1089
|
0
|
|
|
|
|
0
|
$parentTable .= "_$rel"; |
1090
|
0
|
|
|
|
|
0
|
$childTable .= "_$rel"; |
1091
|
0
|
|
|
|
|
0
|
$cacheTable .= "_$rel"; |
1092
|
0
|
|
|
|
|
0
|
$infoTable .= "_$rel"; |
1093
|
|
|
|
|
|
|
|
1094
|
0
|
|
|
|
|
0
|
$output .= " $rel\n"; |
1095
|
|
|
|
|
|
|
} |
1096
|
|
|
|
|
|
|
|
1097
|
0
|
|
|
|
|
0
|
$tableFile .= "_table"; |
1098
|
0
|
|
|
|
|
0
|
$childFile .= "_child"; |
1099
|
0
|
|
|
|
|
0
|
$parentFile .= "_parent"; |
1100
|
0
|
|
|
|
|
0
|
$configFile .= "_config"; |
1101
|
0
|
|
|
|
|
0
|
$tableName .= "_table"; |
1102
|
0
|
|
|
|
|
0
|
$intrinsicTable.= "_intrinsic"; |
1103
|
0
|
|
|
|
|
0
|
$parentTable .= "_parent"; |
1104
|
0
|
|
|
|
|
0
|
$childTable .= "_child"; |
1105
|
0
|
|
|
|
|
0
|
$cacheTable .= "_cache"; |
1106
|
0
|
|
|
|
|
0
|
$infoTable .= "_info"; |
1107
|
|
|
|
|
|
|
|
1108
|
|
|
|
|
|
|
# convert the databases to the hex name |
1109
|
|
|
|
|
|
|
# and store the human readable form |
1110
|
0
|
|
|
|
|
0
|
$tableNameHuman = $tableName; |
1111
|
0
|
|
|
|
|
0
|
$intrinsicTableHuman = $intrinsicTable; |
1112
|
0
|
|
|
|
|
0
|
$childTableHuman = $childTable; |
1113
|
0
|
|
|
|
|
0
|
$cacheTableHuman = $cacheTable; |
1114
|
0
|
|
|
|
|
0
|
$parentTableHuman = $parentTable; |
1115
|
0
|
|
|
|
|
0
|
$infoTableHuman = $infoTable; |
1116
|
|
|
|
|
|
|
|
1117
|
0
|
|
|
|
|
0
|
$tableName = "a" . sha1_hex($tableNameHuman); |
1118
|
0
|
|
|
|
|
0
|
$intrinsicTable = "a" . sha1_hex($intrinsicTableHuman); |
1119
|
0
|
|
|
|
|
0
|
$childTable = "a" . sha1_hex($childTableHuman); |
1120
|
0
|
|
|
|
|
0
|
$parentTable = "a" . sha1_hex($parentTableHuman); |
1121
|
0
|
|
|
|
|
0
|
$infoTable = "a" . sha1_hex($infoTableHuman); |
1122
|
0
|
|
|
|
|
0
|
$cacheTable = "a" . sha1_hex($cacheTableHuman); |
1123
|
|
|
|
|
|
|
|
1124
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
1125
|
0
|
|
|
|
|
0
|
$output .= " Configuration file:\n"; |
1126
|
0
|
|
|
|
|
0
|
$output .= " $configFile\n"; |
1127
|
|
|
|
|
|
|
} |
1128
|
|
|
|
|
|
|
|
1129
|
0
|
|
|
|
|
0
|
$output .= " Database: \n"; |
1130
|
0
|
|
|
|
|
0
|
$output .= " $database ($version)\n\n"; |
1131
|
|
|
|
|
|
|
|
1132
|
0
|
0
|
|
|
|
0
|
if($option_t == 0) { |
1133
|
0
|
0
|
|
|
|
0
|
if($option_config) { |
1134
|
0
|
|
|
|
|
0
|
print STDERR "$output\n"; |
1135
|
|
|
|
|
|
|
} |
1136
|
|
|
|
|
|
|
else { |
1137
|
0
|
|
|
|
|
0
|
print STDERR "UMLS-Interface Configuration Information:\n"; |
1138
|
0
|
|
|
|
|
0
|
print STDERR "(Default Information - no config file)\n\n"; |
1139
|
0
|
|
|
|
|
0
|
print STDERR " Sources (SAB):\n"; |
1140
|
0
|
|
|
|
|
0
|
print STDERR " MSH\n"; |
1141
|
0
|
|
|
|
|
0
|
print STDERR " Relations (REL):\n"; |
1142
|
0
|
|
|
|
|
0
|
print STDERR " PAR\n"; |
1143
|
0
|
|
|
|
|
0
|
print STDERR " CHD\n\n"; |
1144
|
0
|
|
|
|
|
0
|
print STDERR " Sources (SABDEF):\n"; |
1145
|
0
|
|
|
|
|
0
|
print STDERR " UMLS_ALL\n"; |
1146
|
0
|
|
|
|
|
0
|
print STDERR " Relations (RELDEF):\n"; |
1147
|
0
|
|
|
|
|
0
|
print STDERR " UMLS_ALL\n"; |
1148
|
|
|
|
|
|
|
} |
1149
|
|
|
|
|
|
|
} |
1150
|
|
|
|
|
|
|
} |
1151
|
|
|
|
|
|
|
|
1152
|
|
|
|
|
|
|
# set the configuration environment variable |
1153
|
|
|
|
|
|
|
# input : |
1154
|
|
|
|
|
|
|
# output: |
1155
|
|
|
|
|
|
|
sub _setEnvironmentVariable { |
1156
|
|
|
|
|
|
|
|
1157
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1158
|
|
|
|
|
|
|
|
1159
|
0
|
|
|
|
|
0
|
my $function = "_setEnvironmentVariable"; |
1160
|
0
|
|
|
|
|
0
|
&_debug($function); |
1161
|
|
|
|
|
|
|
|
1162
|
|
|
|
|
|
|
# check self |
1163
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1164
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1165
|
|
|
|
|
|
|
} |
1166
|
|
|
|
|
|
|
|
1167
|
0
|
0
|
|
|
|
0
|
if($option_verbose) { |
1168
|
0
|
0
|
|
|
|
0
|
if(! (defined $umlsinterface) ) { |
1169
|
0
|
|
|
|
|
0
|
my $answerFlag = 0; |
1170
|
0
|
|
|
|
|
0
|
my $interfaceFlag = 0; |
1171
|
|
|
|
|
|
|
|
1172
|
0
|
|
|
|
|
0
|
while(! ($interfaceFlag) ) { |
1173
|
|
|
|
|
|
|
|
1174
|
0
|
|
|
|
|
0
|
print STDERR "The UMLSINTERFACE_CONFIGFILE_DIR environment\n"; |
1175
|
0
|
|
|
|
|
0
|
print STDERR "variable has not been defined yet. Please \n"; |
1176
|
0
|
|
|
|
|
0
|
print STDERR "enter a location that the UMLS-Interface can\n"; |
1177
|
0
|
|
|
|
|
0
|
print STDERR "use to store its configuration files:\n"; |
1178
|
|
|
|
|
|
|
|
1179
|
0
|
|
|
|
|
0
|
$umlsinterface = ; chomp $umlsinterface; |
|
0
|
|
|
|
|
0
|
|
1180
|
|
|
|
|
|
|
|
1181
|
0
|
|
|
|
|
0
|
while(! ($answerFlag)) { |
1182
|
0
|
|
|
|
|
0
|
print STDERR " Is $umlsinterface the correct location? "; |
1183
|
0
|
|
|
|
|
0
|
my $answer = ; chomp $answer; |
|
0
|
|
|
|
|
0
|
|
1184
|
0
|
0
|
|
|
|
0
|
if($answer=~/[Yy]/) { |
1185
|
0
|
|
|
|
|
0
|
$answerFlag = 1; |
1186
|
0
|
|
|
|
|
0
|
$interfaceFlag = 1; |
1187
|
|
|
|
|
|
|
} |
1188
|
|
|
|
|
|
|
else { |
1189
|
0
|
|
|
|
|
0
|
print STDERR "Please entire in location:\n"; |
1190
|
0
|
|
|
|
|
0
|
$umlsinterface = ; chomp $umlsinterface; |
|
0
|
|
|
|
|
0
|
|
1191
|
|
|
|
|
|
|
} |
1192
|
|
|
|
|
|
|
} |
1193
|
|
|
|
|
|
|
|
1194
|
0
|
0
|
|
|
|
0
|
if(! (-e $umlsinterface) ) { |
1195
|
0
|
|
|
|
|
0
|
system "mkdir -m 777 $umlsinterface"; |
1196
|
|
|
|
|
|
|
} |
1197
|
|
|
|
|
|
|
|
1198
|
0
|
|
|
|
|
0
|
print STDERR "Please set the UMLSINTERFACE_CONFIGFILE_DIR variable:\n\n"; |
1199
|
0
|
|
|
|
|
0
|
print STDERR "It can be set in csh as follows:\n\n"; |
1200
|
0
|
|
|
|
|
0
|
print STDERR " setenv UMLSINTERFACE_CONFIGFILE_DIR $umlsinterface\n\n"; |
1201
|
0
|
|
|
|
|
0
|
print STDERR "And in bash shell:\n\n"; |
1202
|
0
|
|
|
|
|
0
|
print STDERR " export UMLSINTERFACE_CONFIGFILE_DIR=$umlsinterface\n\n"; |
1203
|
0
|
|
|
|
|
0
|
print STDERR "Thank you!\n\n"; |
1204
|
|
|
|
|
|
|
} |
1205
|
|
|
|
|
|
|
} |
1206
|
|
|
|
|
|
|
} |
1207
|
|
|
|
|
|
|
else { |
1208
|
0
|
|
|
|
|
0
|
$umlsinterface = ""; |
1209
|
|
|
|
|
|
|
} |
1210
|
|
|
|
|
|
|
} |
1211
|
|
|
|
|
|
|
|
1212
|
|
|
|
|
|
|
# sets the relations, parentRelations and childRelations |
1213
|
|
|
|
|
|
|
# variables from the information in the config file |
1214
|
|
|
|
|
|
|
# input : $includerelkeys <- integer |
1215
|
|
|
|
|
|
|
# : $excluderelkeys <- integer |
1216
|
|
|
|
|
|
|
# : $includerel <- reference to hash |
1217
|
|
|
|
|
|
|
# : $excluderel <- reference to hash |
1218
|
|
|
|
|
|
|
# output: |
1219
|
|
|
|
|
|
|
sub _setRelations { |
1220
|
|
|
|
|
|
|
|
1221
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1222
|
0
|
|
|
|
|
0
|
my $includerelkeys = shift; |
1223
|
0
|
|
|
|
|
0
|
my $excluderelkeys = shift; |
1224
|
0
|
|
|
|
|
0
|
my $includerel = shift; |
1225
|
0
|
|
|
|
|
0
|
my $excluderel = shift; |
1226
|
|
|
|
|
|
|
|
1227
|
0
|
|
|
|
|
0
|
my $function = "_setRelations"; |
1228
|
0
|
|
|
|
|
0
|
&_debug($function); |
1229
|
|
|
|
|
|
|
|
1230
|
|
|
|
|
|
|
# check self |
1231
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1232
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1233
|
|
|
|
|
|
|
} |
1234
|
|
|
|
|
|
|
|
1235
|
|
|
|
|
|
|
# check the parameters |
1236
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includerelkeys) || !(defined $excluderelkeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1237
|
|
|
|
|
|
|
!(defined $includerel) || !(defined $excluderel)) { |
1238
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "REL variables not defined.", 4); |
1239
|
|
|
|
|
|
|
} |
1240
|
|
|
|
|
|
|
|
1241
|
0
|
0
|
0
|
|
|
0
|
if($includerelkeys <= 0 && $excluderelkeys <=0) { return; } |
|
0
|
|
|
|
|
0
|
|
1242
|
|
|
|
|
|
|
|
1243
|
|
|
|
|
|
|
# if the umls all option is set clear out the the includerel hash and |
1244
|
|
|
|
|
|
|
# add the umlsall to the exclude. This way all should be included since |
1245
|
|
|
|
|
|
|
# there will never be a source called UMLS_ALL - this is a bit of a dirty |
1246
|
|
|
|
|
|
|
# swap but I think it will simplify the code and work |
1247
|
0
|
0
|
|
|
|
0
|
if(exists ${$includerel}{"UMLS_ALL"}) { |
|
0
|
|
|
|
|
0
|
|
1248
|
0
|
|
|
|
|
0
|
$includerel = ""; $includerelkeys = 0; |
|
0
|
|
|
|
|
0
|
|
1249
|
0
|
|
|
|
|
0
|
${$excluderel}{"UMLS_ALL"} = 1; $excluderelkeys = 1; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1250
|
|
|
|
|
|
|
|
1251
|
|
|
|
|
|
|
} |
1252
|
|
|
|
|
|
|
|
1253
|
|
|
|
|
|
|
# set the database |
1254
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1255
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1256
|
|
|
|
|
|
|
|
1257
|
0
|
|
|
|
|
0
|
$parentRelations = "("; |
1258
|
0
|
|
|
|
|
0
|
$childRelations = "("; |
1259
|
0
|
|
|
|
|
0
|
$relations = "("; |
1260
|
|
|
|
|
|
|
|
1261
|
|
|
|
|
|
|
# get the relations |
1262
|
0
|
|
|
|
|
0
|
my @array = (); |
1263
|
0
|
0
|
|
|
|
0
|
if($includerelkeys > 0) { |
1264
|
0
|
|
|
|
|
0
|
@array = keys %{$includerel}; |
|
0
|
|
|
|
|
0
|
|
1265
|
|
|
|
|
|
|
} |
1266
|
|
|
|
|
|
|
else { |
1267
|
|
|
|
|
|
|
|
1268
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct REL from MRREL"); |
1269
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1270
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1271
|
|
|
|
|
|
|
} |
1272
|
|
|
|
|
|
|
|
1273
|
|
|
|
|
|
|
|
1274
|
0
|
|
|
|
|
0
|
my $relcount = 0; |
1275
|
0
|
|
|
|
|
0
|
my @parents = (); |
1276
|
0
|
|
|
|
|
0
|
my @children = (); |
1277
|
0
|
|
|
|
|
0
|
foreach my $rel (@array) { |
1278
|
|
|
|
|
|
|
|
1279
|
0
|
|
|
|
|
0
|
$relcount++; |
1280
|
|
|
|
|
|
|
|
1281
|
|
|
|
|
|
|
# if we are excluding check to see if this one should be excluded |
1282
|
0
|
0
|
0
|
|
|
0
|
if( ($excluderelkeys > 0) and (exists ${$excluderel}{$rel}) ) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1283
|
|
|
|
|
|
|
|
1284
|
|
|
|
|
|
|
# otherwise store the relation in the relations variable |
1285
|
0
|
0
|
|
|
|
0
|
if($relcount == ($#array+1)) { $relations .= "REL=\'$rel\'"; } |
|
0
|
|
|
|
|
0
|
|
1286
|
0
|
|
|
|
|
0
|
else { $relations .= "REL=\'$rel\' or "; } |
1287
|
|
|
|
|
|
|
|
1288
|
|
|
|
|
|
|
# put it in its proper parent or child array |
1289
|
0
|
0
|
|
|
|
0
|
if ($rel=~/(PAR|RB)/) { push @parents, $rel; } |
|
0
|
0
|
|
|
|
0
|
|
1290
|
0
|
|
|
|
|
0
|
elsif($rel=~/(CHD|RN)/) { push @children, $rel; } |
1291
|
0
|
|
|
|
|
0
|
else { push @parents, $rel; push @children, $rel; } |
|
0
|
|
|
|
|
0
|
|
1292
|
|
|
|
|
|
|
|
1293
|
|
|
|
|
|
|
} |
1294
|
|
|
|
|
|
|
|
1295
|
|
|
|
|
|
|
# set the parentRelations and childRelations variables |
1296
|
0
|
0
|
|
|
|
0
|
if($#parents >= 0) { |
1297
|
0
|
|
|
|
|
0
|
for my $i (0..($#parents-1)) { |
1298
|
0
|
|
|
|
|
0
|
$parentRelations .= "REL=\'$parents[$i]\' or "; |
1299
|
0
|
|
|
|
|
0
|
} $parentRelations .= "REL=\'$parents[$#parents]\'"; |
1300
|
|
|
|
|
|
|
} |
1301
|
0
|
0
|
|
|
|
0
|
if($#children >= 0) { |
1302
|
0
|
|
|
|
|
0
|
for my $i (0..($#children-1)) { |
1303
|
0
|
|
|
|
|
0
|
$childRelations .= "REL=\'$children[$i]\' or "; |
1304
|
0
|
|
|
|
|
0
|
} $childRelations .= "REL=\'$children[$#children]\'"; |
1305
|
|
|
|
|
|
|
} |
1306
|
|
|
|
|
|
|
|
1307
|
0
|
|
|
|
|
0
|
$parentRelations .= ") "; |
1308
|
0
|
|
|
|
|
0
|
$childRelations .= ") "; |
1309
|
0
|
|
|
|
|
0
|
$relations .= ") "; |
1310
|
|
|
|
|
|
|
|
1311
|
|
|
|
|
|
|
} |
1312
|
|
|
|
|
|
|
|
1313
|
|
|
|
|
|
|
# sets the source variables from the information in the config file |
1314
|
|
|
|
|
|
|
# input : $includesabdefkeys <- integer |
1315
|
|
|
|
|
|
|
# : $excludesabdefkeys <- integer |
1316
|
|
|
|
|
|
|
# : $includedefsab <- reference to hash |
1317
|
|
|
|
|
|
|
# : $excludedefsab <- reference to hash |
1318
|
|
|
|
|
|
|
# output: |
1319
|
|
|
|
|
|
|
sub _setSabDef { |
1320
|
|
|
|
|
|
|
|
1321
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1322
|
0
|
|
|
|
|
0
|
my $includesabdefkeys = shift; |
1323
|
0
|
|
|
|
|
0
|
my $excludesabdefkeys = shift; |
1324
|
0
|
|
|
|
|
0
|
my $includesabdef = shift; |
1325
|
0
|
|
|
|
|
0
|
my $excludesabdef = shift; |
1326
|
|
|
|
|
|
|
|
1327
|
0
|
|
|
|
|
0
|
my $function = "_setSabDef"; |
1328
|
0
|
|
|
|
|
0
|
&_debug($function); |
1329
|
|
|
|
|
|
|
|
1330
|
|
|
|
|
|
|
# check self |
1331
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1332
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1333
|
|
|
|
|
|
|
} |
1334
|
|
|
|
|
|
|
|
1335
|
|
|
|
|
|
|
# check the parameters are defined |
1336
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includesabdefkeys) || !(defined $excludesabdefkeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1337
|
|
|
|
|
|
|
!(defined $includesabdef) || !(defined $excludesabdef)) { |
1338
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "SAB variables not defined", 4); |
1339
|
|
|
|
|
|
|
} |
1340
|
|
|
|
|
|
|
|
1341
|
0
|
0
|
0
|
|
|
0
|
if($includesabdefkeys <= 0 && $excludesabdefkeys <=0) { return; } |
|
0
|
|
|
|
|
0
|
|
1342
|
|
|
|
|
|
|
|
1343
|
0
|
|
|
|
|
0
|
$sabdef_umlsall = 0; |
1344
|
|
|
|
|
|
|
|
1345
|
|
|
|
|
|
|
# if the umls all option is set clear out the the includesabdef hash and |
1346
|
|
|
|
|
|
|
# add the umlsall to the exclude. This way all should be included since |
1347
|
|
|
|
|
|
|
# there will never be a source called UMLS_ALL - this is a bit of a dirty |
1348
|
|
|
|
|
|
|
# swap but I think it will simplify the code and work |
1349
|
0
|
0
|
|
|
|
0
|
if(exists ${$includesabdef}{"UMLS_ALL"}) { |
|
0
|
|
|
|
|
0
|
|
1350
|
0
|
|
|
|
|
0
|
$includesabdef = ""; $includesabdefkeys = 0; |
|
0
|
|
|
|
|
0
|
|
1351
|
0
|
|
|
|
|
0
|
${$excludesabdef}{"UMLS_ALL"} = 1; $excludesabdefkeys = 1; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1352
|
0
|
|
|
|
|
0
|
$sabdef_umlsall = 1; |
1353
|
|
|
|
|
|
|
} |
1354
|
|
|
|
|
|
|
|
1355
|
|
|
|
|
|
|
# check that the db is defined |
1356
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1357
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1358
|
|
|
|
|
|
|
|
1359
|
|
|
|
|
|
|
# get the sabs |
1360
|
0
|
|
|
|
|
0
|
my @array = (); |
1361
|
0
|
0
|
|
|
|
0
|
if($includesabdefkeys > 0) { |
1362
|
0
|
|
|
|
|
0
|
@array = keys %{$includesabdef}; |
|
0
|
|
|
|
|
0
|
|
1363
|
|
|
|
|
|
|
} |
1364
|
|
|
|
|
|
|
else { |
1365
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct SAB from MRREL"); |
1366
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1367
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1368
|
|
|
|
|
|
|
} |
1369
|
|
|
|
|
|
|
|
1370
|
|
|
|
|
|
|
# get the sabs |
1371
|
0
|
|
|
|
|
0
|
my $sabcount = 0; my @sabarray = (); |
|
0
|
|
|
|
|
0
|
|
1372
|
0
|
|
|
|
|
0
|
foreach my $sab (@array) { |
1373
|
0
|
|
|
|
|
0
|
$sabcount++; |
1374
|
|
|
|
|
|
|
|
1375
|
|
|
|
|
|
|
# if we are excluding check to see if this sab can be included |
1376
|
0
|
0
|
0
|
|
|
0
|
if(($excludesabdefkeys > 0) and (exists ${$excludesabdef}{$sab})) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1377
|
|
|
|
|
|
|
|
1378
|
|
|
|
|
|
|
# otherwise store it in the sabdef hash and store it in the array |
1379
|
0
|
|
|
|
|
0
|
push @sabarray, "SAB=\'$sab\'"; |
1380
|
|
|
|
|
|
|
|
1381
|
0
|
|
|
|
|
0
|
$sabDefHash{$sab}++; |
1382
|
|
|
|
|
|
|
} |
1383
|
|
|
|
|
|
|
|
1384
|
0
|
0
|
|
|
|
0
|
if(!$sabdef_umlsall) { |
1385
|
0
|
|
|
|
|
0
|
my $string = join " or ", @sabarray; |
1386
|
0
|
|
|
|
|
0
|
$sabdefsources = "( $string )"; |
1387
|
|
|
|
|
|
|
} |
1388
|
|
|
|
|
|
|
} |
1389
|
|
|
|
|
|
|
|
1390
|
|
|
|
|
|
|
# sets the relations, parentRelations and childRelations |
1391
|
|
|
|
|
|
|
# variables from the information in the config file |
1392
|
|
|
|
|
|
|
# input : $includereldefkeys <- integer |
1393
|
|
|
|
|
|
|
# : $excludereldefkeys <- integer |
1394
|
|
|
|
|
|
|
# : $includereldef <- reference to hash |
1395
|
|
|
|
|
|
|
# : $excludereldef <- reference to hash |
1396
|
|
|
|
|
|
|
# output: |
1397
|
|
|
|
|
|
|
sub _setRelDef { |
1398
|
|
|
|
|
|
|
|
1399
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1400
|
0
|
|
|
|
|
0
|
my $includereldefkeys = shift; |
1401
|
0
|
|
|
|
|
0
|
my $excludereldefkeys = shift; |
1402
|
0
|
|
|
|
|
0
|
my $includereldef = shift; |
1403
|
0
|
|
|
|
|
0
|
my $excludereldef = shift; |
1404
|
|
|
|
|
|
|
|
1405
|
0
|
|
|
|
|
0
|
my $function = "_setRelDef"; |
1406
|
0
|
|
|
|
|
0
|
&_debug($function); |
1407
|
|
|
|
|
|
|
|
1408
|
|
|
|
|
|
|
# check self |
1409
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1410
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1411
|
|
|
|
|
|
|
} |
1412
|
|
|
|
|
|
|
|
1413
|
|
|
|
|
|
|
# check the parameters are defined |
1414
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includereldefkeys) || !(defined $excludereldefkeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1415
|
|
|
|
|
|
|
!(defined $includereldef) || !(defined $excludereldef)) { |
1416
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "RELDEF variables not defined.", 4); |
1417
|
|
|
|
|
|
|
} |
1418
|
|
|
|
|
|
|
|
1419
|
0
|
0
|
0
|
|
|
0
|
if($includereldefkeys <= 0 && $excludereldefkeys <=0) { return; } |
|
0
|
|
|
|
|
0
|
|
1420
|
|
|
|
|
|
|
|
1421
|
|
|
|
|
|
|
# if the umls all option is set clear out the the includereldef hash and |
1422
|
|
|
|
|
|
|
# add the umlsall to the exclude. This way all should be included since |
1423
|
|
|
|
|
|
|
# there will never be a source called UMLS_ALL - this is a bit of a dirty |
1424
|
|
|
|
|
|
|
# swap but I think it will simplify the code and work |
1425
|
0
|
0
|
|
|
|
0
|
if(exists ${$includereldef}{"UMLS_ALL"}) { |
|
0
|
|
|
|
|
0
|
|
1426
|
0
|
|
|
|
|
0
|
$includereldef = ""; $includereldefkeys = 0; |
|
0
|
|
|
|
|
0
|
|
1427
|
0
|
|
|
|
|
0
|
${$excludereldef}{"UMLS_ALL"} = 1; $excludereldefkeys = 1; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1428
|
|
|
|
|
|
|
} |
1429
|
|
|
|
|
|
|
|
1430
|
|
|
|
|
|
|
# set the database |
1431
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1432
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1433
|
|
|
|
|
|
|
|
1434
|
|
|
|
|
|
|
# get the relations |
1435
|
0
|
|
|
|
|
0
|
my @array = (); |
1436
|
0
|
0
|
|
|
|
0
|
if($includereldefkeys > 0) { |
1437
|
0
|
|
|
|
|
0
|
@array = keys %{$includereldef}; |
|
0
|
|
|
|
|
0
|
|
1438
|
|
|
|
|
|
|
} |
1439
|
|
|
|
|
|
|
else { |
1440
|
|
|
|
|
|
|
|
1441
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct REL from MRREL"); |
1442
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1443
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1444
|
|
|
|
|
|
|
} |
1445
|
|
|
|
|
|
|
|
1446
|
0
|
|
|
|
|
0
|
my $relcount = 0; |
1447
|
|
|
|
|
|
|
|
1448
|
0
|
|
|
|
|
0
|
foreach my $rel (@array) { |
1449
|
|
|
|
|
|
|
|
1450
|
0
|
|
|
|
|
0
|
$relcount++; |
1451
|
|
|
|
|
|
|
|
1452
|
|
|
|
|
|
|
# if we are excluding check to see if this one should be excluded |
1453
|
0
|
0
|
0
|
|
|
0
|
if( ($excludereldefkeys > 0) and (exists ${$excludereldef}{$rel}) ) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1454
|
|
|
|
|
|
|
|
1455
|
|
|
|
|
|
|
# otherwise store the relation in the reldef hash |
1456
|
0
|
|
|
|
|
0
|
$relDefHash{$rel}++; |
1457
|
|
|
|
|
|
|
} |
1458
|
|
|
|
|
|
|
|
1459
|
|
|
|
|
|
|
|
1460
|
|
|
|
|
|
|
# now add the TERM and CUI which are not actual relations but should be in |
1461
|
|
|
|
|
|
|
# the relDefHash if in the includereldef or not in the excludereldef or |
1462
|
|
|
|
|
|
|
# nothing has been defined |
1463
|
0
|
0
|
|
|
|
0
|
if($includereldefkeys > 0) { |
|
|
0
|
|
|
|
|
|
1464
|
0
|
0
|
|
|
|
0
|
if(exists ${$includereldef}{"TERM"}) { $relDefHash{"TERM"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1465
|
0
|
0
|
|
|
|
0
|
if(exists ${$includereldef}{"CUI"}) { $relDefHash{"CUI"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1466
|
0
|
0
|
|
|
|
0
|
if(exists ${$includereldef}{"ST"}) { $relDefHash{"ST"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1467
|
|
|
|
|
|
|
} |
1468
|
|
|
|
|
|
|
elsif($excludereldefkeys > 0) { |
1469
|
0
|
0
|
|
|
|
0
|
if(! exists ${$excludereldef}{"TERM"}) { $relDefHash{"TERM"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1470
|
0
|
0
|
|
|
|
0
|
if(! exists ${$excludereldef}{"CUI"}) { $relDefHash{"CUI"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1471
|
0
|
0
|
|
|
|
0
|
if(! exists ${$excludereldef}{"ST"}) { $relDefHash{"ST"}++; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1472
|
|
|
|
|
|
|
} |
1473
|
|
|
|
|
|
|
else { |
1474
|
0
|
|
|
|
|
0
|
$relDefHash{"TERM"}++; $relDefHash{"CUI"}++; $relDefHash{"ST"}++; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1475
|
|
|
|
|
|
|
} |
1476
|
|
|
|
|
|
|
} |
1477
|
|
|
|
|
|
|
|
1478
|
|
|
|
|
|
|
# sets the variables for using the entire umls rather than just a subset |
1479
|
|
|
|
|
|
|
# input : |
1480
|
|
|
|
|
|
|
# output: |
1481
|
|
|
|
|
|
|
sub _setSabUmlsAll { |
1482
|
|
|
|
|
|
|
|
1483
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1484
|
|
|
|
|
|
|
|
1485
|
0
|
|
|
|
|
0
|
my $function = "_setSabUmlsAll"; |
1486
|
0
|
|
|
|
|
0
|
&_debug($function); |
1487
|
|
|
|
|
|
|
|
1488
|
|
|
|
|
|
|
# check input value |
1489
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1490
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1491
|
|
|
|
|
|
|
} |
1492
|
|
|
|
|
|
|
|
1493
|
|
|
|
|
|
|
# set the database |
1494
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1495
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1496
|
|
|
|
|
|
|
|
1497
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct SAB from MRREL where $relations"); |
1498
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1499
|
|
|
|
|
|
|
|
1500
|
0
|
|
|
|
|
0
|
foreach my $sab (@{$arrRef}) { |
|
0
|
|
|
|
|
0
|
|
1501
|
0
|
|
|
|
|
0
|
my $cui = $self->_getSabCui($sab); |
1502
|
|
|
|
|
|
|
|
1503
|
0
|
|
|
|
|
0
|
$sabnamesHash{$sab}++; |
1504
|
0
|
|
|
|
|
0
|
$sabHash{$cui}++; |
1505
|
|
|
|
|
|
|
} |
1506
|
|
|
|
|
|
|
} |
1507
|
|
|
|
|
|
|
|
1508
|
|
|
|
|
|
|
# sets the source variables from the information in the config file |
1509
|
|
|
|
|
|
|
# input : $includesabkeys <- integer |
1510
|
|
|
|
|
|
|
# : $excludesabkeys <- integer |
1511
|
|
|
|
|
|
|
# : $includesab <- reference to hash |
1512
|
|
|
|
|
|
|
# : $excludesab <- reference to hash |
1513
|
|
|
|
|
|
|
# output: |
1514
|
|
|
|
|
|
|
sub _setSabs { |
1515
|
|
|
|
|
|
|
|
1516
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1517
|
0
|
|
|
|
|
0
|
my $includesabkeys = shift; |
1518
|
0
|
|
|
|
|
0
|
my $excludesabkeys = shift; |
1519
|
0
|
|
|
|
|
0
|
my $includesab = shift; |
1520
|
0
|
|
|
|
|
0
|
my $excludesab = shift; |
1521
|
|
|
|
|
|
|
|
1522
|
0
|
|
|
|
|
0
|
my $function = "_setSabs"; |
1523
|
0
|
|
|
|
|
0
|
&_debug($function); |
1524
|
|
|
|
|
|
|
|
1525
|
|
|
|
|
|
|
# check input value |
1526
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1527
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1528
|
|
|
|
|
|
|
} |
1529
|
|
|
|
|
|
|
|
1530
|
|
|
|
|
|
|
# check the parameters are defined |
1531
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includesabkeys) || !(defined $excludesabkeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1532
|
|
|
|
|
|
|
!(defined $includesab) || !(defined $excludesab)) { |
1533
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "SAB variables not defined.", 4); |
1534
|
|
|
|
|
|
|
} |
1535
|
|
|
|
|
|
|
|
1536
|
|
|
|
|
|
|
# return if no sab or rel options were in the config file |
1537
|
0
|
0
|
0
|
|
|
0
|
if($includesabkeys <= 0 && $excludesabkeys <=0) { return; } |
|
0
|
|
|
|
|
0
|
|
1538
|
|
|
|
|
|
|
|
1539
|
|
|
|
|
|
|
# initialize the sources |
1540
|
0
|
|
|
|
|
0
|
$sources = ""; |
1541
|
|
|
|
|
|
|
|
1542
|
|
|
|
|
|
|
# if the umls all option is set clear out the the includesab hash and |
1543
|
|
|
|
|
|
|
# add the umlsall to the exclude. This way all should be included since |
1544
|
|
|
|
|
|
|
# there will never be a source called UMLS_ALL - this is a bit of a dirty |
1545
|
|
|
|
|
|
|
# swap but I think it will simplify the code and work |
1546
|
0
|
0
|
|
|
|
0
|
if(exists ${$includesab}{"UMLS_ALL"}) { |
|
0
|
|
|
|
|
0
|
|
1547
|
0
|
|
|
|
|
0
|
$includesab = ""; $includesabkeys = 0; |
|
0
|
|
|
|
|
0
|
|
1548
|
0
|
|
|
|
|
0
|
${$excludesab}{"UMLS_ALL"} = 1; $excludesabkeys = 1; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1549
|
0
|
|
|
|
|
0
|
$umlsall = 1; |
1550
|
0
|
|
|
|
|
0
|
$sources = "UMLS_ALL"; |
1551
|
|
|
|
|
|
|
} |
1552
|
|
|
|
|
|
|
|
1553
|
|
|
|
|
|
|
# check that the db is defined |
1554
|
|
|
|
|
|
|
# set the database |
1555
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1556
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1557
|
|
|
|
|
|
|
|
1558
|
|
|
|
|
|
|
# get the sabs |
1559
|
0
|
|
|
|
|
0
|
my @array = (); |
1560
|
0
|
0
|
|
|
|
0
|
if($includesabkeys > 0) { |
1561
|
0
|
|
|
|
|
0
|
@array = keys %{$includesab}; |
|
0
|
|
|
|
|
0
|
|
1562
|
|
|
|
|
|
|
} |
1563
|
|
|
|
|
|
|
else { |
1564
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct SAB from MRREL where $relations"); |
1565
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1566
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1567
|
|
|
|
|
|
|
} |
1568
|
|
|
|
|
|
|
|
1569
|
0
|
|
|
|
|
0
|
my $sabcount = 0; |
1570
|
0
|
|
|
|
|
0
|
foreach my $sab (@array) { |
1571
|
|
|
|
|
|
|
|
1572
|
0
|
|
|
|
|
0
|
$sabcount++; |
1573
|
|
|
|
|
|
|
|
1574
|
|
|
|
|
|
|
# if we are excluding check to see if this sab can be included |
1575
|
0
|
0
|
0
|
|
|
0
|
if(($excludesabkeys > 0) and (exists ${$excludesab}{$sab})) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1576
|
|
|
|
|
|
|
|
1577
|
|
|
|
|
|
|
# include the sab in the sources variable |
1578
|
0
|
0
|
|
|
|
0
|
if($sabcount == ($#array+1)) { $sources .="SAB=\'$sab\'"; } |
|
0
|
|
|
|
|
0
|
|
1579
|
0
|
|
|
|
|
0
|
else { $sources .="SAB=\'$sab\' or "; } |
1580
|
|
|
|
|
|
|
|
1581
|
|
|
|
|
|
|
# get the sabs cui |
1582
|
0
|
|
|
|
|
0
|
my $cui = $self->_getSabCui($sab); |
1583
|
|
|
|
|
|
|
|
1584
|
|
|
|
|
|
|
# store the sabs cui and name information |
1585
|
0
|
|
|
|
|
0
|
$sabnamesHash{$sab}++; |
1586
|
0
|
|
|
|
|
0
|
$sabHash{$cui}++; |
1587
|
|
|
|
|
|
|
} |
1588
|
|
|
|
|
|
|
} |
1589
|
|
|
|
|
|
|
|
1590
|
|
|
|
|
|
|
# sets the rela variables from the information in the config file |
1591
|
|
|
|
|
|
|
# input : $includerelakeys <- integer |
1592
|
|
|
|
|
|
|
# : $excluderelakeys <- integer |
1593
|
|
|
|
|
|
|
# : $includerela <- reference to hash |
1594
|
|
|
|
|
|
|
# : $excluderela <- reference to hash |
1595
|
|
|
|
|
|
|
# output: |
1596
|
|
|
|
|
|
|
sub _setRelas { |
1597
|
|
|
|
|
|
|
|
1598
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1599
|
0
|
|
|
|
|
0
|
my $includerelakeys = shift; |
1600
|
0
|
|
|
|
|
0
|
my $excluderelakeys = shift; |
1601
|
0
|
|
|
|
|
0
|
my $includerela = shift; |
1602
|
0
|
|
|
|
|
0
|
my $excluderela = shift; |
1603
|
|
|
|
|
|
|
|
1604
|
0
|
|
|
|
|
0
|
my $function = "_setRelas"; |
1605
|
0
|
|
|
|
|
0
|
&_debug($function); |
1606
|
|
|
|
|
|
|
|
1607
|
|
|
|
|
|
|
# check the input values |
1608
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1609
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1610
|
|
|
|
|
|
|
} |
1611
|
|
|
|
|
|
|
|
1612
|
|
|
|
|
|
|
# check the parameters are defined |
1613
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includerelakeys) || !(defined $excluderelakeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1614
|
|
|
|
|
|
|
!(defined $includerela) || !(defined $excluderela)) { |
1615
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "RELA variables not defined.", 4); |
1616
|
|
|
|
|
|
|
} |
1617
|
|
|
|
|
|
|
|
1618
|
|
|
|
|
|
|
# if no relas were specified just return |
1619
|
0
|
0
|
0
|
|
|
0
|
if($includerelakeys <= 0 && $excluderelakeys <=0) { return } |
|
0
|
|
|
|
|
0
|
|
1620
|
|
|
|
|
|
|
|
1621
|
|
|
|
|
|
|
# set the database |
1622
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1623
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1624
|
|
|
|
|
|
|
|
1625
|
|
|
|
|
|
|
# initalize the hash tables that will hold children and parent relas |
1626
|
0
|
|
|
|
|
0
|
my %childrelas = (); |
1627
|
0
|
|
|
|
|
0
|
my %parentrelas = (); |
1628
|
|
|
|
|
|
|
|
1629
|
|
|
|
|
|
|
# set the parent relations |
1630
|
0
|
|
|
|
|
0
|
my $prelations = ""; |
1631
|
0
|
0
|
|
|
|
0
|
if($relations=~/PAR/) { |
|
|
0
|
|
|
|
|
|
1632
|
0
|
0
|
|
|
|
0
|
if($relations=~/RB/) { |
1633
|
0
|
|
|
|
|
0
|
$prelations = "(REL='PAR') or (REL='RB')"; |
1634
|
0
|
|
|
|
|
0
|
} else { $prelations = "(REL='PAR')"; } |
1635
|
0
|
|
|
|
|
0
|
} elsif($relations=~/RB/) { $prelations = "(REL='RB')"; } |
1636
|
|
|
|
|
|
|
|
1637
|
|
|
|
|
|
|
# set the child relations |
1638
|
0
|
|
|
|
|
0
|
my $crelations = ""; |
1639
|
0
|
0
|
|
|
|
0
|
if($relations=~/CHD/) { |
|
|
0
|
|
|
|
|
|
1640
|
0
|
0
|
|
|
|
0
|
if($relations=~/RN/) { |
1641
|
0
|
|
|
|
|
0
|
$crelations = "(REL='CHD') or (REL='RN')"; |
1642
|
0
|
|
|
|
|
0
|
} else { $crelations = "(REL='CHD')"; } |
1643
|
0
|
|
|
|
|
0
|
} elsif($relations=~/RB/) { $crelations = "(REL='RN')"; } |
1644
|
|
|
|
|
|
|
|
1645
|
|
|
|
|
|
|
# get the rela relations that exist for the given set of sources and |
1646
|
|
|
|
|
|
|
# relations for the children relations that are specified in the config |
1647
|
0
|
|
|
|
|
0
|
my $sth = ""; |
1648
|
0
|
0
|
|
|
|
0
|
if($umlsall) { |
1649
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $crelations"); |
1650
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1651
|
|
|
|
|
|
|
} |
1652
|
|
|
|
|
|
|
else { |
1653
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $crelations and ($sources)"); |
1654
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1655
|
|
|
|
|
|
|
} |
1656
|
0
|
|
|
|
|
0
|
$sth->execute(); |
1657
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
1658
|
|
|
|
|
|
|
|
1659
|
|
|
|
|
|
|
# get all the relas for the children |
1660
|
0
|
|
|
|
|
0
|
my $crela = ""; |
1661
|
0
|
|
|
|
|
0
|
while(($crela) = $sth->fetchrow()) { |
1662
|
0
|
0
|
|
|
|
0
|
if(defined $crela) { |
1663
|
0
|
0
|
|
|
|
0
|
if($crela ne "NULL") { |
1664
|
0
|
|
|
|
|
0
|
$childrelas{$crela}++; |
1665
|
|
|
|
|
|
|
} |
1666
|
|
|
|
|
|
|
} |
1667
|
|
|
|
|
|
|
} |
1668
|
0
|
|
|
|
|
0
|
$sth->finish(); |
1669
|
|
|
|
|
|
|
|
1670
|
0
|
|
|
|
|
0
|
my $crelakeys = keys %childrelas; |
1671
|
0
|
0
|
|
|
|
0
|
if($crelakeys <= 0) { |
1672
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
1673
|
|
|
|
|
|
|
$function, |
1674
|
|
|
|
|
|
|
"There are no RELA relations for the given sources/relations.", |
1675
|
|
|
|
|
|
|
5); |
1676
|
|
|
|
|
|
|
} |
1677
|
|
|
|
|
|
|
|
1678
|
|
|
|
|
|
|
|
1679
|
|
|
|
|
|
|
# get the rela relations that exist for the given set of sources and |
1680
|
|
|
|
|
|
|
# relations for the children relations that are specified in the config |
1681
|
0
|
0
|
|
|
|
0
|
if($umlsall) { |
1682
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $prelations"); |
1683
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1684
|
|
|
|
|
|
|
} |
1685
|
|
|
|
|
|
|
else { |
1686
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $prelations and ($sources)"); |
1687
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1688
|
|
|
|
|
|
|
} |
1689
|
0
|
|
|
|
|
0
|
$sth->execute(); |
1690
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
1691
|
|
|
|
|
|
|
|
1692
|
|
|
|
|
|
|
# get all the relas for the parents |
1693
|
0
|
|
|
|
|
0
|
my $prela = ""; |
1694
|
0
|
|
|
|
|
0
|
while(($prela) = $sth->fetchrow()) { |
1695
|
0
|
0
|
|
|
|
0
|
if(defined $prela) { |
1696
|
0
|
0
|
|
|
|
0
|
if($prela ne "NULL") { |
1697
|
0
|
|
|
|
|
0
|
$parentrelas{$prela}++; |
1698
|
|
|
|
|
|
|
} |
1699
|
|
|
|
|
|
|
} |
1700
|
|
|
|
|
|
|
} |
1701
|
0
|
|
|
|
|
0
|
$sth->finish(); |
1702
|
|
|
|
|
|
|
|
1703
|
0
|
|
|
|
|
0
|
my $prelakeys = keys %parentrelas; |
1704
|
0
|
0
|
|
|
|
0
|
if($prelakeys <= 0) { |
1705
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
1706
|
|
|
|
|
|
|
$function, |
1707
|
|
|
|
|
|
|
"There are no RELA relations for the given sources.", |
1708
|
|
|
|
|
|
|
5); |
1709
|
|
|
|
|
|
|
} |
1710
|
|
|
|
|
|
|
|
1711
|
|
|
|
|
|
|
# uses the relas that are set in the includrelakeys or excluderelakeys |
1712
|
0
|
|
|
|
|
0
|
my @array = (); |
1713
|
0
|
0
|
|
|
|
0
|
if($includerelakeys > 0) { |
1714
|
0
|
|
|
|
|
0
|
@array = keys %{$includerela}; |
|
0
|
|
|
|
|
0
|
|
1715
|
|
|
|
|
|
|
} |
1716
|
|
|
|
|
|
|
else { |
1717
|
|
|
|
|
|
|
|
1718
|
0
|
|
|
|
|
0
|
my $arrRef = |
1719
|
|
|
|
|
|
|
$db->selectcol_arrayref("select distinct RELA from MRREL where ($sources) and $prelations and $crelations"); |
1720
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1721
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1722
|
0
|
|
|
|
|
0
|
shift @array; |
1723
|
|
|
|
|
|
|
} |
1724
|
|
|
|
|
|
|
|
1725
|
0
|
|
|
|
|
0
|
my @crelas = (); |
1726
|
0
|
|
|
|
|
0
|
my @prelas = (); |
1727
|
0
|
|
|
|
|
0
|
my $relacount = 0; |
1728
|
|
|
|
|
|
|
|
1729
|
0
|
|
|
|
|
0
|
my @newrelations = (); |
1730
|
|
|
|
|
|
|
|
1731
|
0
|
|
|
|
|
0
|
foreach my $r (@array) { |
1732
|
|
|
|
|
|
|
|
1733
|
0
|
|
|
|
|
0
|
$relacount++; |
1734
|
|
|
|
|
|
|
|
1735
|
0
|
0
|
0
|
|
|
0
|
if( ($excluderelakeys > 0) and (exists ${$excluderela}{$r}) ) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1736
|
|
|
|
|
|
|
|
1737
|
0
|
|
|
|
|
0
|
push @newrelations, "RELA=\'$r\'"; |
1738
|
|
|
|
|
|
|
|
1739
|
0
|
0
|
|
|
|
0
|
if(exists $childrelas{$r}) { push @crelas, "RELA=\'$r\'"; } |
|
0
|
0
|
|
|
|
0
|
|
1740
|
0
|
|
|
|
|
0
|
elsif(exists $parentrelas{$r}) { push @prelas, "RELA=\'$r\'"; } |
1741
|
|
|
|
|
|
|
else { |
1742
|
0
|
|
|
|
|
0
|
my $errorstring = "RELA relation ($r) does not exist for the given sources/relations."; |
1743
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, $errorstring, 5); |
1744
|
|
|
|
|
|
|
} |
1745
|
|
|
|
|
|
|
} |
1746
|
|
|
|
|
|
|
|
1747
|
0
|
0
|
|
|
|
0
|
if($#newrelations >= 0) { |
1748
|
0
|
|
|
|
|
0
|
my $string = join " or ", @newrelations; |
1749
|
|
|
|
|
|
|
|
1750
|
0
|
|
|
|
|
0
|
$relations .= "and ( $string )"; |
1751
|
|
|
|
|
|
|
|
1752
|
0
|
|
|
|
|
0
|
my $crelasline = join " or ", @crelas; |
1753
|
0
|
|
|
|
|
0
|
my $prelasline = join " or ", @prelas; |
1754
|
|
|
|
|
|
|
|
1755
|
|
|
|
|
|
|
# set the parent relations |
1756
|
0
|
0
|
|
|
|
0
|
if($parentRelations=~/PAR/) { |
1757
|
0
|
|
|
|
|
0
|
$parentRelations=~s/REL='PAR'/\(REL='PAR' and \($prelasline\)\)/g; |
1758
|
0
|
|
|
|
|
0
|
$relations=~s/REL='PAR'/\(REL='PAR' and \($prelasline\)\)/g; |
1759
|
|
|
|
|
|
|
} |
1760
|
0
|
0
|
|
|
|
0
|
if($parentRelations=~/RB/) { |
1761
|
0
|
|
|
|
|
0
|
$parentRelations=~s/REL='RB'/\(REL='RB' and \($prelasline\)\)/g; |
1762
|
0
|
|
|
|
|
0
|
$relations=~s/REL='RB'/\(REL='RB' and \($prelasline\)\)/g; |
1763
|
|
|
|
|
|
|
} |
1764
|
|
|
|
|
|
|
# set the child relations |
1765
|
0
|
0
|
|
|
|
0
|
if($childRelations=~/CHD/) { |
1766
|
0
|
|
|
|
|
0
|
$childRelations=~s/REL='CHD'/\(REL='CHD' and \($crelasline\)\)/g; |
1767
|
0
|
|
|
|
|
0
|
$relations=~s/REL='CHD'/\(REL='CHD' and \($crelasline\)\)/g; |
1768
|
|
|
|
|
|
|
} |
1769
|
0
|
0
|
|
|
|
0
|
if($childRelations=~/RN/) { |
1770
|
0
|
|
|
|
|
0
|
$childRelations=~s/REL='RN'/\(REL='RN' and \($crelasline\)\)/g; |
1771
|
0
|
|
|
|
|
0
|
$relations=~s/REL='RN'/\(REL='RN' and \($crelasline\)\)/g; |
1772
|
|
|
|
|
|
|
} |
1773
|
|
|
|
|
|
|
} |
1774
|
|
|
|
|
|
|
} |
1775
|
|
|
|
|
|
|
|
1776
|
|
|
|
|
|
|
# sets the reladef variables from the information in the config file |
1777
|
|
|
|
|
|
|
# input : $includereladefkeys <- integer |
1778
|
|
|
|
|
|
|
# : $excludereladefkeys <- integer |
1779
|
|
|
|
|
|
|
# : $includereladef <- reference to hash |
1780
|
|
|
|
|
|
|
# : $excludereladef <- reference to hash |
1781
|
|
|
|
|
|
|
# output: |
1782
|
|
|
|
|
|
|
sub _setRelaDef { |
1783
|
|
|
|
|
|
|
|
1784
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1785
|
0
|
|
|
|
|
0
|
my $includereladefkeys = shift; |
1786
|
0
|
|
|
|
|
0
|
my $excludereladefkeys = shift; |
1787
|
0
|
|
|
|
|
0
|
my $includereladef = shift; |
1788
|
0
|
|
|
|
|
0
|
my $excludereladef = shift; |
1789
|
|
|
|
|
|
|
|
1790
|
0
|
|
|
|
|
0
|
my $function = "_setRelaDef"; |
1791
|
0
|
|
|
|
|
0
|
&_debug($function); |
1792
|
|
|
|
|
|
|
|
1793
|
|
|
|
|
|
|
# check the input values |
1794
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1795
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1796
|
|
|
|
|
|
|
} |
1797
|
|
|
|
|
|
|
|
1798
|
|
|
|
|
|
|
# check the parameters are defined |
1799
|
0
|
0
|
0
|
|
|
0
|
if(!(defined $includereladefkeys) || !(defined $excludereladefkeys) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
1800
|
|
|
|
|
|
|
!(defined $includereladef) || !(defined $excludereladef)) { |
1801
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "RELADEF variables not defined.", 4); |
1802
|
|
|
|
|
|
|
} |
1803
|
|
|
|
|
|
|
|
1804
|
|
|
|
|
|
|
# if no relas were specified just return |
1805
|
0
|
0
|
0
|
|
|
0
|
if($includereladefkeys <= 0 && $excludereladefkeys <=0) { return; } |
|
0
|
|
|
|
|
0
|
|
1806
|
|
|
|
|
|
|
|
1807
|
|
|
|
|
|
|
# set the database |
1808
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
1809
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
1810
|
|
|
|
|
|
|
|
1811
|
|
|
|
|
|
|
# initalize the hash tables that will hold children and parent relas |
1812
|
0
|
|
|
|
|
0
|
my %childrelas = (); |
1813
|
0
|
|
|
|
|
0
|
my %parentrelas = (); |
1814
|
|
|
|
|
|
|
|
1815
|
|
|
|
|
|
|
# set the parent relations |
1816
|
0
|
|
|
|
|
0
|
my $prelations = ""; |
1817
|
0
|
0
|
|
|
|
0
|
if($reldefstring=~/PAR/) { |
|
|
0
|
|
|
|
|
|
1818
|
0
|
0
|
|
|
|
0
|
if($reldefstring=~/RB/) { |
1819
|
0
|
|
|
|
|
0
|
$prelations = "(REL='PAR') or (REL='RB')"; |
1820
|
0
|
|
|
|
|
0
|
} else { $prelations = "(REL='PAR')"; } |
1821
|
0
|
|
|
|
|
0
|
} elsif($reldefstring=~/RB/) { $prelations = "(REL='RB')"; } |
1822
|
|
|
|
|
|
|
|
1823
|
|
|
|
|
|
|
# set the child relations |
1824
|
0
|
|
|
|
|
0
|
my $crelations = ""; |
1825
|
0
|
0
|
|
|
|
0
|
if($reldefstring=~/CHD/) { |
|
|
0
|
|
|
|
|
|
1826
|
0
|
0
|
|
|
|
0
|
if($reldefstring=~/RN/) { |
1827
|
0
|
|
|
|
|
0
|
$crelations = "(REL='CHD') or (REL='RN')"; |
1828
|
0
|
|
|
|
|
0
|
} else { $crelations = "(REL='CHD')"; } |
1829
|
0
|
|
|
|
|
0
|
} elsif($reldefstring=~/RB/) { $crelations = "(REL='RN')"; } |
1830
|
|
|
|
|
|
|
|
1831
|
|
|
|
|
|
|
# get the rela relations that exist for the given set of sources and |
1832
|
|
|
|
|
|
|
# relations for the children relations that are specified in the config |
1833
|
0
|
|
|
|
|
0
|
my $sth = ""; |
1834
|
0
|
0
|
|
|
|
0
|
if($umlsall) { |
1835
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $crelations"); |
1836
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1837
|
|
|
|
|
|
|
} |
1838
|
|
|
|
|
|
|
else { |
1839
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $crelations and ($sabdefsources)"); |
1840
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1841
|
|
|
|
|
|
|
} |
1842
|
0
|
|
|
|
|
0
|
$sth->execute(); |
1843
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
1844
|
|
|
|
|
|
|
|
1845
|
|
|
|
|
|
|
# get all the relas for the children |
1846
|
0
|
|
|
|
|
0
|
my $crela = ""; |
1847
|
0
|
|
|
|
|
0
|
while(($crela) = $sth->fetchrow()) { |
1848
|
0
|
0
|
|
|
|
0
|
if(defined $crela) { |
1849
|
0
|
0
|
|
|
|
0
|
if($crela ne "NULL") { |
1850
|
0
|
|
|
|
|
0
|
$childrelas{$crela}++; |
1851
|
|
|
|
|
|
|
} |
1852
|
|
|
|
|
|
|
} |
1853
|
|
|
|
|
|
|
} |
1854
|
0
|
|
|
|
|
0
|
$sth->finish(); |
1855
|
|
|
|
|
|
|
|
1856
|
0
|
|
|
|
|
0
|
my $crelakeys = keys %childrelas; |
1857
|
0
|
0
|
|
|
|
0
|
if($crelakeys <= 0) { |
1858
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
1859
|
|
|
|
|
|
|
$function, |
1860
|
|
|
|
|
|
|
"There are no RELA relations for the given sources/relations.", |
1861
|
|
|
|
|
|
|
5); |
1862
|
|
|
|
|
|
|
} |
1863
|
|
|
|
|
|
|
|
1864
|
|
|
|
|
|
|
# get the rela relations that exist for the given set of sources and |
1865
|
|
|
|
|
|
|
# relations for the children relations that are specified in the config |
1866
|
0
|
0
|
|
|
|
0
|
if($umlsall) { |
1867
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $prelations"); |
1868
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1869
|
|
|
|
|
|
|
} |
1870
|
|
|
|
|
|
|
else { |
1871
|
0
|
|
|
|
|
0
|
$sth = $db->prepare("select distinct RELA from MRREL where $prelations and ($sabdefsources)"); |
1872
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1873
|
|
|
|
|
|
|
} |
1874
|
0
|
|
|
|
|
0
|
$sth->execute(); |
1875
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
1876
|
|
|
|
|
|
|
|
1877
|
|
|
|
|
|
|
# get all the relas for the parents |
1878
|
0
|
|
|
|
|
0
|
my $prela = ""; |
1879
|
0
|
|
|
|
|
0
|
while(($prela) = $sth->fetchrow()) { |
1880
|
0
|
0
|
|
|
|
0
|
if(defined $prela) { |
1881
|
0
|
0
|
|
|
|
0
|
if($prela ne "NULL") { |
1882
|
0
|
|
|
|
|
0
|
$parentrelas{$prela}++; |
1883
|
|
|
|
|
|
|
} |
1884
|
|
|
|
|
|
|
} |
1885
|
|
|
|
|
|
|
} |
1886
|
0
|
|
|
|
|
0
|
$sth->finish(); |
1887
|
|
|
|
|
|
|
|
1888
|
0
|
|
|
|
|
0
|
my $prelakeys = keys %parentrelas; |
1889
|
0
|
0
|
|
|
|
0
|
if($prelakeys <= 0) { |
1890
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
1891
|
|
|
|
|
|
|
$function, |
1892
|
|
|
|
|
|
|
"There are no RELA relations for the given sources.", |
1893
|
|
|
|
|
|
|
5); |
1894
|
|
|
|
|
|
|
} |
1895
|
|
|
|
|
|
|
|
1896
|
|
|
|
|
|
|
# uses the relas that are set in the includrelakeys or excludereladefkeys |
1897
|
0
|
|
|
|
|
0
|
my @array = (); |
1898
|
0
|
0
|
|
|
|
0
|
if($includereladefkeys > 0) { |
1899
|
0
|
|
|
|
|
0
|
@array = keys %{$includereladef}; |
|
0
|
|
|
|
|
0
|
|
1900
|
|
|
|
|
|
|
} |
1901
|
|
|
|
|
|
|
else { |
1902
|
|
|
|
|
|
|
|
1903
|
0
|
|
|
|
|
0
|
my $arrRef = |
1904
|
|
|
|
|
|
|
$db->selectcol_arrayref("select distinct RELA from MRREL where ($sources) and $prelations and $crelations"); |
1905
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
1906
|
0
|
|
|
|
|
0
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
1907
|
0
|
|
|
|
|
0
|
shift @array; |
1908
|
|
|
|
|
|
|
} |
1909
|
|
|
|
|
|
|
|
1910
|
0
|
|
|
|
|
0
|
my @crelas = (); |
1911
|
0
|
|
|
|
|
0
|
my @prelas = (); |
1912
|
0
|
|
|
|
|
0
|
my $relacount = 0; |
1913
|
|
|
|
|
|
|
|
1914
|
0
|
|
|
|
|
0
|
my @newrelations = (); |
1915
|
|
|
|
|
|
|
|
1916
|
0
|
|
|
|
|
0
|
foreach my $r (@array) { |
1917
|
|
|
|
|
|
|
|
1918
|
0
|
|
|
|
|
0
|
$relacount++; |
1919
|
|
|
|
|
|
|
|
1920
|
0
|
0
|
0
|
|
|
0
|
if( ($excludereladefkeys > 0) and (exists ${$excludereladef}{$r}) ) { next; } |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
1921
|
|
|
|
|
|
|
|
1922
|
0
|
|
|
|
|
0
|
push @newrelations, "RELA=\'$r\'"; |
1923
|
|
|
|
|
|
|
|
1924
|
0
|
0
|
|
|
|
0
|
if(exists $childrelas{$r}) { push @crelas, "RELA=\'$r\'"; } |
|
0
|
0
|
|
|
|
0
|
|
1925
|
0
|
|
|
|
|
0
|
elsif(exists $parentrelas{$r}) { push @prelas, "RELA=\'$r\'"; } |
1926
|
|
|
|
|
|
|
else { |
1927
|
0
|
|
|
|
|
0
|
my $errorstring = "RELA relation ($r) does not exist for the given sources/relations."; |
1928
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, $errorstring, 5); |
1929
|
|
|
|
|
|
|
} |
1930
|
|
|
|
|
|
|
} |
1931
|
|
|
|
|
|
|
|
1932
|
0
|
0
|
|
|
|
0
|
if($#newrelations >= 0) { |
1933
|
0
|
|
|
|
|
0
|
my $string = join " or ", @newrelations; |
1934
|
|
|
|
|
|
|
|
1935
|
0
|
|
|
|
|
0
|
$relations .= "and ( $string )"; |
1936
|
|
|
|
|
|
|
|
1937
|
0
|
|
|
|
|
0
|
$reladefchildren = join " or ", @crelas; |
1938
|
0
|
|
|
|
|
0
|
$reladefparents = join " or ", @prelas; |
1939
|
|
|
|
|
|
|
} |
1940
|
|
|
|
|
|
|
} |
1941
|
|
|
|
|
|
|
|
1942
|
|
|
|
|
|
|
# This sets the sources that are to be used. These sources |
1943
|
|
|
|
|
|
|
# are found in the config file. The defaults are: |
1944
|
|
|
|
|
|
|
# input : $file <- string |
1945
|
|
|
|
|
|
|
# output: |
1946
|
|
|
|
|
|
|
sub _config { |
1947
|
|
|
|
|
|
|
|
1948
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
1949
|
0
|
|
|
|
|
0
|
my $file = shift; |
1950
|
|
|
|
|
|
|
|
1951
|
0
|
|
|
|
|
0
|
my $function = "_config"; |
1952
|
0
|
|
|
|
|
0
|
&_debug($function); |
1953
|
|
|
|
|
|
|
|
1954
|
|
|
|
|
|
|
# check self |
1955
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
1956
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
1957
|
|
|
|
|
|
|
} |
1958
|
|
|
|
|
|
|
|
1959
|
0
|
|
|
|
|
0
|
my %includesab = (); my %excludesab = (); |
|
0
|
|
|
|
|
0
|
|
1960
|
0
|
|
|
|
|
0
|
my %includerel = (); my %excluderel = (); |
|
0
|
|
|
|
|
0
|
|
1961
|
0
|
|
|
|
|
0
|
my %includerela = (); my %excluderela = (); |
|
0
|
|
|
|
|
0
|
|
1962
|
0
|
|
|
|
|
0
|
my %includereldef = (); my %excludereldef = (); |
|
0
|
|
|
|
|
0
|
|
1963
|
0
|
|
|
|
|
0
|
my %includesabdef = (); my %excludesabdef = (); |
|
0
|
|
|
|
|
0
|
|
1964
|
0
|
|
|
|
|
0
|
my %includereladef = (); my %excludereladef = (); |
|
0
|
|
|
|
|
0
|
|
1965
|
|
|
|
|
|
|
|
1966
|
0
|
|
|
|
|
0
|
my %check = (); |
1967
|
|
|
|
|
|
|
|
1968
|
0
|
0
|
|
|
|
0
|
if(defined $file) { |
1969
|
0
|
0
|
|
|
|
0
|
open(FILE, $file) || die "Could not open configuration file: $file\n"; |
1970
|
0
|
|
|
|
|
0
|
while() { |
1971
|
0
|
|
|
|
|
0
|
chomp; |
1972
|
|
|
|
|
|
|
# if blank line skip |
1973
|
0
|
0
|
|
|
|
0
|
if($_=~/^\s*$/) { next; } |
|
0
|
|
|
|
|
0
|
|
1974
|
|
|
|
|
|
|
|
1975
|
0
|
0
|
|
|
|
0
|
if($_=~/([A-Z]+)\s*\:\:\s*(include|exclude)\s+(.*)/) { |
1976
|
|
|
|
|
|
|
|
1977
|
0
|
|
|
|
|
0
|
my $type = $1; |
1978
|
0
|
|
|
|
|
0
|
my $det = $2; |
1979
|
0
|
|
|
|
|
0
|
my $list = $3; |
1980
|
|
|
|
|
|
|
|
1981
|
|
|
|
|
|
|
# catch what types are in the config file for checking |
1982
|
|
|
|
|
|
|
# right now the checking is pretty simple but I think |
1983
|
|
|
|
|
|
|
# in the future as others get added it might be more |
1984
|
|
|
|
|
|
|
# extensive |
1985
|
0
|
|
|
|
|
0
|
$check{$type}++; |
1986
|
|
|
|
|
|
|
|
1987
|
0
|
|
|
|
|
0
|
my @array = split/\s*\,\s*/, $list; |
1988
|
0
|
|
|
|
|
0
|
foreach my $element (@array) { |
1989
|
|
|
|
|
|
|
|
1990
|
0
|
|
|
|
|
0
|
$element=~s/^\s+//g; $element=~s/\s+$//g; |
|
0
|
|
|
|
|
0
|
|
1991
|
0
|
0
|
0
|
|
|
0
|
if( $type eq "SAB" and $det eq "include") { $includesab{$element}++; |
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
1992
|
0
|
|
|
|
|
0
|
$sabstring = $_; |
1993
|
0
|
|
|
|
|
0
|
$parameters{"SAB"}++; |
1994
|
|
|
|
|
|
|
} |
1995
|
0
|
|
|
|
|
0
|
elsif($type eq "SAB" and $det eq "exclude") { $excludesab{$element}++; |
1996
|
0
|
|
|
|
|
0
|
$sabstring = $_; |
1997
|
0
|
|
|
|
|
0
|
$parameters{"SAB"}++; |
1998
|
|
|
|
|
|
|
} |
1999
|
0
|
|
|
|
|
0
|
elsif($type eq "REL" and $det eq "include") { $includerel{$element}++; |
2000
|
0
|
|
|
|
|
0
|
$relstring = $_; |
2001
|
0
|
|
|
|
|
0
|
$parameters{"REL"}++; |
2002
|
|
|
|
|
|
|
} |
2003
|
0
|
|
|
|
|
0
|
elsif($type eq "REL" and $det eq "exclude") { $excluderel{$element}++; |
2004
|
0
|
|
|
|
|
0
|
$relstring = $_; |
2005
|
0
|
|
|
|
|
0
|
$parameters{"REL"}++; |
2006
|
|
|
|
|
|
|
} |
2007
|
0
|
|
|
|
|
0
|
elsif($type eq "RELA" and $det eq "include") { $includerela{$element}++; |
2008
|
0
|
|
|
|
|
0
|
$relastring = $_; |
2009
|
0
|
|
|
|
|
0
|
$parameters{"RELA"}++; |
2010
|
|
|
|
|
|
|
} |
2011
|
0
|
|
|
|
|
0
|
elsif($type eq "RELA" and $det eq "exclude") { $excluderela{$element}++; |
2012
|
0
|
|
|
|
|
0
|
$relastring = $_; |
2013
|
0
|
|
|
|
|
0
|
$parameters{"RELA"}++; |
2014
|
|
|
|
|
|
|
} |
2015
|
0
|
|
|
|
|
0
|
elsif($type eq "RELDEF" and $det eq "include") { $includereldef{$element}++; |
2016
|
0
|
|
|
|
|
0
|
$reldefstring = $_; |
2017
|
0
|
|
|
|
|
0
|
$parameters{"RELDEF"}++; |
2018
|
|
|
|
|
|
|
} |
2019
|
0
|
|
|
|
|
0
|
elsif($type eq "RELDEF" and $det eq "exclude") { $excludereldef{$element}++; |
2020
|
0
|
|
|
|
|
0
|
$reldefstring = $_; |
2021
|
0
|
|
|
|
|
0
|
$parameters{"RELDEF"}++; |
2022
|
|
|
|
|
|
|
} |
2023
|
0
|
|
|
|
|
0
|
elsif($type eq "SABDEF" and $det eq "include") { $includesabdef{$element}++; |
2024
|
0
|
|
|
|
|
0
|
$sabdefstring = $_; |
2025
|
0
|
|
|
|
|
0
|
$parameters{"SABDEF"}++; |
2026
|
|
|
|
|
|
|
} |
2027
|
0
|
|
|
|
|
0
|
elsif($type eq "SABDEF" and $det eq "exclude") { $excludesabdef{$element}++; |
2028
|
0
|
|
|
|
|
0
|
$sabdefstring = $_; |
2029
|
0
|
|
|
|
|
0
|
$parameters{"SABDEF"}++; |
2030
|
|
|
|
|
|
|
} |
2031
|
0
|
|
|
|
|
0
|
elsif($type eq "RELADEF" and $det eq "include"){ $includereladef{$element}++; |
2032
|
0
|
|
|
|
|
0
|
$parameters{"RELADEF"}++; |
2033
|
|
|
|
|
|
|
} |
2034
|
0
|
|
|
|
|
0
|
elsif($type eq "RELADEF" and $det eq "exclude"){ $excludereladef{$element}++; |
2035
|
0
|
|
|
|
|
0
|
$parameters{"RELADEF"}++; |
2036
|
|
|
|
|
|
|
} |
2037
|
|
|
|
|
|
|
} |
2038
|
|
|
|
|
|
|
} |
2039
|
|
|
|
|
|
|
else { |
2040
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Format not correct ($_)", 5); |
2041
|
|
|
|
|
|
|
} |
2042
|
|
|
|
|
|
|
} |
2043
|
|
|
|
|
|
|
} |
2044
|
|
|
|
|
|
|
|
2045
|
|
|
|
|
|
|
|
2046
|
|
|
|
|
|
|
|
2047
|
|
|
|
|
|
|
# check about the UMLS_ALL option in RELA and RELADEF |
2048
|
|
|
|
|
|
|
# this is the default so just remove them - it is here |
2049
|
|
|
|
|
|
|
# for the user not really for us |
2050
|
0
|
0
|
|
|
|
0
|
if(exists $includerela{"UMLS_ALL"}) { %includerela = (); } |
|
0
|
|
|
|
|
0
|
|
2051
|
0
|
0
|
|
|
|
0
|
if(exists $includereladef{"UMLS_ALL"}) { %includereladef = (); } |
|
0
|
|
|
|
|
0
|
|
2052
|
|
|
|
|
|
|
|
2053
|
0
|
|
|
|
|
0
|
my $includesabkeys = keys %includesab; |
2054
|
0
|
|
|
|
|
0
|
my $excludesabkeys = keys %excludesab; |
2055
|
0
|
|
|
|
|
0
|
my $includerelkeys = keys %includerel; |
2056
|
0
|
|
|
|
|
0
|
my $excluderelkeys = keys %excluderel; |
2057
|
0
|
|
|
|
|
0
|
my $includerelakeys = keys %includerela; |
2058
|
0
|
|
|
|
|
0
|
my $excluderelakeys = keys %excluderela; |
2059
|
0
|
|
|
|
|
0
|
my $includereldefkeys = keys %includereldef; |
2060
|
0
|
|
|
|
|
0
|
my $excludereldefkeys = keys %excludereldef; |
2061
|
0
|
|
|
|
|
0
|
my $includesabdefkeys = keys %includesabdef; |
2062
|
0
|
|
|
|
|
0
|
my $excludesabdefkeys = keys %excludesabdef; |
2063
|
0
|
|
|
|
|
0
|
my $includereladefkeys = keys %includereladef; |
2064
|
0
|
|
|
|
|
0
|
my $excludereladefkeys = keys %excludereladef; |
2065
|
|
|
|
|
|
|
|
2066
|
|
|
|
|
|
|
# check for errors |
2067
|
0
|
0
|
0
|
|
|
0
|
if( (!exists $check{"SAB"} && exists $check{"REL"}) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2068
|
|
|
|
|
|
|
(!exists $check{"REL"} && exists $check{"SAB"}) ) { |
2069
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2070
|
|
|
|
|
|
|
$function, |
2071
|
|
|
|
|
|
|
"Configuration file must include both REL and SAB information.", |
2072
|
|
|
|
|
|
|
5); |
2073
|
|
|
|
|
|
|
} |
2074
|
0
|
0
|
0
|
|
|
0
|
if( (!exists $check{"SABDEF"} && exists $check{"RELDEF"}) || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2075
|
|
|
|
|
|
|
(!exists $check{"RELDEF"} && exists $check{"SABDEF"}) ) { |
2076
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2077
|
|
|
|
|
|
|
$function, |
2078
|
|
|
|
|
|
|
"Configuration file must include both RELDEF and SABDEF information.", |
2079
|
|
|
|
|
|
|
5); |
2080
|
|
|
|
|
|
|
} |
2081
|
0
|
0
|
0
|
|
|
0
|
if($includesabkeys > 0 && $excludesabkeys > 0) { |
2082
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2083
|
|
|
|
|
|
|
$function, |
2084
|
|
|
|
|
|
|
"Configuration file can not have an include and exclude list of sources.", |
2085
|
|
|
|
|
|
|
5); |
2086
|
|
|
|
|
|
|
} |
2087
|
0
|
0
|
0
|
|
|
0
|
if($includerelkeys > 0 && $excluderelkeys > 0) { |
2088
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2089
|
|
|
|
|
|
|
$function, |
2090
|
|
|
|
|
|
|
"Configuration file can not have an include and exclude list of relations.", |
2091
|
|
|
|
|
|
|
5); |
2092
|
|
|
|
|
|
|
} |
2093
|
0
|
0
|
0
|
|
|
0
|
if( ($includerelkeys <= 0 && $excluderelkeys <= 0) && |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2094
|
|
|
|
|
|
|
($includerelakeys > 0 || $excluderelakeys > 0) ) { |
2095
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2096
|
|
|
|
|
|
|
$function, |
2097
|
|
|
|
|
|
|
"The relations (REL) must be specified if using the rela relations (RELA).", |
2098
|
|
|
|
|
|
|
5); |
2099
|
|
|
|
|
|
|
} |
2100
|
0
|
0
|
0
|
|
|
0
|
if( ($includereldefkeys <= 0 && $excludereldefkeys <= 0) && |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2101
|
|
|
|
|
|
|
($includereladefkeys > 0 || $excludereladefkeys > 0) ) { |
2102
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2103
|
|
|
|
|
|
|
$function, |
2104
|
|
|
|
|
|
|
"The relations (RELDEF) must be specified if using the rela relations (RELADEF).", |
2105
|
|
|
|
|
|
|
5); |
2106
|
|
|
|
|
|
|
} |
2107
|
|
|
|
|
|
|
|
2108
|
|
|
|
|
|
|
|
2109
|
|
|
|
|
|
|
# set the defaults |
2110
|
0
|
0
|
0
|
|
|
0
|
if($includerelkeys <= 0 && $excluderelkeys <= 0) { |
2111
|
0
|
|
|
|
|
0
|
$includesab{"MSH"}++; |
2112
|
0
|
|
|
|
|
0
|
$includerel{"PAR"}++; |
2113
|
0
|
|
|
|
|
0
|
$includerel{"CHD"}++; |
2114
|
|
|
|
|
|
|
|
2115
|
0
|
|
|
|
|
0
|
$sabstring = "SAB :: include MSH"; |
2116
|
0
|
|
|
|
|
0
|
$relstring = "REL :: include CHD, PAR"; |
2117
|
|
|
|
|
|
|
|
2118
|
0
|
|
|
|
|
0
|
$includerelkeys = keys %includerel; |
2119
|
0
|
|
|
|
|
0
|
$includesabkeys = keys %includesab; |
2120
|
|
|
|
|
|
|
} |
2121
|
|
|
|
|
|
|
|
2122
|
|
|
|
|
|
|
# set the defaults |
2123
|
0
|
0
|
0
|
|
|
0
|
if($includereldefkeys <= 0 && $excludereldefkeys <= 0) { |
2124
|
|
|
|
|
|
|
|
2125
|
0
|
|
|
|
|
0
|
$includesabdef{"UMLS_ALL"}++; |
2126
|
0
|
|
|
|
|
0
|
$includereldef{"UMLS_ALL"}++; |
2127
|
|
|
|
|
|
|
|
2128
|
0
|
|
|
|
|
0
|
$sabdefstring = "SAB :: include UMLS_ALL"; |
2129
|
0
|
|
|
|
|
0
|
$reldefstring = "REL :: include UMLS_ALL"; |
2130
|
|
|
|
|
|
|
|
2131
|
0
|
|
|
|
|
0
|
$includereldefkeys = keys %includereldef; |
2132
|
0
|
|
|
|
|
0
|
$includesabdefkeys = keys %includesabdef; |
2133
|
|
|
|
|
|
|
|
2134
|
|
|
|
|
|
|
} |
2135
|
|
|
|
|
|
|
else { |
2136
|
0
|
|
|
|
|
0
|
$defflag = 1; |
2137
|
|
|
|
|
|
|
} |
2138
|
|
|
|
|
|
|
|
2139
|
|
|
|
|
|
|
# The order matters here so don't mess with it! The relations have to be set |
2140
|
|
|
|
|
|
|
# prior to the sabs and both need to be set prior to the relas. |
2141
|
|
|
|
|
|
|
|
2142
|
|
|
|
|
|
|
# set the relations |
2143
|
0
|
|
|
|
|
0
|
$self->_setRelations($includerelkeys, $excluderelkeys, \%includerel, \%excluderel); |
2144
|
|
|
|
|
|
|
|
2145
|
|
|
|
|
|
|
# set the sabs |
2146
|
0
|
|
|
|
|
0
|
$self->_setSabs($includesabkeys, $excludesabkeys, \%includesab, \%excludesab); |
2147
|
|
|
|
|
|
|
|
2148
|
|
|
|
|
|
|
# set the relas as long as there exists a PAR/CHD or RB/RN relation |
2149
|
0
|
0
|
|
|
|
0
|
if($relations=~/(PAR|CHD|RB|RN)/) { |
2150
|
0
|
|
|
|
|
0
|
$self->_setRelas($includerelakeys, $excluderelakeys, \%includerela, \%excluderela); |
2151
|
|
|
|
|
|
|
} |
2152
|
|
|
|
|
|
|
else { |
2153
|
0
|
0
|
0
|
|
|
0
|
if(($includerelkeys > 0 || $excluderelkeys > 0) && |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2154
|
|
|
|
|
|
|
($includerelakeys > 0 || $excluderelakeys > 0) ) { |
2155
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2156
|
|
|
|
|
|
|
$function, |
2157
|
|
|
|
|
|
|
"The rela relations (RELA) can only be used with the PAR/CHD or RB/RN relations (REL).", |
2158
|
|
|
|
|
|
|
5); |
2159
|
|
|
|
|
|
|
} |
2160
|
|
|
|
|
|
|
} |
2161
|
|
|
|
|
|
|
|
2162
|
|
|
|
|
|
|
# set the sabs for the CUI and extended definitions |
2163
|
0
|
|
|
|
|
0
|
$self->_setSabDef($includesabdefkeys, $excludesabdefkeys, \%includesabdef, \%excludesabdef); |
2164
|
|
|
|
|
|
|
|
2165
|
|
|
|
|
|
|
# set the rels for the extended definition |
2166
|
0
|
|
|
|
|
0
|
$self->_setRelDef($includereldefkeys, $excludereldefkeys, \%includereldef, \%excludereldef); |
2167
|
|
|
|
|
|
|
|
2168
|
|
|
|
|
|
|
# set the relas for the extended definition |
2169
|
0
|
0
|
|
|
|
0
|
if($reldefstring=~/(PAR|CHD|RB|RN)/) { |
2170
|
0
|
|
|
|
|
0
|
$self->_setRelaDef($includereladefkeys, $excludereladefkeys, \%includereladef, \%excludereladef); |
2171
|
|
|
|
|
|
|
} |
2172
|
|
|
|
|
|
|
else { |
2173
|
0
|
0
|
0
|
|
|
0
|
if(($includereldefkeys > 0 || $excludereldefkeys > 0) && |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2174
|
|
|
|
|
|
|
($includereladefkeys > 0 || $excludereladefkeys > 0) ) { |
2175
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, |
2176
|
|
|
|
|
|
|
$function, |
2177
|
|
|
|
|
|
|
"The rela relations (RELADEF) can only be used with the PAR/CHD or RB/RN relations (RELDEF).", |
2178
|
|
|
|
|
|
|
5); |
2179
|
|
|
|
|
|
|
} |
2180
|
|
|
|
|
|
|
} |
2181
|
|
|
|
|
|
|
|
2182
|
|
|
|
|
|
|
# now at this point everything that is set with the names are set |
2183
|
|
|
|
|
|
|
# if though SABDEF has been set without SAB then use SABDEF |
2184
|
|
|
|
|
|
|
# similarity if SABREL has been set without REL then use SABREL |
2185
|
|
|
|
|
|
|
# set the relations - this is done right now to extract terms and |
2186
|
|
|
|
|
|
|
# and such from the umls - I don't really like how this is done but |
2187
|
|
|
|
|
|
|
# it will be okay for right now. It would be nice to have them |
2188
|
|
|
|
|
|
|
# completely seperate. Doing it this way though allows for the REL, |
2189
|
|
|
|
|
|
|
# SAB, RELDEF and SABDEF to all be specified - again order matters here. |
2190
|
|
|
|
|
|
|
|
2191
|
|
|
|
|
|
|
#if($includerelkeys == 0 && $excluderelkeys == 0) { |
2192
|
|
|
|
|
|
|
# $self->_setRelations($includereldefkeys, $excludereldefkeys, \%includereldef, \%excludereldef); |
2193
|
|
|
|
|
|
|
#} |
2194
|
|
|
|
|
|
|
#if($includesabkeys == 0 && $excludesabkeys == 0) { |
2195
|
|
|
|
|
|
|
# $self->_setSabs($includesabdefkeys, $excludesabdefkeys, \%includesabdef, \%excludesabdef); |
2196
|
|
|
|
|
|
|
#} |
2197
|
|
|
|
|
|
|
#if($includerelkeys == 0 && $excluderelkeys == 0) { |
2198
|
|
|
|
|
|
|
# if($relations=~/(PAR|CHD|RB|RN)/) { |
2199
|
|
|
|
|
|
|
# $self->_setRelas($includereladefkeys, $excludereladefkeys, \%includereladef, \%excludereladef); |
2200
|
|
|
|
|
|
|
# } |
2201
|
|
|
|
|
|
|
#} |
2202
|
|
|
|
|
|
|
|
2203
|
0
|
0
|
|
|
|
0
|
if($debug) { |
2204
|
0
|
0
|
|
|
|
0
|
if($umlsall) { print STDERR "SOURCE : UMLS_ALL\n"; } |
|
0
|
|
|
|
|
0
|
|
2205
|
0
|
|
|
|
|
0
|
else { print STDERR "SOURCE : $sources\n"; } |
2206
|
0
|
|
|
|
|
0
|
print STDERR "RELATIONS: $relations\n"; |
2207
|
0
|
|
|
|
|
0
|
print STDERR "PARENTS : $parentRelations\n"; |
2208
|
0
|
|
|
|
|
0
|
print STDERR "CHILDREN : $childRelations\n\n"; |
2209
|
0
|
0
|
|
|
|
0
|
if($sabdefsources eq "") { |
2210
|
0
|
|
|
|
|
0
|
print STDERR "SABDEF : UMLS_ALL\n"; |
2211
|
|
|
|
|
|
|
} |
2212
|
|
|
|
|
|
|
else { |
2213
|
0
|
|
|
|
|
0
|
print STDERR "SABDEF : $sabdefsources\n"; |
2214
|
|
|
|
|
|
|
} |
2215
|
0
|
|
|
|
|
0
|
my $reldefrelations = "UMLS_ALL"; |
2216
|
0
|
0
|
|
|
|
0
|
if($reldefstring ne "") { |
2217
|
0
|
|
|
|
|
0
|
$reldefstring=~/RELDEF :: include ([A-Z0-9\, ]+)/; |
2218
|
0
|
|
|
|
|
0
|
$reldefrelations = $1; |
2219
|
|
|
|
|
|
|
} |
2220
|
0
|
|
|
|
|
0
|
print STDERR "RELDEF : $reldefrelations\n"; |
2221
|
0
|
|
|
|
|
0
|
print STDERR "SAB : $sources\n"; |
2222
|
0
|
|
|
|
|
0
|
print STDERR "REL : $relations\n"; |
2223
|
|
|
|
|
|
|
} |
2224
|
|
|
|
|
|
|
} |
2225
|
|
|
|
|
|
|
|
2226
|
|
|
|
|
|
|
# returns the SAB from the configuratino file |
2227
|
|
|
|
|
|
|
# input : |
2228
|
|
|
|
|
|
|
# output: $string <- containing SAB line from config file |
2229
|
|
|
|
|
|
|
sub _getSabString { |
2230
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2231
|
|
|
|
|
|
|
|
2232
|
0
|
|
|
|
|
0
|
return $sabstring; |
2233
|
|
|
|
|
|
|
} |
2234
|
|
|
|
|
|
|
|
2235
|
|
|
|
|
|
|
# returns the REL from the configuratino file |
2236
|
|
|
|
|
|
|
# input : |
2237
|
|
|
|
|
|
|
# output: $string <- containing REL line from config file |
2238
|
|
|
|
|
|
|
sub _getRelString { |
2239
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2240
|
|
|
|
|
|
|
|
2241
|
0
|
|
|
|
|
0
|
return $relstring; |
2242
|
|
|
|
|
|
|
} |
2243
|
|
|
|
|
|
|
|
2244
|
|
|
|
|
|
|
# returns the RELA from the configuratino file |
2245
|
|
|
|
|
|
|
# input : |
2246
|
|
|
|
|
|
|
# output: $string <- containing RELA line from config file |
2247
|
|
|
|
|
|
|
sub _getRelaString { |
2248
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2249
|
|
|
|
|
|
|
|
2250
|
0
|
|
|
|
|
0
|
return $relastring; |
2251
|
|
|
|
|
|
|
} |
2252
|
|
|
|
|
|
|
|
2253
|
|
|
|
|
|
|
# returns the SABDEF from the configuratino file |
2254
|
|
|
|
|
|
|
# input : |
2255
|
|
|
|
|
|
|
# output: $string <- containing SABDEF line from config file |
2256
|
|
|
|
|
|
|
sub _getSabDefString { |
2257
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2258
|
|
|
|
|
|
|
|
2259
|
0
|
|
|
|
|
0
|
return $sabdefstring; |
2260
|
|
|
|
|
|
|
} |
2261
|
|
|
|
|
|
|
|
2262
|
|
|
|
|
|
|
# returns the RELDEF from the configuratino file |
2263
|
|
|
|
|
|
|
# input : |
2264
|
|
|
|
|
|
|
# output: $string <- containing RELDEF line from config file |
2265
|
|
|
|
|
|
|
sub _getRelDefString { |
2266
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2267
|
|
|
|
|
|
|
|
2268
|
0
|
|
|
|
|
0
|
return $reldefstring; |
2269
|
|
|
|
|
|
|
} |
2270
|
|
|
|
|
|
|
|
2271
|
|
|
|
|
|
|
|
2272
|
|
|
|
|
|
|
|
2273
|
|
|
|
|
|
|
# set the version |
2274
|
|
|
|
|
|
|
# input : |
2275
|
|
|
|
|
|
|
# output: |
2276
|
|
|
|
|
|
|
sub _setVersion { |
2277
|
|
|
|
|
|
|
|
2278
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2279
|
|
|
|
|
|
|
|
2280
|
0
|
|
|
|
|
0
|
my $function = "_setVersion"; |
2281
|
0
|
|
|
|
|
0
|
&_debug($function); |
2282
|
|
|
|
|
|
|
|
2283
|
|
|
|
|
|
|
# check self |
2284
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2285
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2286
|
|
|
|
|
|
|
} |
2287
|
|
|
|
|
|
|
|
2288
|
|
|
|
|
|
|
# set the database |
2289
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
2290
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
2291
|
|
|
|
|
|
|
|
2292
|
|
|
|
|
|
|
# get the verstion information |
2293
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select EXPL from MRDOC where VALUE = \'mmsys.version\'"); |
2294
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2295
|
|
|
|
|
|
|
|
2296
|
|
|
|
|
|
|
# check that it was returned |
2297
|
0
|
0
|
|
|
|
0
|
if(scalar(@{$arrRef}) < 1) { |
|
0
|
|
|
|
|
0
|
|
2298
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "No version info in table MRDOC.", 7); |
2299
|
|
|
|
|
|
|
} |
2300
|
|
|
|
|
|
|
|
2301
|
0
|
|
|
|
|
0
|
($version) = @{$arrRef}; |
|
0
|
|
|
|
|
0
|
|
2302
|
|
|
|
|
|
|
} |
2303
|
|
|
|
|
|
|
|
2304
|
|
|
|
|
|
|
|
2305
|
|
|
|
|
|
|
# check if the UMLS tables required all exist |
2306
|
|
|
|
|
|
|
# input : |
2307
|
|
|
|
|
|
|
# output: |
2308
|
|
|
|
|
|
|
sub _checkTablesExist { |
2309
|
|
|
|
|
|
|
|
2310
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2311
|
|
|
|
|
|
|
|
2312
|
0
|
|
|
|
|
0
|
my $function = "_checkTablesExist"; |
2313
|
0
|
|
|
|
|
0
|
&_debug($function); |
2314
|
|
|
|
|
|
|
|
2315
|
|
|
|
|
|
|
# check self |
2316
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2317
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2318
|
|
|
|
|
|
|
} |
2319
|
|
|
|
|
|
|
|
2320
|
|
|
|
|
|
|
# set up the database |
2321
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
2322
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
2323
|
|
|
|
|
|
|
|
2324
|
|
|
|
|
|
|
# check if the tables exist... |
2325
|
0
|
|
|
|
|
0
|
my $sth = $db->prepare("show tables"); |
2326
|
0
|
|
|
|
|
0
|
$sth->execute(); |
2327
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
2328
|
|
|
|
|
|
|
|
2329
|
0
|
|
|
|
|
0
|
my $table = ""; |
2330
|
0
|
|
|
|
|
0
|
my %tables = (); |
2331
|
0
|
|
|
|
|
0
|
while(($table) = $sth->fetchrow()) { |
2332
|
0
|
|
|
|
|
0
|
$tables{$table} = 1; |
2333
|
|
|
|
|
|
|
} |
2334
|
0
|
|
|
|
|
0
|
$sth->finish(); |
2335
|
|
|
|
|
|
|
|
2336
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"MRCONSO"} and !defined $tables{"mrconso"}) { |
2337
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table MRCONSO not found in database", 7); |
2338
|
|
|
|
|
|
|
} |
2339
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"MRDEF"} and !defined $tables{"mrdef"}) { |
2340
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table MRDEF not found in database", 7); |
2341
|
|
|
|
|
|
|
} |
2342
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"SRDEF"} and !defined $tables{"srdef"}) { |
2343
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table SRDEF not found in database", 7); |
2344
|
|
|
|
|
|
|
} |
2345
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"MRREL"} and !defined $tables{"mrrel"}) { |
2346
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table MRREL not found in database", 7); |
2347
|
|
|
|
|
|
|
} |
2348
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"MRDOC"} and !defined $tables{"mrdoc"}) { |
2349
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table MRDEC not found in database", 7); |
2350
|
|
|
|
|
|
|
} |
2351
|
0
|
0
|
0
|
|
|
0
|
if(!defined $tables{"MRSAB"} and !defined $tables{"mrsab"}) { |
2352
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Table MRSAB not found in database", 7); |
2353
|
|
|
|
|
|
|
} |
2354
|
|
|
|
|
|
|
} |
2355
|
|
|
|
|
|
|
|
2356
|
|
|
|
|
|
|
# method to set the global parameter options |
2357
|
|
|
|
|
|
|
# input : $params <- reference to a hash |
2358
|
|
|
|
|
|
|
# output: |
2359
|
|
|
|
|
|
|
sub _setOptions { |
2360
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2361
|
0
|
|
|
|
|
0
|
my $params = shift; |
2362
|
|
|
|
|
|
|
|
2363
|
0
|
|
|
|
|
0
|
my $function = "_setOptions"; |
2364
|
0
|
|
|
|
|
0
|
&_debug($function); |
2365
|
|
|
|
|
|
|
|
2366
|
|
|
|
|
|
|
# check self |
2367
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2368
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2369
|
|
|
|
|
|
|
} |
2370
|
|
|
|
|
|
|
|
2371
|
|
|
|
|
|
|
# check the params |
2372
|
0
|
0
|
|
|
|
0
|
$params = {} if(!defined $params); |
2373
|
|
|
|
|
|
|
|
2374
|
|
|
|
|
|
|
# get all the parameters |
2375
|
0
|
|
|
|
|
0
|
my $verbose = $params->{'verbose'}; |
2376
|
0
|
|
|
|
|
0
|
my $cuilist = $params->{'cuilist'}; |
2377
|
0
|
|
|
|
|
0
|
my $t = $params->{'t'}; |
2378
|
0
|
|
|
|
|
0
|
my $debugoption = $params->{'debug'}; |
2379
|
0
|
|
|
|
|
0
|
my $config = $params->{'config'}; |
2380
|
|
|
|
|
|
|
|
2381
|
0
|
0
|
|
|
|
0
|
if(defined $t) { |
2382
|
0
|
|
|
|
|
0
|
$option_t = 1; |
2383
|
|
|
|
|
|
|
} |
2384
|
|
|
|
|
|
|
|
2385
|
0
|
|
|
|
|
0
|
my $output = ""; |
2386
|
|
|
|
|
|
|
|
2387
|
0
|
0
|
0
|
|
|
0
|
if(defined $verbose || defined $cuilist || |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
2388
|
|
|
|
|
|
|
defined $debugoption || defined $config) { |
2389
|
0
|
|
|
|
|
0
|
$output .= "\nCuiFinder User Options: \n"; |
2390
|
|
|
|
|
|
|
} |
2391
|
|
|
|
|
|
|
|
2392
|
|
|
|
|
|
|
# check the debug option |
2393
|
0
|
0
|
|
|
|
0
|
if(defined $debugoption) { |
2394
|
0
|
|
|
|
|
0
|
$debug = 1; |
2395
|
0
|
|
|
|
|
0
|
$output .= " --debug"; |
2396
|
|
|
|
|
|
|
} |
2397
|
|
|
|
|
|
|
|
2398
|
|
|
|
|
|
|
# check if verbose run has been identified |
2399
|
0
|
0
|
|
|
|
0
|
if(defined $verbose) { |
2400
|
0
|
|
|
|
|
0
|
$option_verbose = 1; |
2401
|
0
|
|
|
|
|
0
|
$output .= " --verbose option set\n"; |
2402
|
|
|
|
|
|
|
} |
2403
|
|
|
|
|
|
|
|
2404
|
|
|
|
|
|
|
|
2405
|
|
|
|
|
|
|
# check if the cuilist option has been set |
2406
|
0
|
0
|
|
|
|
0
|
if(defined $cuilist) { |
2407
|
0
|
|
|
|
|
0
|
$option_cuilist = 1; |
2408
|
0
|
|
|
|
|
0
|
$output .= " --cuilist option set\n"; |
2409
|
|
|
|
|
|
|
} |
2410
|
|
|
|
|
|
|
|
2411
|
|
|
|
|
|
|
# check if the config file is set |
2412
|
0
|
0
|
|
|
|
0
|
if(defined $config) { |
2413
|
0
|
|
|
|
|
0
|
$option_config = 1; |
2414
|
0
|
|
|
|
|
0
|
$output .= " --config option set\n"; |
2415
|
|
|
|
|
|
|
} |
2416
|
|
|
|
|
|
|
|
2417
|
0
|
0
|
|
|
|
0
|
if($option_t == 0) { |
2418
|
0
|
|
|
|
|
0
|
print STDERR "$output\n\n"; |
2419
|
|
|
|
|
|
|
} |
2420
|
|
|
|
|
|
|
} |
2421
|
|
|
|
|
|
|
|
2422
|
|
|
|
|
|
|
# method to set the umlsinterface index database |
2423
|
|
|
|
|
|
|
# input : $params <- reference to a hash |
2424
|
|
|
|
|
|
|
# output: |
2425
|
|
|
|
|
|
|
sub _setDatabase { |
2426
|
|
|
|
|
|
|
|
2427
|
22
|
|
|
22
|
|
27
|
my $self = shift; |
2428
|
22
|
|
|
|
|
34
|
my $params = shift; |
2429
|
|
|
|
|
|
|
|
2430
|
22
|
|
|
|
|
47
|
my $function = "_setDatabase"; |
2431
|
22
|
|
|
|
|
64
|
&_debug($function); |
2432
|
|
|
|
|
|
|
|
2433
|
|
|
|
|
|
|
# check self |
2434
|
22
|
50
|
33
|
|
|
127
|
if(!defined $self || !ref $self) { |
2435
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2436
|
|
|
|
|
|
|
} |
2437
|
|
|
|
|
|
|
|
2438
|
|
|
|
|
|
|
# check the params |
2439
|
22
|
50
|
|
|
|
112
|
$params = {} if(!defined $params); |
2440
|
|
|
|
|
|
|
|
2441
|
|
|
|
|
|
|
# get the database connection parameters |
2442
|
22
|
|
|
|
|
46
|
my $database = $params->{'database'}; |
2443
|
22
|
|
|
|
|
40
|
my $hostname = $params->{'hostname'}; |
2444
|
22
|
|
|
|
|
40
|
my $socket = $params->{'socket'}; |
2445
|
22
|
|
|
|
|
36
|
my $port = $params->{'port'}; |
2446
|
22
|
|
|
|
|
33
|
my $username = $params->{'username'}; |
2447
|
22
|
|
|
|
|
29
|
my $password = $params->{'password'}; |
2448
|
|
|
|
|
|
|
|
2449
|
|
|
|
|
|
|
# set up defaults if the options were not passed |
2450
|
22
|
50
|
|
|
|
61
|
if(! defined $database) { $database = "umls"; } |
|
22
|
|
|
|
|
36
|
|
2451
|
22
|
50
|
|
|
|
55
|
if(! defined $socket) { $socket = "/var/run/mysqld/mysqld.sock"; } |
|
22
|
|
|
|
|
37
|
|
2452
|
22
|
50
|
|
|
|
61
|
if(! defined $hostname) { $hostname = "localhost"; } |
|
22
|
|
|
|
|
41
|
|
2453
|
|
|
|
|
|
|
|
2454
|
|
|
|
|
|
|
# initialize the database handler |
2455
|
22
|
|
|
|
|
28
|
my $db = ""; |
2456
|
|
|
|
|
|
|
|
2457
|
|
|
|
|
|
|
# create the database object... |
2458
|
22
|
50
|
33
|
|
|
92
|
if(defined $username and defined $password) { |
2459
|
0
|
0
|
|
|
|
0
|
if($debug) { print STDERR "Connecting with username and password\n"; } |
|
0
|
|
|
|
|
0
|
|
2460
|
0
|
|
|
|
|
0
|
$db = DBI->connect("DBI:mysql:database=$database;mysql_socket=$socket;host=$hostname",$username, $password, {RaiseError => 0}); |
2461
|
|
|
|
|
|
|
} |
2462
|
|
|
|
|
|
|
else { |
2463
|
22
|
50
|
|
|
|
61
|
if($debug) { print STDERR "Connecting using the my.cnf file\n"; } |
|
0
|
|
|
|
|
0
|
|
2464
|
22
|
|
|
|
|
56
|
my $dsn = "DBI:mysql:umls;mysql_read_default_group=client;"; |
2465
|
22
|
|
|
|
|
162
|
$db = DBI->connect($dsn); |
2466
|
|
|
|
|
|
|
} |
2467
|
|
|
|
|
|
|
|
2468
|
|
|
|
|
|
|
# check if there is an error |
2469
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2470
|
|
|
|
|
|
|
|
2471
|
|
|
|
|
|
|
# check that the db exists |
2472
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
2473
|
|
|
|
|
|
|
|
2474
|
|
|
|
|
|
|
# set database parameters |
2475
|
0
|
|
|
|
|
0
|
$db->{'mysql_enable_utf8'} = 1; |
2476
|
0
|
|
|
|
|
0
|
$db->do('SET NAMES utf8'); |
2477
|
0
|
|
|
|
|
0
|
$db->{mysql_auto_reconnect} = 1; |
2478
|
|
|
|
|
|
|
|
2479
|
|
|
|
|
|
|
# set the self parameters |
2480
|
0
|
|
|
|
|
0
|
$self->{'db'} = $db; |
2481
|
0
|
|
|
|
|
0
|
$self->{'username'} = $username; |
2482
|
0
|
|
|
|
|
0
|
$self->{'password'} = $password; |
2483
|
0
|
|
|
|
|
0
|
$self->{'hostname'} = $hostname; |
2484
|
0
|
|
|
|
|
0
|
$self->{'socket'} = $socket; |
2485
|
0
|
|
|
|
|
0
|
$self->{'database'} = $database; |
2486
|
|
|
|
|
|
|
|
2487
|
|
|
|
|
|
|
# return the database handler |
2488
|
0
|
|
|
|
|
0
|
return $db; |
2489
|
|
|
|
|
|
|
} |
2490
|
|
|
|
|
|
|
|
2491
|
|
|
|
|
|
|
# returns the parameters set in the configuration file |
2492
|
|
|
|
|
|
|
# input: |
2493
|
|
|
|
|
|
|
# output : $hash <- reference to hash containing parameters in the |
2494
|
|
|
|
|
|
|
# configuration file - if there was not config |
2495
|
|
|
|
|
|
|
# file the hash is empty and defaults are being |
2496
|
|
|
|
|
|
|
# use |
2497
|
|
|
|
|
|
|
sub _getConfigParameters { |
2498
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2499
|
|
|
|
|
|
|
|
2500
|
0
|
|
|
|
|
0
|
my $function = "_getConfigParameters"; |
2501
|
|
|
|
|
|
|
|
2502
|
0
|
|
|
|
|
0
|
return \%parameters; |
2503
|
|
|
|
|
|
|
} |
2504
|
|
|
|
|
|
|
|
2505
|
|
|
|
|
|
|
# returns all of the cuis given the specified set of sources |
2506
|
|
|
|
|
|
|
# and relations defined in the configuration file |
2507
|
|
|
|
|
|
|
# input : $sab <- string containing a source |
2508
|
|
|
|
|
|
|
# output: $array <- reference to array of cuis |
2509
|
|
|
|
|
|
|
sub _getCuis { |
2510
|
|
|
|
|
|
|
|
2511
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2512
|
0
|
|
|
|
|
0
|
my $sab = shift; |
2513
|
|
|
|
|
|
|
|
2514
|
0
|
|
|
|
|
0
|
my $function = "_getCuis"; |
2515
|
|
|
|
|
|
|
#&_debug($function); |
2516
|
|
|
|
|
|
|
|
2517
|
|
|
|
|
|
|
# check self |
2518
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2519
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2520
|
|
|
|
|
|
|
} |
2521
|
|
|
|
|
|
|
|
2522
|
|
|
|
|
|
|
# check input variables |
2523
|
0
|
0
|
|
|
|
0
|
if(!$sab) { $errorhandler->_error($pkg, $function, "Error with input variable \$sab.", 4); } |
|
0
|
|
|
|
|
0
|
|
2524
|
|
|
|
|
|
|
|
2525
|
|
|
|
|
|
|
# set up the database |
2526
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
2527
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
2528
|
|
|
|
|
|
|
|
2529
|
|
|
|
|
|
|
# NOTE: it is quicker to get all the CUI1s and then all of the CUI2 and then merge |
2530
|
|
|
|
|
|
|
# rather than try to get them all together in a single query. |
2531
|
|
|
|
|
|
|
# get all of the CUI1s |
2532
|
0
|
|
|
|
|
0
|
my $allCui1 = $db->selectcol_arrayref("select CUI1 from MRREL where ($relations) and (SAB=\'$sab\') and SUPPRESS='N'\;"); |
2533
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2534
|
|
|
|
|
|
|
|
2535
|
|
|
|
|
|
|
# get all of the CUI1s |
2536
|
0
|
|
|
|
|
0
|
my $allCui2 = $db->selectcol_arrayref("select CUI2 from MRREL where ($relations) and (SAB=\'$sab\')and SUPPRESS='N'"); |
2537
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2538
|
|
|
|
|
|
|
|
2539
|
|
|
|
|
|
|
# merge and return them |
2540
|
0
|
|
|
|
|
0
|
my @allCuis = (@{$allCui1}, @{$allCui2}); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
2541
|
|
|
|
|
|
|
|
2542
|
0
|
|
|
|
|
0
|
return \@allCuis; |
2543
|
|
|
|
|
|
|
} |
2544
|
|
|
|
|
|
|
|
2545
|
|
|
|
|
|
|
# Takes as input a SAB and returns its corresponding |
2546
|
|
|
|
|
|
|
# UMLS CUI. Keep in mind this is the root cui not |
2547
|
|
|
|
|
|
|
# the version cui that is returned. The information |
2548
|
|
|
|
|
|
|
# for this is obtained from the MRSAB table |
2549
|
|
|
|
|
|
|
# input : $sab <- string containing source |
2550
|
|
|
|
|
|
|
# output: $cui <- string containing cui |
2551
|
|
|
|
|
|
|
sub _getSabCui { |
2552
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2553
|
0
|
|
|
|
|
0
|
my $sab = shift; |
2554
|
|
|
|
|
|
|
|
2555
|
0
|
|
|
|
|
0
|
my $function = "_getSabCui"; |
2556
|
|
|
|
|
|
|
|
2557
|
|
|
|
|
|
|
# check self |
2558
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2559
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2560
|
|
|
|
|
|
|
} |
2561
|
|
|
|
|
|
|
|
2562
|
|
|
|
|
|
|
# check input variables |
2563
|
0
|
0
|
|
|
|
0
|
if(!$sab) { $errorhandler->_error($pkg, $function, "Error with input variable \$sab.", 4); } |
|
0
|
|
|
|
|
0
|
|
2564
|
|
|
|
|
|
|
|
2565
|
|
|
|
|
|
|
# set up the database |
2566
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
2567
|
0
|
0
|
|
|
|
0
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
0
|
|
2568
|
|
|
|
|
|
|
|
2569
|
|
|
|
|
|
|
# if the sab is umls all |
2570
|
0
|
0
|
|
|
|
0
|
if($sab eq "UMLS_ALL") { |
2571
|
0
|
|
|
|
|
0
|
return $umlsRoot; |
2572
|
|
|
|
|
|
|
} |
2573
|
|
|
|
|
|
|
|
2574
|
0
|
|
|
|
|
0
|
my $arrRef = $db->selectcol_arrayref("select distinct RCUI from MRSAB where RSAB='$sab' and SABIN='Y'"); |
2575
|
0
|
|
|
|
|
0
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2576
|
|
|
|
|
|
|
|
2577
|
0
|
0
|
|
|
|
0
|
if(scalar(@{$arrRef}) < 1) { |
|
0
|
|
|
|
|
0
|
|
2578
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "SAB ($sab) does not exist in your current UMLS view.", 7); |
2579
|
|
|
|
|
|
|
} |
2580
|
|
|
|
|
|
|
|
2581
|
0
|
0
|
|
|
|
0
|
if(scalar(@{$arrRef}) > 1) { |
|
0
|
|
|
|
|
0
|
|
2582
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "Internal error: Duplicate concept rows.", 7); |
2583
|
|
|
|
|
|
|
} |
2584
|
|
|
|
|
|
|
|
2585
|
0
|
|
|
|
|
0
|
return (pop @{$arrRef}); |
|
0
|
|
|
|
|
0
|
|
2586
|
|
|
|
|
|
|
} |
2587
|
|
|
|
|
|
|
|
2588
|
|
|
|
|
|
|
|
2589
|
|
|
|
|
|
|
# method to destroy the created object. |
2590
|
|
|
|
|
|
|
# input : |
2591
|
|
|
|
|
|
|
# output: |
2592
|
|
|
|
|
|
|
sub _disconnect { |
2593
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
2594
|
|
|
|
|
|
|
|
2595
|
0
|
|
|
|
|
0
|
my $function = "_disconnect"; |
2596
|
|
|
|
|
|
|
|
2597
|
|
|
|
|
|
|
# check self |
2598
|
0
|
0
|
0
|
|
|
0
|
if(!defined $self || !ref $self) { |
2599
|
0
|
|
|
|
|
0
|
$errorhandler->_error($pkg, $function, "", 2); |
2600
|
|
|
|
|
|
|
} |
2601
|
|
|
|
|
|
|
|
2602
|
0
|
0
|
|
|
|
0
|
if($self) { |
2603
|
0
|
|
|
|
|
0
|
my $db = $self->{'db'}; |
2604
|
0
|
0
|
|
|
|
0
|
$db->disconnect() if($db); |
2605
|
|
|
|
|
|
|
} |
2606
|
|
|
|
|
|
|
} |
2607
|
|
|
|
|
|
|
|
2608
|
|
|
|
|
|
|
# returns the version of the UMLS currently being used |
2609
|
|
|
|
|
|
|
# input : |
2610
|
|
|
|
|
|
|
# output: $version <- string containing version |
2611
|
|
|
|
|
|
|
sub _version { |
2612
|
|
|
|
|
|
|
|
2613
|
0
|
|
|
0
|
|
0
|
return $version; |
2614
|
|
|
|
|
|
|
} |
2615
|
|
|
|
|
|
|
|
2616
|
|
|
|
|
|
|
# print out the function name to standard error |
2617
|
|
|
|
|
|
|
# input : $function <- string containing function name |
2618
|
|
|
|
|
|
|
# output: |
2619
|
|
|
|
|
|
|
sub _debug { |
2620
|
66
|
|
|
66
|
|
67
|
my $function = shift; |
2621
|
66
|
50
|
|
|
|
129
|
if($debug) { print STDERR "In UMLS::Interface::CuiFinder::$function\n"; } |
|
0
|
|
|
|
|
|
|
2622
|
|
|
|
|
|
|
} |
2623
|
|
|
|
|
|
|
|
2624
|
|
|
|
|
|
|
###################################################################### |
2625
|
|
|
|
|
|
|
# functions to obtain information about the cuis |
2626
|
|
|
|
|
|
|
###################################################################### |
2627
|
|
|
|
|
|
|
|
2628
|
|
|
|
|
|
|
# Method to check if a concept ID exists in the database. |
2629
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
2630
|
|
|
|
|
|
|
# output: $bool <- string indicating if the cui exists |
2631
|
|
|
|
|
|
|
sub _exists { |
2632
|
|
|
|
|
|
|
|
2633
|
0
|
|
|
0
|
|
|
my $self = shift; |
2634
|
0
|
|
|
|
|
|
my $concept = shift; |
2635
|
|
|
|
|
|
|
|
2636
|
0
|
|
|
|
|
|
my $function = "_exists"; |
2637
|
|
|
|
|
|
|
|
2638
|
|
|
|
|
|
|
# check self |
2639
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2640
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2641
|
|
|
|
|
|
|
} |
2642
|
|
|
|
|
|
|
|
2643
|
|
|
|
|
|
|
# check parameter exists |
2644
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2645
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2646
|
|
|
|
|
|
|
} |
2647
|
|
|
|
|
|
|
|
2648
|
|
|
|
|
|
|
# check if valid concept |
2649
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2650
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2651
|
|
|
|
|
|
|
} |
2652
|
|
|
|
|
|
|
|
2653
|
|
|
|
|
|
|
# check if root |
2654
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { return 1; } |
|
0
|
|
|
|
|
|
|
2655
|
|
|
|
|
|
|
|
2656
|
|
|
|
|
|
|
# check if a sab |
2657
|
0
|
0
|
|
|
|
|
if(exists $sabHash{$concept}) { return 1; } |
|
0
|
|
|
|
|
|
|
2658
|
|
|
|
|
|
|
|
2659
|
|
|
|
|
|
|
# set up database |
2660
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2661
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2662
|
|
|
|
|
|
|
|
2663
|
|
|
|
|
|
|
# get the concept |
2664
|
0
|
|
|
|
|
|
my $arrRef = ""; |
2665
|
0
|
0
|
|
|
|
|
if($umlsall) { |
2666
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where CUI='$concept'"); |
2667
|
|
|
|
|
|
|
} |
2668
|
|
|
|
|
|
|
else { |
2669
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where CUI='$concept' and $sources"); |
2670
|
|
|
|
|
|
|
} |
2671
|
|
|
|
|
|
|
|
2672
|
|
|
|
|
|
|
# check the database for errors |
2673
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2674
|
|
|
|
|
|
|
|
2675
|
|
|
|
|
|
|
# get the count |
2676
|
0
|
|
|
|
|
|
my $count = scalar(@{$arrRef}); |
|
0
|
|
|
|
|
|
|
2677
|
|
|
|
|
|
|
|
2678
|
0
|
0
|
|
|
|
|
return 1 if($count); return 0; |
|
0
|
|
|
|
|
|
|
2679
|
|
|
|
|
|
|
} |
2680
|
|
|
|
|
|
|
|
2681
|
|
|
|
|
|
|
# method that returns a list of concepts (@concepts) related |
2682
|
|
|
|
|
|
|
# to a concept $concept through a relation $rel |
2683
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2684
|
|
|
|
|
|
|
# $rel <- string containing a relation |
2685
|
|
|
|
|
|
|
# output: $array <- reference to an array of cuis |
2686
|
|
|
|
|
|
|
sub _getRelated { |
2687
|
|
|
|
|
|
|
|
2688
|
0
|
|
|
0
|
|
|
my $self = shift; |
2689
|
0
|
|
|
|
|
|
my $concept = shift; |
2690
|
0
|
|
|
|
|
|
my $rel = shift; |
2691
|
|
|
|
|
|
|
|
2692
|
0
|
|
|
|
|
|
my $function = "_getRelated"; |
2693
|
0
|
|
|
|
|
|
&_debug($function); |
2694
|
|
|
|
|
|
|
|
2695
|
|
|
|
|
|
|
# check self |
2696
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2697
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2698
|
|
|
|
|
|
|
} |
2699
|
|
|
|
|
|
|
|
2700
|
|
|
|
|
|
|
# check parameter exists |
2701
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2702
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2703
|
|
|
|
|
|
|
} |
2704
|
|
|
|
|
|
|
|
2705
|
0
|
0
|
|
|
|
|
if(!defined $rel) { |
2706
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$rel.", 4); |
2707
|
|
|
|
|
|
|
} |
2708
|
|
|
|
|
|
|
|
2709
|
|
|
|
|
|
|
# check if valid concept |
2710
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2711
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2712
|
|
|
|
|
|
|
} |
2713
|
|
|
|
|
|
|
|
2714
|
|
|
|
|
|
|
# set up database |
2715
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2716
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2717
|
|
|
|
|
|
|
|
2718
|
|
|
|
|
|
|
# return all the relations 'rel' for cui 'concept' |
2719
|
0
|
|
|
|
|
|
my $arrRef = ""; |
2720
|
0
|
0
|
|
|
|
|
if($umlsall) { |
2721
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and REL='$rel' and CUI2!='$concept'"); |
2722
|
|
|
|
|
|
|
} |
2723
|
|
|
|
|
|
|
else { |
2724
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and REL='$rel' and ($sources) and CUI2!='$concept'"); |
2725
|
|
|
|
|
|
|
} |
2726
|
|
|
|
|
|
|
|
2727
|
|
|
|
|
|
|
# check for errors |
2728
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2729
|
|
|
|
|
|
|
|
2730
|
0
|
|
|
|
|
|
return $arrRef; |
2731
|
|
|
|
|
|
|
} |
2732
|
|
|
|
|
|
|
|
2733
|
|
|
|
|
|
|
# method that returns the preferred term of a cui from the UMLS |
2734
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2735
|
|
|
|
|
|
|
# output: $string <- string containing the preferred term |
2736
|
|
|
|
|
|
|
sub _getAllPreferredTerm { |
2737
|
0
|
|
|
0
|
|
|
my $self = shift; |
2738
|
0
|
|
|
|
|
|
my $concept = shift; |
2739
|
|
|
|
|
|
|
|
2740
|
0
|
|
|
|
|
|
my $function = "_getAllPreferredTerm"; |
2741
|
|
|
|
|
|
|
|
2742
|
|
|
|
|
|
|
# check self |
2743
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2744
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2745
|
|
|
|
|
|
|
} |
2746
|
|
|
|
|
|
|
|
2747
|
|
|
|
|
|
|
# check parameter exists |
2748
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2749
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2750
|
|
|
|
|
|
|
} |
2751
|
|
|
|
|
|
|
|
2752
|
|
|
|
|
|
|
# check if valid concept |
2753
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2754
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2755
|
|
|
|
|
|
|
} |
2756
|
|
|
|
|
|
|
|
2757
|
|
|
|
|
|
|
# set the return hash |
2758
|
0
|
|
|
|
|
|
my %retHash = (); |
2759
|
|
|
|
|
|
|
|
2760
|
|
|
|
|
|
|
# if the concept is the root return the root string |
2761
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
2762
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
2763
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2764
|
0
|
|
|
|
|
|
return \@array; |
2765
|
|
|
|
|
|
|
} |
2766
|
|
|
|
|
|
|
|
2767
|
|
|
|
|
|
|
# set the database |
2768
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2769
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2770
|
|
|
|
|
|
|
|
2771
|
|
|
|
|
|
|
# get the strings associated to the CUI |
2772
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept' and TS='P' and LAT='ENG'"); |
2773
|
|
|
|
|
|
|
|
2774
|
|
|
|
|
|
|
# check the database for errors |
2775
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2776
|
|
|
|
|
|
|
|
2777
|
|
|
|
|
|
|
# clean up the strings a bit and lower case them |
2778
|
0
|
|
|
|
|
|
my $term = ""; |
2779
|
0
|
|
|
|
|
|
foreach my $tr (@{$arrRef}) { |
|
0
|
|
|
|
|
|
|
2780
|
0
|
|
|
|
|
|
$tr =~ s/^\s+//; |
2781
|
0
|
|
|
|
|
|
$tr =~ s/\s+$//; |
2782
|
0
|
|
|
|
|
|
$tr =~ s/\s+/ /g; |
2783
|
0
|
|
|
|
|
|
$term = $tr; |
2784
|
|
|
|
|
|
|
} |
2785
|
|
|
|
|
|
|
|
2786
|
|
|
|
|
|
|
# return the strings |
2787
|
0
|
|
|
|
|
|
return $term; |
2788
|
|
|
|
|
|
|
} |
2789
|
|
|
|
|
|
|
|
2790
|
|
|
|
|
|
|
# method that returns the preferred term of a cui from |
2791
|
|
|
|
|
|
|
# sources specified in the configuration file |
2792
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2793
|
|
|
|
|
|
|
# output: $string <- string containing the preferred term |
2794
|
|
|
|
|
|
|
sub _getPreferredTerm { |
2795
|
0
|
|
|
0
|
|
|
my $self = shift; |
2796
|
0
|
|
|
|
|
|
my $concept = shift; |
2797
|
|
|
|
|
|
|
|
2798
|
0
|
|
|
|
|
|
my $function = "_getPreferredTerm"; |
2799
|
|
|
|
|
|
|
|
2800
|
|
|
|
|
|
|
# check self |
2801
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2802
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2803
|
|
|
|
|
|
|
} |
2804
|
|
|
|
|
|
|
|
2805
|
|
|
|
|
|
|
# check parameter exists |
2806
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2807
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2808
|
|
|
|
|
|
|
} |
2809
|
|
|
|
|
|
|
|
2810
|
|
|
|
|
|
|
# check if valid concept |
2811
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2812
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2813
|
|
|
|
|
|
|
} |
2814
|
|
|
|
|
|
|
|
2815
|
|
|
|
|
|
|
# set the return hash |
2816
|
0
|
|
|
|
|
|
my %retHash = (); |
2817
|
|
|
|
|
|
|
|
2818
|
|
|
|
|
|
|
# if the concept is the root return the root string |
2819
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
2820
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
2821
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2822
|
0
|
|
|
|
|
|
return \@array; |
2823
|
|
|
|
|
|
|
} |
2824
|
|
|
|
|
|
|
|
2825
|
|
|
|
|
|
|
# set the database |
2826
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2827
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2828
|
|
|
|
|
|
|
|
2829
|
|
|
|
|
|
|
# get the strings associated to the CUI |
2830
|
0
|
|
|
|
|
|
my $arrRef = ""; |
2831
|
0
|
0
|
|
|
|
|
if($umlsall) { |
2832
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept' and TS='P' and LAT='ENG'"); |
2833
|
|
|
|
|
|
|
} |
2834
|
|
|
|
|
|
|
else { |
2835
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept' and TS='P' and ($sources or SAB='SRC') and LAT='ENG'"); |
2836
|
|
|
|
|
|
|
} |
2837
|
|
|
|
|
|
|
|
2838
|
|
|
|
|
|
|
# check the database for errors |
2839
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2840
|
|
|
|
|
|
|
|
2841
|
|
|
|
|
|
|
|
2842
|
|
|
|
|
|
|
# clean up the strings a bit and lower case them |
2843
|
0
|
|
|
|
|
|
my $term = ""; |
2844
|
0
|
|
|
|
|
|
foreach my $tr (@{$arrRef}) { |
|
0
|
|
|
|
|
|
|
2845
|
0
|
|
|
|
|
|
$tr =~ s/^\s+//; |
2846
|
0
|
|
|
|
|
|
$tr =~ s/\s+$//; |
2847
|
0
|
|
|
|
|
|
$tr =~ s/\s+/ /g; |
2848
|
0
|
|
|
|
|
|
$term = $tr; |
2849
|
|
|
|
|
|
|
} |
2850
|
|
|
|
|
|
|
|
2851
|
|
|
|
|
|
|
# return the strings |
2852
|
0
|
|
|
|
|
|
return $term; |
2853
|
|
|
|
|
|
|
} |
2854
|
|
|
|
|
|
|
|
2855
|
|
|
|
|
|
|
|
2856
|
|
|
|
|
|
|
|
2857
|
|
|
|
|
|
|
# method that maps terms to cuis in the sources specified in |
2858
|
|
|
|
|
|
|
# in the configuration file by the user using the SAB parameter |
2859
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2860
|
|
|
|
|
|
|
# output: $array <- reference to an array of terms (strings) |
2861
|
|
|
|
|
|
|
sub _getTermList { |
2862
|
0
|
|
|
0
|
|
|
my $self = shift; |
2863
|
0
|
|
|
|
|
|
my $concept = shift; |
2864
|
|
|
|
|
|
|
|
2865
|
0
|
|
|
|
|
|
my $function = "_getTermList"; |
2866
|
|
|
|
|
|
|
|
2867
|
|
|
|
|
|
|
# check self |
2868
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2869
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2870
|
|
|
|
|
|
|
} |
2871
|
|
|
|
|
|
|
|
2872
|
|
|
|
|
|
|
# check parameter exists |
2873
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2874
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2875
|
|
|
|
|
|
|
} |
2876
|
|
|
|
|
|
|
|
2877
|
|
|
|
|
|
|
# check if valid concept |
2878
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2879
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2880
|
|
|
|
|
|
|
} |
2881
|
|
|
|
|
|
|
|
2882
|
|
|
|
|
|
|
# set the return hash |
2883
|
0
|
|
|
|
|
|
my %retHash = (); |
2884
|
|
|
|
|
|
|
|
2885
|
|
|
|
|
|
|
# if the concept is the root return the root string |
2886
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
2887
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
2888
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2889
|
0
|
|
|
|
|
|
return \@array; |
2890
|
|
|
|
|
|
|
} |
2891
|
|
|
|
|
|
|
|
2892
|
|
|
|
|
|
|
# set the database |
2893
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2894
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2895
|
|
|
|
|
|
|
|
2896
|
|
|
|
|
|
|
# get the strings associated to the CUI |
2897
|
0
|
|
|
|
|
|
my $arrRef = ""; |
2898
|
0
|
0
|
|
|
|
|
if($umlsall) { |
2899
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept'"); |
2900
|
|
|
|
|
|
|
} |
2901
|
|
|
|
|
|
|
else { |
2902
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept' and ($sources or SAB='SRC')"); |
2903
|
|
|
|
|
|
|
} |
2904
|
|
|
|
|
|
|
|
2905
|
|
|
|
|
|
|
# check the database for errors |
2906
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2907
|
|
|
|
|
|
|
|
2908
|
|
|
|
|
|
|
# clean up the strings a bit and lower case them |
2909
|
0
|
|
|
|
|
|
foreach my $tr (@{$arrRef}) { |
|
0
|
|
|
|
|
|
|
2910
|
0
|
|
|
|
|
|
$tr =~ s/^\s+//; |
2911
|
0
|
|
|
|
|
|
$tr =~ s/\s+$//; |
2912
|
0
|
|
|
|
|
|
$tr =~ s/\s+/ /g; |
2913
|
0
|
|
|
|
|
|
$retHash{lc($tr)} = 1; |
2914
|
|
|
|
|
|
|
} |
2915
|
|
|
|
|
|
|
|
2916
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2917
|
|
|
|
|
|
|
|
2918
|
|
|
|
|
|
|
# return the strings |
2919
|
0
|
|
|
|
|
|
return \@array; |
2920
|
|
|
|
|
|
|
} |
2921
|
|
|
|
|
|
|
|
2922
|
|
|
|
|
|
|
# method that maps terms to cuis in the sources specified in |
2923
|
|
|
|
|
|
|
# in the configuration file by the user using the SABDEF parameter |
2924
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2925
|
|
|
|
|
|
|
# output: $array <- reference to an array of terms |
2926
|
|
|
|
|
|
|
sub _getDefTermList { |
2927
|
0
|
|
|
0
|
|
|
my $self = shift; |
2928
|
0
|
|
|
|
|
|
my $concept = shift; |
2929
|
|
|
|
|
|
|
|
2930
|
0
|
|
|
|
|
|
my $function = "_getTermList"; |
2931
|
|
|
|
|
|
|
|
2932
|
|
|
|
|
|
|
# check self |
2933
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2934
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
2935
|
|
|
|
|
|
|
} |
2936
|
|
|
|
|
|
|
|
2937
|
|
|
|
|
|
|
# check parameter exists |
2938
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
2939
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
2940
|
|
|
|
|
|
|
} |
2941
|
|
|
|
|
|
|
|
2942
|
|
|
|
|
|
|
# check if valid concept |
2943
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
2944
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
2945
|
|
|
|
|
|
|
} |
2946
|
|
|
|
|
|
|
|
2947
|
|
|
|
|
|
|
# set the return hash |
2948
|
0
|
|
|
|
|
|
my %retHash = (); |
2949
|
|
|
|
|
|
|
|
2950
|
|
|
|
|
|
|
# if the concept is the root return the root string |
2951
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
2952
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
2953
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2954
|
0
|
|
|
|
|
|
return \@array; |
2955
|
|
|
|
|
|
|
} |
2956
|
|
|
|
|
|
|
|
2957
|
|
|
|
|
|
|
# set the database |
2958
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
2959
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
2960
|
|
|
|
|
|
|
|
2961
|
|
|
|
|
|
|
# get the strings associated to the CUI |
2962
|
0
|
|
|
|
|
|
my $arrRef = ""; |
2963
|
0
|
0
|
|
|
|
|
if($sabdef_umlsall) { |
2964
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept'"); |
2965
|
|
|
|
|
|
|
} |
2966
|
|
|
|
|
|
|
else { |
2967
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct STR from MRCONSO where CUI='$concept' and ($sabdefsources or SAB='SRC')"); |
2968
|
|
|
|
|
|
|
} |
2969
|
|
|
|
|
|
|
|
2970
|
|
|
|
|
|
|
# check the database for errors |
2971
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
2972
|
|
|
|
|
|
|
|
2973
|
|
|
|
|
|
|
# clean up the strings a bit and lower case them |
2974
|
0
|
|
|
|
|
|
foreach my $tr (@{$arrRef}) { |
|
0
|
|
|
|
|
|
|
2975
|
0
|
|
|
|
|
|
$tr =~ s/^\s+//; |
2976
|
0
|
|
|
|
|
|
$tr =~ s/\s+$//; |
2977
|
0
|
|
|
|
|
|
$tr =~ s/\s+/ /g; |
2978
|
0
|
|
|
|
|
|
$retHash{lc($tr)} = 1; |
2979
|
|
|
|
|
|
|
} |
2980
|
|
|
|
|
|
|
|
2981
|
|
|
|
|
|
|
# return the strings |
2982
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
2983
|
0
|
|
|
|
|
|
return \@array; |
2984
|
|
|
|
|
|
|
} |
2985
|
|
|
|
|
|
|
|
2986
|
|
|
|
|
|
|
# method that maps terms to cuis in the sources specified in |
2987
|
|
|
|
|
|
|
# in the configuration file by the user |
2988
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
2989
|
|
|
|
|
|
|
# output: $array <- reference to an array of terms and their sources |
2990
|
|
|
|
|
|
|
sub _getTermSabList { |
2991
|
0
|
|
|
0
|
|
|
my $self = shift; |
2992
|
0
|
|
|
|
|
|
my $concept = shift; |
2993
|
|
|
|
|
|
|
|
2994
|
0
|
|
|
|
|
|
my $function = "_getTermSabList"; |
2995
|
0
|
|
|
|
|
|
&_debug($function); |
2996
|
|
|
|
|
|
|
|
2997
|
|
|
|
|
|
|
# check self |
2998
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
2999
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3000
|
|
|
|
|
|
|
} |
3001
|
|
|
|
|
|
|
|
3002
|
|
|
|
|
|
|
# check parameter exists |
3003
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3004
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3005
|
|
|
|
|
|
|
} |
3006
|
|
|
|
|
|
|
|
3007
|
|
|
|
|
|
|
# check if valid concept |
3008
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3009
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3010
|
|
|
|
|
|
|
} |
3011
|
|
|
|
|
|
|
|
3012
|
|
|
|
|
|
|
# initialize the return hash |
3013
|
0
|
|
|
|
|
|
my %retHash = (); |
3014
|
|
|
|
|
|
|
|
3015
|
|
|
|
|
|
|
# if the concept is the root return the root string |
3016
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
3017
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
3018
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
3019
|
0
|
|
|
|
|
|
return \@array; |
3020
|
|
|
|
|
|
|
} |
3021
|
|
|
|
|
|
|
|
3022
|
|
|
|
|
|
|
# otherwise, set up the db |
3023
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3024
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3025
|
|
|
|
|
|
|
# get all of the strings with their corresponding sab |
3026
|
0
|
|
|
|
|
|
my %strhash = (); my $sql = ""; |
|
0
|
|
|
|
|
|
|
3027
|
0
|
0
|
|
|
|
|
if($sabdef_umlsall) { |
3028
|
0
|
|
|
|
|
|
$sql = qq{ select STR, SAB from MRCONSO where CUI='$concept' }; |
3029
|
|
|
|
|
|
|
} |
3030
|
|
|
|
|
|
|
else { |
3031
|
0
|
|
|
|
|
|
$sql = qq{select STR, SAB from MRCONSO where CUI='$concept' and ($sabdefsources or SAB='SRC') }; |
3032
|
|
|
|
|
|
|
} |
3033
|
0
|
|
|
|
|
|
my $sth = $db->prepare( $sql ); |
3034
|
0
|
|
|
|
|
|
$sth->execute(); |
3035
|
0
|
|
|
|
|
|
my($str, $sab); |
3036
|
0
|
|
|
|
|
|
$sth->bind_columns( undef, \$str, \$sab ); |
3037
|
0
|
|
|
|
|
|
while( $sth->fetch() ) { |
3038
|
0
|
|
|
|
|
|
$str =~ s/^\s+//; |
3039
|
0
|
|
|
|
|
|
$str =~ s/\s+$//; |
3040
|
0
|
|
|
|
|
|
$str =~ s/\s+/ /g; |
3041
|
0
|
|
|
|
|
|
$str = lc($str); |
3042
|
0
|
|
|
|
|
|
my $item = "$sab : $str"; |
3043
|
0
|
|
|
|
|
|
$retHash{$item}++; |
3044
|
|
|
|
|
|
|
} |
3045
|
|
|
|
|
|
|
|
3046
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
3047
|
0
|
|
|
|
|
|
$sth->finish(); |
3048
|
|
|
|
|
|
|
|
3049
|
|
|
|
|
|
|
# return keys |
3050
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
3051
|
0
|
|
|
|
|
|
return \@array; |
3052
|
|
|
|
|
|
|
} |
3053
|
|
|
|
|
|
|
|
3054
|
|
|
|
|
|
|
|
3055
|
|
|
|
|
|
|
# method to map terms to any concept in the umls |
3056
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
3057
|
|
|
|
|
|
|
# output: $array <- reference to an array containing terms (strings) |
3058
|
|
|
|
|
|
|
sub _getAllTerms { |
3059
|
0
|
|
|
0
|
|
|
my $self = shift; |
3060
|
0
|
|
|
|
|
|
my $concept = shift; |
3061
|
|
|
|
|
|
|
|
3062
|
0
|
|
|
|
|
|
my $function = "_getAllTerms"; |
3063
|
0
|
|
|
|
|
|
&_debug($function); |
3064
|
|
|
|
|
|
|
|
3065
|
|
|
|
|
|
|
# check self |
3066
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3067
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3068
|
|
|
|
|
|
|
} |
3069
|
|
|
|
|
|
|
|
3070
|
|
|
|
|
|
|
# check parameter exists |
3071
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3072
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3073
|
|
|
|
|
|
|
} |
3074
|
|
|
|
|
|
|
|
3075
|
|
|
|
|
|
|
# check if valid concept |
3076
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3077
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3078
|
|
|
|
|
|
|
} |
3079
|
|
|
|
|
|
|
|
3080
|
|
|
|
|
|
|
# initialize the return hash |
3081
|
0
|
|
|
|
|
|
my %retHash = (); |
3082
|
|
|
|
|
|
|
|
3083
|
|
|
|
|
|
|
# if the concept is the root return the root string |
3084
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
3085
|
0
|
|
|
|
|
|
$retHash{"**UMLS ROOT**"}++; |
3086
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
3087
|
0
|
|
|
|
|
|
return \@array; |
3088
|
|
|
|
|
|
|
} |
3089
|
|
|
|
|
|
|
|
3090
|
|
|
|
|
|
|
# otherwise, set up the db |
3091
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3092
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3093
|
|
|
|
|
|
|
|
3094
|
|
|
|
|
|
|
# get all of the strings with their corresponding sab |
3095
|
0
|
|
|
|
|
|
my %strhash = (); |
3096
|
0
|
|
|
|
|
|
my $sql = qq{ select STR, SAB from MRCONSO where CUI='$concept' }; |
3097
|
0
|
|
|
|
|
|
my $sth = $db->prepare( $sql ); |
3098
|
0
|
|
|
|
|
|
$sth->execute(); |
3099
|
0
|
|
|
|
|
|
my($str, $sab); |
3100
|
0
|
|
|
|
|
|
$sth->bind_columns( undef, \$str, \$sab ); |
3101
|
0
|
|
|
|
|
|
while( $sth->fetch() ) { |
3102
|
0
|
|
|
|
|
|
$str =~ s/^\s+//; |
3103
|
0
|
|
|
|
|
|
$str =~ s/\s+$//; |
3104
|
0
|
|
|
|
|
|
$str =~ s/\s+/ /g; |
3105
|
0
|
|
|
|
|
|
$str = lc($str); |
3106
|
0
|
|
|
|
|
|
push @{$strhash{$str}}, $sab; |
|
0
|
|
|
|
|
|
|
3107
|
|
|
|
|
|
|
} |
3108
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
3109
|
0
|
|
|
|
|
|
$sth->finish(); |
3110
|
|
|
|
|
|
|
|
3111
|
|
|
|
|
|
|
# set the output |
3112
|
0
|
|
|
|
|
|
foreach my $str (sort keys %strhash) { |
3113
|
0
|
|
|
|
|
|
my $sabs = join ", ", @{$strhash{$str}}; |
|
0
|
|
|
|
|
|
|
3114
|
0
|
|
|
|
|
|
my $index = "$str - $sabs"; |
3115
|
0
|
|
|
|
|
|
$retHash{$index}++; |
3116
|
|
|
|
|
|
|
} |
3117
|
|
|
|
|
|
|
|
3118
|
0
|
|
|
|
|
|
my @array = keys(%retHash); |
3119
|
|
|
|
|
|
|
|
3120
|
0
|
|
|
|
|
|
return \@array; |
3121
|
|
|
|
|
|
|
} |
3122
|
|
|
|
|
|
|
|
3123
|
|
|
|
|
|
|
# method to map CUIs to a terms in the sources and the relations |
3124
|
|
|
|
|
|
|
# specified in the configuration file by SAB and REL |
3125
|
|
|
|
|
|
|
# input : $term <- string containing a term |
3126
|
|
|
|
|
|
|
# output: $array <- reference to an array containing cuis |
3127
|
|
|
|
|
|
|
sub _getConceptList { |
3128
|
|
|
|
|
|
|
|
3129
|
0
|
|
|
0
|
|
|
my $self = shift; |
3130
|
0
|
|
|
|
|
|
my $term = shift; |
3131
|
|
|
|
|
|
|
|
3132
|
0
|
|
|
|
|
|
my $function = "_getConceptList"; |
3133
|
0
|
|
|
|
|
|
&_debug($function); |
3134
|
|
|
|
|
|
|
|
3135
|
|
|
|
|
|
|
# check self |
3136
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3137
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3138
|
|
|
|
|
|
|
} |
3139
|
|
|
|
|
|
|
|
3140
|
|
|
|
|
|
|
# check parameter exists |
3141
|
0
|
0
|
|
|
|
|
if(!defined $term) { |
3142
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$term.", 4); |
3143
|
|
|
|
|
|
|
} |
3144
|
|
|
|
|
|
|
|
3145
|
|
|
|
|
|
|
# check that the ' are escaped if exist |
3146
|
0
|
|
|
|
|
|
$term=~s/\\?\'/\\\'/; |
3147
|
|
|
|
|
|
|
|
3148
|
|
|
|
|
|
|
# set up the database |
3149
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3150
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3151
|
|
|
|
|
|
|
|
3152
|
|
|
|
|
|
|
# get the cuis |
3153
|
0
|
|
|
|
|
|
my $arrRef = ""; |
3154
|
|
|
|
|
|
|
|
3155
|
0
|
0
|
|
|
|
|
if($umlsall) { |
|
|
0
|
|
|
|
|
|
3156
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where STR='$term'"); |
3157
|
|
|
|
|
|
|
} |
3158
|
|
|
|
|
|
|
elsif($sources ne "") { |
3159
|
|
|
|
|
|
|
|
3160
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where STR='$term' and ($sources)"); |
3161
|
|
|
|
|
|
|
} |
3162
|
|
|
|
|
|
|
else { |
3163
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with sources from configuration file.", 5); |
3164
|
|
|
|
|
|
|
} |
3165
|
|
|
|
|
|
|
# check for database errors |
3166
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3167
|
|
|
|
|
|
|
|
3168
|
0
|
|
|
|
|
|
return $arrRef; |
3169
|
|
|
|
|
|
|
} |
3170
|
|
|
|
|
|
|
|
3171
|
|
|
|
|
|
|
# method to map CUIs to a terms in the sources and the relations |
3172
|
|
|
|
|
|
|
# specified in the configuration file by SABDEF and RELDEF |
3173
|
|
|
|
|
|
|
# input : $term <- string containing a term |
3174
|
|
|
|
|
|
|
# output: $array <- reference to an array containing cuis |
3175
|
|
|
|
|
|
|
sub _getDefConceptList { |
3176
|
|
|
|
|
|
|
|
3177
|
0
|
|
|
0
|
|
|
my $self = shift; |
3178
|
0
|
|
|
|
|
|
my $term = shift; |
3179
|
|
|
|
|
|
|
|
3180
|
0
|
|
|
|
|
|
my $function = "_getDefConceptList"; |
3181
|
|
|
|
|
|
|
|
3182
|
|
|
|
|
|
|
# check self |
3183
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3184
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3185
|
|
|
|
|
|
|
} |
3186
|
|
|
|
|
|
|
|
3187
|
|
|
|
|
|
|
# check parameter exists |
3188
|
0
|
0
|
|
|
|
|
if(!defined $term) { |
3189
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$term.", 4); |
3190
|
|
|
|
|
|
|
} |
3191
|
|
|
|
|
|
|
|
3192
|
|
|
|
|
|
|
# check that the ' are escaped if exist |
3193
|
0
|
|
|
|
|
|
$term=~s/\\?\'/\\\'/; |
3194
|
|
|
|
|
|
|
|
3195
|
|
|
|
|
|
|
# set up the database |
3196
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3197
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3198
|
|
|
|
|
|
|
|
3199
|
|
|
|
|
|
|
# get the cuis |
3200
|
0
|
|
|
|
|
|
my $arrRef = ""; |
3201
|
|
|
|
|
|
|
|
3202
|
0
|
0
|
|
|
|
|
if($sabdef_umlsall) { |
|
|
0
|
|
|
|
|
|
3203
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where STR='$term'"); |
3204
|
|
|
|
|
|
|
} |
3205
|
|
|
|
|
|
|
elsif($sabdefsources ne "") { |
3206
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where STR='$term' and ($sabdefsources)"); |
3207
|
|
|
|
|
|
|
} |
3208
|
|
|
|
|
|
|
else { |
3209
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with sources from configuration file.", 5); |
3210
|
|
|
|
|
|
|
} |
3211
|
|
|
|
|
|
|
# check for database errors |
3212
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3213
|
|
|
|
|
|
|
|
3214
|
0
|
|
|
|
|
|
return $arrRef; |
3215
|
|
|
|
|
|
|
} |
3216
|
|
|
|
|
|
|
|
3217
|
|
|
|
|
|
|
# method to map CUIs to a terms using the CUIs in the |
3218
|
|
|
|
|
|
|
# entire UMLS not just the sources in the config file |
3219
|
|
|
|
|
|
|
# input : $term <- string containing a term |
3220
|
|
|
|
|
|
|
# output: $array <- reference to an array containing cuis |
3221
|
|
|
|
|
|
|
sub _getAllConcepts { |
3222
|
|
|
|
|
|
|
|
3223
|
0
|
|
|
0
|
|
|
my $self = shift; |
3224
|
0
|
|
|
|
|
|
my $term = shift; |
3225
|
|
|
|
|
|
|
|
3226
|
0
|
|
|
|
|
|
my $function = "_getAllConcepts"; |
3227
|
|
|
|
|
|
|
|
3228
|
|
|
|
|
|
|
# check self |
3229
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3230
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3231
|
|
|
|
|
|
|
} |
3232
|
|
|
|
|
|
|
|
3233
|
|
|
|
|
|
|
# check parameter exists |
3234
|
0
|
0
|
|
|
|
|
if(!defined $term) { |
3235
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$term.", 4); |
3236
|
|
|
|
|
|
|
} |
3237
|
|
|
|
|
|
|
|
3238
|
|
|
|
|
|
|
# check that the ' are escaped if exist |
3239
|
0
|
|
|
|
|
|
$term=~s/\\?\'/\\\'/; |
3240
|
|
|
|
|
|
|
|
3241
|
|
|
|
|
|
|
# set up the database |
3242
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3243
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3244
|
|
|
|
|
|
|
|
3245
|
|
|
|
|
|
|
# get the cuis |
3246
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct CUI from MRCONSO where STR='$term'"); |
3247
|
|
|
|
|
|
|
|
3248
|
|
|
|
|
|
|
# check for database errors |
3249
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3250
|
|
|
|
|
|
|
|
3251
|
0
|
|
|
|
|
|
return $arrRef; |
3252
|
|
|
|
|
|
|
} |
3253
|
|
|
|
|
|
|
|
3254
|
|
|
|
|
|
|
# method returns all the compounds in the sources |
3255
|
|
|
|
|
|
|
# specified in the configuration file |
3256
|
|
|
|
|
|
|
# input: |
3257
|
|
|
|
|
|
|
# output: $hash <- reference to a hash containing cuis |
3258
|
|
|
|
|
|
|
sub _getCompounds { |
3259
|
|
|
|
|
|
|
|
3260
|
0
|
|
|
0
|
|
|
my $self = shift; |
3261
|
|
|
|
|
|
|
|
3262
|
0
|
|
|
|
|
|
my $function = "_getCompounds"; |
3263
|
0
|
|
|
|
|
|
&_debug($function); |
3264
|
|
|
|
|
|
|
|
3265
|
|
|
|
|
|
|
# check self |
3266
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3267
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3268
|
|
|
|
|
|
|
} |
3269
|
|
|
|
|
|
|
|
3270
|
|
|
|
|
|
|
# set up the database |
3271
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3272
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3273
|
|
|
|
|
|
|
|
3274
|
|
|
|
|
|
|
# initialize return hash |
3275
|
0
|
|
|
|
|
|
my %compounds = (); |
3276
|
|
|
|
|
|
|
|
3277
|
|
|
|
|
|
|
# get strings in the MRCONSO table |
3278
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3279
|
|
|
|
|
|
|
# get all the terms from the MRCONSO table |
3280
|
0
|
|
|
|
|
|
my $strs = $db->selectcol_arrayref("select distinct STR from MRCONSO"); |
3281
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3282
|
|
|
|
|
|
|
|
3283
|
|
|
|
|
|
|
# loop through the terms and add the ones that have more than one word to the hash |
3284
|
0
|
|
|
|
|
|
foreach my $str (@{$strs}) { |
|
0
|
|
|
|
|
|
|
3285
|
0
|
|
|
|
|
|
my @array = split/\s+/, $str; |
3286
|
0
|
0
|
|
|
|
|
if($#array > 0) { |
3287
|
0
|
|
|
|
|
|
$compounds{$str} = 0; |
3288
|
|
|
|
|
|
|
} |
3289
|
|
|
|
|
|
|
} |
3290
|
|
|
|
|
|
|
} |
3291
|
|
|
|
|
|
|
else { |
3292
|
|
|
|
|
|
|
|
3293
|
|
|
|
|
|
|
# for each of the sabs in the configuratinon file get strings |
3294
|
0
|
|
|
|
|
|
foreach my $sab (sort keys %sabnamesHash) { |
3295
|
|
|
|
|
|
|
|
3296
|
|
|
|
|
|
|
# get the cuis for that sab |
3297
|
0
|
|
|
|
|
|
my $strs = $db->selectcol_arrayref("select distinct STR from MRCONSO where SAB=\'$sab\'"); |
3298
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3299
|
|
|
|
|
|
|
|
3300
|
|
|
|
|
|
|
# loop through the terms and add the ones that have more than one word to the hash |
3301
|
0
|
|
|
|
|
|
foreach my $str (@{$strs}) { |
|
0
|
|
|
|
|
|
|
3302
|
0
|
|
|
|
|
|
my @array = split/\s+/, $str; |
3303
|
0
|
0
|
|
|
|
|
if($#array > 0) { |
3304
|
0
|
|
|
|
|
|
$compounds{$str} = 0; |
3305
|
|
|
|
|
|
|
} |
3306
|
|
|
|
|
|
|
} |
3307
|
|
|
|
|
|
|
} |
3308
|
|
|
|
|
|
|
} |
3309
|
|
|
|
|
|
|
|
3310
|
0
|
|
|
|
|
|
return \%compounds; |
3311
|
|
|
|
|
|
|
} |
3312
|
|
|
|
|
|
|
|
3313
|
|
|
|
|
|
|
|
3314
|
|
|
|
|
|
|
# method returns all of the cuis in the sources |
3315
|
|
|
|
|
|
|
# specified in the configuration file |
3316
|
|
|
|
|
|
|
# input : |
3317
|
|
|
|
|
|
|
# output: $hash <- reference to a hash containing cuis |
3318
|
|
|
|
|
|
|
sub _getCuiList { |
3319
|
|
|
|
|
|
|
|
3320
|
0
|
|
|
0
|
|
|
my $self = shift; |
3321
|
|
|
|
|
|
|
|
3322
|
0
|
|
|
|
|
|
my $function = "_getCuiList"; |
3323
|
0
|
|
|
|
|
|
&_debug($function); |
3324
|
|
|
|
|
|
|
|
3325
|
|
|
|
|
|
|
# check self |
3326
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3327
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3328
|
|
|
|
|
|
|
} |
3329
|
|
|
|
|
|
|
|
3330
|
|
|
|
|
|
|
# if this has already been done just return the stored cuiListHash |
3331
|
0
|
|
|
|
|
|
my $elements = keys %cuiListHash; |
3332
|
0
|
0
|
|
|
|
|
if($elements > 0) { |
3333
|
0
|
|
|
|
|
|
return \%cuiListHash; |
3334
|
|
|
|
|
|
|
} |
3335
|
|
|
|
|
|
|
|
3336
|
|
|
|
|
|
|
# otherwise, set up the database |
3337
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3338
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3339
|
|
|
|
|
|
|
|
3340
|
|
|
|
|
|
|
# get the sabs in the config file |
3341
|
0
|
|
|
|
|
|
my @sabs = (); |
3342
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3343
|
0
|
|
|
|
|
|
my $s = $db->selectcol_arrayref("select distinct SAB from MRREL"); |
3344
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3345
|
0
|
|
|
|
|
|
@sabs = @{$s}; |
|
0
|
|
|
|
|
|
|
3346
|
|
|
|
|
|
|
} |
3347
|
|
|
|
|
|
|
else { |
3348
|
0
|
|
|
|
|
|
foreach my $sab (sort keys %sabnamesHash) { push @sabs, $sab; } |
|
0
|
|
|
|
|
|
|
3349
|
|
|
|
|
|
|
} |
3350
|
|
|
|
|
|
|
|
3351
|
|
|
|
|
|
|
# initialize the cui list hash |
3352
|
0
|
|
|
|
|
|
%cuiListHash = (); |
3353
|
|
|
|
|
|
|
|
3354
|
|
|
|
|
|
|
# for each of the sabs in the configuratino file |
3355
|
0
|
|
|
|
|
|
foreach my $sab (@sabs) { |
3356
|
|
|
|
|
|
|
|
3357
|
|
|
|
|
|
|
# get the cuis for that sab |
3358
|
0
|
|
|
|
|
|
my $cuis = $self->_getCuis($sab); |
3359
|
|
|
|
|
|
|
|
3360
|
|
|
|
|
|
|
# add the cuis to the hash |
3361
|
0
|
|
|
|
|
|
foreach my $cui (@{$cuis}) { $cuiListHash{$cui} = 0 }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3362
|
|
|
|
|
|
|
} |
3363
|
|
|
|
|
|
|
|
3364
|
|
|
|
|
|
|
# add upper level taxonomy |
3365
|
0
|
|
|
|
|
|
foreach my $cui (sort keys %parentTaxonomyArray) { $cuiListHash{$cui} = 0; } |
|
0
|
|
|
|
|
|
|
3366
|
0
|
|
|
|
|
|
foreach my $cui (sort keys %childTaxonomyArray) { $cuiListHash{$cui} = 0; } |
|
0
|
|
|
|
|
|
|
3367
|
|
|
|
|
|
|
|
3368
|
0
|
|
|
|
|
|
return \%cuiListHash; |
3369
|
|
|
|
|
|
|
} |
3370
|
|
|
|
|
|
|
|
3371
|
|
|
|
|
|
|
# returns the cuis from a specified source |
3372
|
|
|
|
|
|
|
# input : $sab <- string contain the sources abbreviation |
3373
|
|
|
|
|
|
|
# output: $array <- reference to an array containing cuis |
3374
|
|
|
|
|
|
|
sub _getCuisFromSource { |
3375
|
|
|
|
|
|
|
|
3376
|
0
|
|
|
0
|
|
|
my $self = shift; |
3377
|
0
|
|
|
|
|
|
my $sab = shift; |
3378
|
|
|
|
|
|
|
|
3379
|
0
|
|
|
|
|
|
my $function = "_getCuisFromSource"; |
3380
|
0
|
|
|
|
|
|
&_debug($function); |
3381
|
|
|
|
|
|
|
|
3382
|
|
|
|
|
|
|
# check self |
3383
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3384
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3385
|
|
|
|
|
|
|
} |
3386
|
|
|
|
|
|
|
|
3387
|
|
|
|
|
|
|
# get the cuis from the specified source |
3388
|
0
|
|
|
|
|
|
my $arrRef = $self->_getCuis($sab); |
3389
|
|
|
|
|
|
|
|
3390
|
0
|
|
|
|
|
|
return ($arrRef); |
3391
|
|
|
|
|
|
|
} |
3392
|
|
|
|
|
|
|
|
3393
|
|
|
|
|
|
|
# returns all of the sources specified that contain the given cui |
3394
|
|
|
|
|
|
|
# input : $concept <- string containing the cui |
3395
|
|
|
|
|
|
|
# output: $array <- reference to an array contain the sources (abbreviations) |
3396
|
|
|
|
|
|
|
sub _getSab { |
3397
|
|
|
|
|
|
|
|
3398
|
0
|
|
|
0
|
|
|
my $self = shift; |
3399
|
0
|
|
|
|
|
|
my $concept = shift; |
3400
|
|
|
|
|
|
|
|
3401
|
0
|
|
|
|
|
|
my $function = "_getSab"; |
3402
|
|
|
|
|
|
|
|
3403
|
|
|
|
|
|
|
# check self |
3404
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3405
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3406
|
|
|
|
|
|
|
} |
3407
|
|
|
|
|
|
|
|
3408
|
|
|
|
|
|
|
# check parameter exists |
3409
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3410
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3411
|
|
|
|
|
|
|
} |
3412
|
|
|
|
|
|
|
|
3413
|
|
|
|
|
|
|
# check if valid concept |
3414
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3415
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3416
|
|
|
|
|
|
|
} |
3417
|
|
|
|
|
|
|
|
3418
|
|
|
|
|
|
|
# connect to the database |
3419
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3420
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3421
|
|
|
|
|
|
|
|
3422
|
|
|
|
|
|
|
# select all the sources from the mrconso table |
3423
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct SAB from MRCONSO where CUI='$concept'"); |
3424
|
|
|
|
|
|
|
|
3425
|
|
|
|
|
|
|
# check the database for errors |
3426
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3427
|
|
|
|
|
|
|
|
3428
|
0
|
|
|
|
|
|
return $arrRef; |
3429
|
|
|
|
|
|
|
} |
3430
|
|
|
|
|
|
|
|
3431
|
|
|
|
|
|
|
# returns the child relations |
3432
|
|
|
|
|
|
|
# input : |
3433
|
|
|
|
|
|
|
# output: $string <- containing the child relations |
3434
|
|
|
|
|
|
|
sub _getChildRelations { |
3435
|
0
|
|
|
0
|
|
|
my $self = shift; |
3436
|
|
|
|
|
|
|
|
3437
|
0
|
|
|
|
|
|
return $childRelations; |
3438
|
|
|
|
|
|
|
} |
3439
|
|
|
|
|
|
|
# returns the parent relations |
3440
|
|
|
|
|
|
|
# input : |
3441
|
|
|
|
|
|
|
# output: $string <- containing the parent relations |
3442
|
|
|
|
|
|
|
sub _getParentRelations { |
3443
|
0
|
|
|
0
|
|
|
my $self = shift; |
3444
|
|
|
|
|
|
|
|
3445
|
0
|
|
|
|
|
|
return $parentRelations; |
3446
|
|
|
|
|
|
|
} |
3447
|
|
|
|
|
|
|
|
3448
|
|
|
|
|
|
|
|
3449
|
|
|
|
|
|
|
# returns the children of a concept - the relations that |
3450
|
|
|
|
|
|
|
# are considered children are predefined by the user. |
3451
|
|
|
|
|
|
|
# the default are the RN and CHD relations |
3452
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
3453
|
|
|
|
|
|
|
# output: $array <- reference to an array containing a list of cuis |
3454
|
|
|
|
|
|
|
sub _getChildren { |
3455
|
|
|
|
|
|
|
|
3456
|
0
|
|
|
0
|
|
|
my $self = shift; |
3457
|
0
|
|
|
|
|
|
my $concept = shift; |
3458
|
|
|
|
|
|
|
|
3459
|
0
|
|
|
|
|
|
my $function = "_getChildren"; |
3460
|
|
|
|
|
|
|
#&_debug($function); |
3461
|
|
|
|
|
|
|
|
3462
|
|
|
|
|
|
|
# check self |
3463
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3464
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3465
|
|
|
|
|
|
|
} |
3466
|
|
|
|
|
|
|
|
3467
|
|
|
|
|
|
|
# check parameter exists |
3468
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3469
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3470
|
|
|
|
|
|
|
} |
3471
|
|
|
|
|
|
|
|
3472
|
|
|
|
|
|
|
# check if valid concept |
3473
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3474
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3475
|
|
|
|
|
|
|
} |
3476
|
|
|
|
|
|
|
|
3477
|
|
|
|
|
|
|
# connect to the database |
3478
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3479
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3480
|
|
|
|
|
|
|
|
3481
|
|
|
|
|
|
|
# if the concept is the umls root node cui return |
3482
|
|
|
|
|
|
|
# the source's cuis |
3483
|
0
|
0
|
|
|
|
|
if($concept eq $umlsRoot) { |
3484
|
0
|
|
|
|
|
|
my @array = (keys %sabHash); |
3485
|
0
|
|
|
|
|
|
return \@array; |
3486
|
|
|
|
|
|
|
} |
3487
|
|
|
|
|
|
|
|
3488
|
|
|
|
|
|
|
# otherwise everything is normal so return its children |
3489
|
|
|
|
|
|
|
else { |
3490
|
0
|
|
|
|
|
|
my $arrRef = ""; |
3491
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3492
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and ($childRelations) and CUI2!='$concept' and SUPPRESS='N'"); |
3493
|
|
|
|
|
|
|
} |
3494
|
|
|
|
|
|
|
else { |
3495
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and ($childRelations) and ($sources) and CUI2!='$concept' and SUPPRESS='N'"); |
3496
|
|
|
|
|
|
|
} |
3497
|
|
|
|
|
|
|
|
3498
|
|
|
|
|
|
|
# check the database for errors |
3499
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3500
|
|
|
|
|
|
|
|
3501
|
|
|
|
|
|
|
# add the children in the upper taxonomy |
3502
|
0
|
|
|
|
|
|
my @array = (); |
3503
|
0
|
0
|
|
|
|
|
if(exists $childTaxonomyArray{$concept}) { |
3504
|
0
|
|
|
|
|
|
@array = (@{$childTaxonomyArray{$concept}}, @{$arrRef}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3505
|
|
|
|
|
|
|
} |
3506
|
|
|
|
|
|
|
else { |
3507
|
0
|
|
|
|
|
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
|
|
3508
|
|
|
|
|
|
|
} |
3509
|
0
|
|
|
|
|
|
return \@array; |
3510
|
|
|
|
|
|
|
} |
3511
|
|
|
|
|
|
|
} |
3512
|
|
|
|
|
|
|
|
3513
|
|
|
|
|
|
|
|
3514
|
|
|
|
|
|
|
# returns the parents of a concept - the relations that |
3515
|
|
|
|
|
|
|
# are considered parents are predefined by the user. |
3516
|
|
|
|
|
|
|
# the default are the PAR and RB relations. |
3517
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
3518
|
|
|
|
|
|
|
# outupt: $array <- reference to an array containing a list of cuis |
3519
|
|
|
|
|
|
|
sub _getParents { |
3520
|
|
|
|
|
|
|
|
3521
|
0
|
|
|
0
|
|
|
my $self = shift; |
3522
|
0
|
|
|
|
|
|
my $concept = shift; |
3523
|
|
|
|
|
|
|
|
3524
|
0
|
|
|
|
|
|
my $function = "_getParents"; |
3525
|
|
|
|
|
|
|
|
3526
|
|
|
|
|
|
|
# check self |
3527
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3528
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3529
|
|
|
|
|
|
|
} |
3530
|
|
|
|
|
|
|
|
3531
|
|
|
|
|
|
|
# check parameter exists |
3532
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3533
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3534
|
|
|
|
|
|
|
} |
3535
|
|
|
|
|
|
|
|
3536
|
|
|
|
|
|
|
# check if valid concept |
3537
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3538
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3539
|
|
|
|
|
|
|
} |
3540
|
|
|
|
|
|
|
|
3541
|
|
|
|
|
|
|
# connect to the database |
3542
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3543
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3544
|
|
|
|
|
|
|
|
3545
|
|
|
|
|
|
|
# if the cui is a root return an empty array |
3546
|
0
|
0
|
0
|
|
|
|
if($concept eq $umlsRoot) { |
|
|
0
|
|
|
|
|
|
3547
|
0
|
|
|
|
|
|
my @returnarray = (); |
3548
|
0
|
|
|
|
|
|
return \@returnarray; # empty array |
3549
|
|
|
|
|
|
|
} |
3550
|
|
|
|
|
|
|
# if the cui is a source cui but not a root return the umls root |
3551
|
|
|
|
|
|
|
elsif( (exists $sabHash{$concept}) and ($concept ne $umlsRoot)) { |
3552
|
0
|
|
|
|
|
|
my @returnarray = (); |
3553
|
0
|
|
|
|
|
|
push @returnarray, $umlsRoot; |
3554
|
0
|
|
|
|
|
|
return \@returnarray; |
3555
|
|
|
|
|
|
|
} |
3556
|
|
|
|
|
|
|
# otherwise everything is normal so return its parents |
3557
|
|
|
|
|
|
|
else { |
3558
|
0
|
|
|
|
|
|
my $arrRef = ""; |
3559
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3560
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and ($parentRelations) and CUI2!='$concept' and SUPPRESS='N'"); |
3561
|
|
|
|
|
|
|
} |
3562
|
|
|
|
|
|
|
else { |
3563
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and ($parentRelations) and ($sources) and CUI2!='$concept' and SUPPRESS='N'"); |
3564
|
|
|
|
|
|
|
} |
3565
|
|
|
|
|
|
|
|
3566
|
|
|
|
|
|
|
# check the database for errors |
3567
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3568
|
|
|
|
|
|
|
|
3569
|
|
|
|
|
|
|
# add the parents in the upper taxonomy |
3570
|
0
|
|
|
|
|
|
my @array = (); |
3571
|
0
|
0
|
|
|
|
|
if(exists $parentTaxonomyArray{$concept}) { |
3572
|
0
|
|
|
|
|
|
@array = (@{$parentTaxonomyArray{$concept}}, @{$arrRef}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3573
|
|
|
|
|
|
|
} |
3574
|
|
|
|
|
|
|
else { |
3575
|
0
|
|
|
|
|
|
@array = @{$arrRef}; |
|
0
|
|
|
|
|
|
|
3576
|
|
|
|
|
|
|
} |
3577
|
0
|
|
|
|
|
|
return \@array; |
3578
|
|
|
|
|
|
|
} |
3579
|
|
|
|
|
|
|
} |
3580
|
|
|
|
|
|
|
|
3581
|
|
|
|
|
|
|
# returns the relations of a concept given a specified source |
3582
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
3583
|
|
|
|
|
|
|
# output: $array <- reference to an array containing strings of relations |
3584
|
|
|
|
|
|
|
sub _getRelations { |
3585
|
|
|
|
|
|
|
|
3586
|
0
|
|
|
0
|
|
|
my $self = shift; |
3587
|
0
|
|
|
|
|
|
my $concept = shift; |
3588
|
|
|
|
|
|
|
|
3589
|
0
|
|
|
|
|
|
my $function = "_getRelations"; |
3590
|
0
|
|
|
|
|
|
&_debug($function); |
3591
|
|
|
|
|
|
|
|
3592
|
|
|
|
|
|
|
# check self |
3593
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3594
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3595
|
|
|
|
|
|
|
} |
3596
|
|
|
|
|
|
|
|
3597
|
|
|
|
|
|
|
# check parameter exists |
3598
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3599
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3600
|
|
|
|
|
|
|
} |
3601
|
|
|
|
|
|
|
|
3602
|
|
|
|
|
|
|
# check if valid concept |
3603
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3604
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3605
|
|
|
|
|
|
|
} |
3606
|
|
|
|
|
|
|
|
3607
|
|
|
|
|
|
|
# connect to the database |
3608
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3609
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3610
|
|
|
|
|
|
|
|
3611
|
|
|
|
|
|
|
# get the relations |
3612
|
0
|
|
|
|
|
|
my $arrRef = ""; |
3613
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3614
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct REL from MRREL where (CUI1='$concept' or CUI2='$concept') and CUI1!=CUI2"); |
3615
|
|
|
|
|
|
|
} |
3616
|
|
|
|
|
|
|
else { |
3617
|
0
|
|
|
|
|
|
$arrRef = $db->selectcol_arrayref("select distinct REL from MRREL where (CUI1='$concept' or CUI2='$concept') and ($sources) and CUI1!=CUI2"); |
3618
|
|
|
|
|
|
|
} |
3619
|
|
|
|
|
|
|
|
3620
|
|
|
|
|
|
|
# check the database for errors |
3621
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3622
|
|
|
|
|
|
|
|
3623
|
0
|
|
|
|
|
|
return $arrRef; |
3624
|
|
|
|
|
|
|
} |
3625
|
|
|
|
|
|
|
|
3626
|
|
|
|
|
|
|
# returns the relations and its source between two concepts |
3627
|
|
|
|
|
|
|
# input : $concept1 <- string containing a cui |
3628
|
|
|
|
|
|
|
# : $concept2 <- string containing a cui |
3629
|
|
|
|
|
|
|
# output: $array <- reference to an array containing the relations |
3630
|
|
|
|
|
|
|
sub _getRelationsBetweenCuis { |
3631
|
|
|
|
|
|
|
|
3632
|
0
|
|
|
0
|
|
|
my $self = shift; |
3633
|
0
|
|
|
|
|
|
my $concept1 = shift; |
3634
|
0
|
|
|
|
|
|
my $concept2 = shift; |
3635
|
|
|
|
|
|
|
|
3636
|
0
|
|
|
|
|
|
my $function = "_getRelationBetweenCuis"; |
3637
|
0
|
|
|
|
|
|
&_debug($function); |
3638
|
|
|
|
|
|
|
|
3639
|
|
|
|
|
|
|
# check self |
3640
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3641
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3642
|
|
|
|
|
|
|
} |
3643
|
|
|
|
|
|
|
|
3644
|
|
|
|
|
|
|
# check parameter exists |
3645
|
0
|
0
|
|
|
|
|
if(!defined $concept1) { |
3646
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept1.", 4); |
3647
|
|
|
|
|
|
|
} |
3648
|
0
|
0
|
|
|
|
|
if(!defined $concept2) { |
3649
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept2.", 4); |
3650
|
|
|
|
|
|
|
} |
3651
|
|
|
|
|
|
|
|
3652
|
|
|
|
|
|
|
# check if valid concept |
3653
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept1)) ) { |
3654
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept1) is not valid.", 6); |
3655
|
|
|
|
|
|
|
} |
3656
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept2)) ) { |
3657
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept2) is not valid.", 6); |
3658
|
|
|
|
|
|
|
} |
3659
|
|
|
|
|
|
|
# connect to the database |
3660
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3661
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3662
|
|
|
|
|
|
|
|
3663
|
0
|
|
|
|
|
|
my @array = (); |
3664
|
|
|
|
|
|
|
|
3665
|
0
|
0
|
|
|
|
|
if($concept1 eq $umlsRoot) { |
3666
|
0
|
|
|
|
|
|
push @array, "CHD (source)"; |
3667
|
0
|
|
|
|
|
|
return \@array; |
3668
|
|
|
|
|
|
|
} |
3669
|
|
|
|
|
|
|
|
3670
|
|
|
|
|
|
|
# get the relations |
3671
|
0
|
|
|
|
|
|
my $sql = ""; |
3672
|
0
|
0
|
|
|
|
|
if($umlsall) { |
3673
|
0
|
|
|
|
|
|
$sql = qq{ select distinct REL, SAB from MRREL where (CUI1='$concept1' and CUI2='$concept2') and ($relations)}; |
3674
|
|
|
|
|
|
|
} |
3675
|
|
|
|
|
|
|
else { |
3676
|
0
|
|
|
|
|
|
$sql = qq{ select distinct REL, SAB from MRREL where (CUI1='$concept1' and CUI2='$concept2') and ($sources) and ($relations)}; |
3677
|
|
|
|
|
|
|
} |
3678
|
|
|
|
|
|
|
|
3679
|
0
|
|
|
|
|
|
my $sth = $db->prepare( $sql ); |
3680
|
0
|
|
|
|
|
|
$sth->execute(); |
3681
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
3682
|
|
|
|
|
|
|
|
3683
|
0
|
|
|
|
|
|
my($rel, $sab); |
3684
|
0
|
|
|
|
|
|
$sth->bind_columns( undef, \$rel, \$sab ); |
3685
|
0
|
|
|
|
|
|
while( $sth->fetch() ) { |
3686
|
0
|
|
|
|
|
|
my $str = "$rel ($sab)"; |
3687
|
0
|
|
|
|
|
|
push @array, $str; |
3688
|
0
|
|
|
|
|
|
} $sth->finish(); |
3689
|
|
|
|
|
|
|
|
3690
|
0
|
|
|
|
|
|
return \@array; |
3691
|
|
|
|
|
|
|
} |
3692
|
|
|
|
|
|
|
|
3693
|
|
|
|
|
|
|
# checks to see a concept is forbidden |
3694
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
3695
|
|
|
|
|
|
|
# output: $string <- integer indicating true or false |
3696
|
|
|
|
|
|
|
sub _forbiddenConcept { |
3697
|
|
|
|
|
|
|
|
3698
|
0
|
|
|
0
|
|
|
my $self = shift; |
3699
|
0
|
|
|
|
|
|
my $concept = shift; |
3700
|
|
|
|
|
|
|
|
3701
|
0
|
|
|
|
|
|
my $function = "_forbiddenConcept"; |
3702
|
|
|
|
|
|
|
|
3703
|
|
|
|
|
|
|
# check self |
3704
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3705
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3706
|
|
|
|
|
|
|
} |
3707
|
|
|
|
|
|
|
|
3708
|
|
|
|
|
|
|
# check parameter exists |
3709
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3710
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3711
|
|
|
|
|
|
|
} |
3712
|
|
|
|
|
|
|
|
3713
|
|
|
|
|
|
|
# check if valid concept |
3714
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3715
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3716
|
|
|
|
|
|
|
} |
3717
|
|
|
|
|
|
|
|
3718
|
|
|
|
|
|
|
# if concept is one of the following just return |
3719
|
|
|
|
|
|
|
#C1274012|Ambiguous concept (inactive concept) |
3720
|
0
|
0
|
|
|
|
|
if($concept=~/C1274012/) { return 1; } |
|
0
|
|
|
|
|
|
|
3721
|
|
|
|
|
|
|
#C1274013|Duplicate concept (inactive concept) |
3722
|
0
|
0
|
|
|
|
|
if($concept=~/C1274013/) { return 1; } |
|
0
|
|
|
|
|
|
|
3723
|
|
|
|
|
|
|
#C1276325|Reason not stated concept (inactive concept) |
3724
|
0
|
0
|
|
|
|
|
if($concept=~/C1276325/) { return 1; } |
|
0
|
|
|
|
|
|
|
3725
|
|
|
|
|
|
|
#C1274014|Outdated concept (inactive concept) |
3726
|
0
|
0
|
|
|
|
|
if($concept=~/C1274014/) { return 1; } |
|
0
|
|
|
|
|
|
|
3727
|
|
|
|
|
|
|
#C1274015|Erroneous concept (inactive concept) |
3728
|
0
|
0
|
|
|
|
|
if($concept=~/C1274015/) { return 1; } |
|
0
|
|
|
|
|
|
|
3729
|
|
|
|
|
|
|
#C1274021|Moved elsewhere (inactive concept) |
3730
|
0
|
0
|
|
|
|
|
if($concept=~/C1274021/) { return 1; } |
|
0
|
|
|
|
|
|
|
3731
|
|
|
|
|
|
|
#C1443286|unapproved attribute |
3732
|
0
|
0
|
|
|
|
|
if($concept=~/C1443286/) { return 1; } |
|
0
|
|
|
|
|
|
|
3733
|
|
|
|
|
|
|
#C1274012|non-current concept - ambiguous |
3734
|
0
|
0
|
|
|
|
|
if($concept=~/C1274012/) { return 1; } |
|
0
|
|
|
|
|
|
|
3735
|
|
|
|
|
|
|
#C2733115|limited status concept |
3736
|
0
|
0
|
|
|
|
|
if($concept=~/C2733115/) { return 1; } |
|
0
|
|
|
|
|
|
|
3737
|
|
|
|
|
|
|
|
3738
|
0
|
|
|
|
|
|
return 0; |
3739
|
|
|
|
|
|
|
} |
3740
|
|
|
|
|
|
|
|
3741
|
|
|
|
|
|
|
# Subroutine to get the semantic type's tui of a concept |
3742
|
|
|
|
|
|
|
# input : $cui <- string containing a concept |
3743
|
|
|
|
|
|
|
# output: $array <- reference to an array containing the semantic |
3744
|
|
|
|
|
|
|
# type's TUIs associated with the concept |
3745
|
|
|
|
|
|
|
sub _getSt { |
3746
|
|
|
|
|
|
|
|
3747
|
0
|
|
|
0
|
|
|
my $self = shift; |
3748
|
0
|
|
|
|
|
|
my $concept = shift; |
3749
|
|
|
|
|
|
|
|
3750
|
0
|
|
|
|
|
|
my $function = "_getSt"; |
3751
|
0
|
|
|
|
|
|
&_debug($function); |
3752
|
|
|
|
|
|
|
|
3753
|
|
|
|
|
|
|
# check self |
3754
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3755
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3756
|
|
|
|
|
|
|
} |
3757
|
|
|
|
|
|
|
|
3758
|
|
|
|
|
|
|
# check parameter exists |
3759
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
3760
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
3761
|
|
|
|
|
|
|
} |
3762
|
|
|
|
|
|
|
|
3763
|
|
|
|
|
|
|
# check if valid concept |
3764
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
3765
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
3766
|
|
|
|
|
|
|
} |
3767
|
|
|
|
|
|
|
|
3768
|
|
|
|
|
|
|
# set the database |
3769
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3770
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3771
|
|
|
|
|
|
|
|
3772
|
|
|
|
|
|
|
# get the TUI |
3773
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select TUI from MRSTY where CUI=\'$concept\'"); |
3774
|
|
|
|
|
|
|
|
3775
|
|
|
|
|
|
|
# check for database errors |
3776
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3777
|
|
|
|
|
|
|
|
3778
|
0
|
|
|
|
|
|
return $arrRef; |
3779
|
|
|
|
|
|
|
} |
3780
|
|
|
|
|
|
|
|
3781
|
|
|
|
|
|
|
# Subroutine to get the semantic type's tui of a semantic group |
3782
|
|
|
|
|
|
|
# input : $sg <- string containing a semantic group |
3783
|
|
|
|
|
|
|
# output: $array <- reference to an array containing the semantic |
3784
|
|
|
|
|
|
|
# type's TUIs associated with the concept |
3785
|
|
|
|
|
|
|
sub _getStsFromSg { |
3786
|
|
|
|
|
|
|
|
3787
|
0
|
|
|
0
|
|
|
my $self = shift; |
3788
|
0
|
|
|
|
|
|
my $sg = shift; |
3789
|
|
|
|
|
|
|
|
3790
|
0
|
|
|
|
|
|
my $function = "_getSt"; |
3791
|
0
|
|
|
|
|
|
&_debug($function); |
3792
|
|
|
|
|
|
|
|
3793
|
|
|
|
|
|
|
# check self |
3794
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3795
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3796
|
|
|
|
|
|
|
} |
3797
|
|
|
|
|
|
|
|
3798
|
|
|
|
|
|
|
# set the database |
3799
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3800
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3801
|
|
|
|
|
|
|
|
3802
|
|
|
|
|
|
|
|
3803
|
0
|
|
|
|
|
|
my $string = ""; |
3804
|
0
|
0
|
|
|
|
|
if(exists $sgConversion{$sg}) { |
3805
|
0
|
|
|
|
|
|
$string = $sgConversion{$sg}; |
3806
|
|
|
|
|
|
|
} |
3807
|
|
|
|
|
|
|
else { |
3808
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Semantic Group ($sg) is not valid.", 6); |
3809
|
|
|
|
|
|
|
} |
3810
|
|
|
|
|
|
|
|
3811
|
0
|
|
|
|
|
|
my @sts = (); |
3812
|
0
|
|
|
|
|
|
foreach my $st (sort keys %semanticGroups) { |
3813
|
0
|
|
|
|
|
|
foreach my $group (@{$semanticGroups{$st}}) { |
|
0
|
|
|
|
|
|
|
3814
|
0
|
0
|
|
|
|
|
if($string eq $group) { |
3815
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select ABR from SRDEF where STY_RL=\'$st\'"); |
3816
|
0
|
|
|
|
|
|
my $el = shift @{$arrRef}; |
|
0
|
|
|
|
|
|
|
3817
|
0
|
|
|
|
|
|
push @sts, $el; |
3818
|
|
|
|
|
|
|
} |
3819
|
|
|
|
|
|
|
} |
3820
|
|
|
|
|
|
|
} |
3821
|
|
|
|
|
|
|
|
3822
|
0
|
|
|
|
|
|
return \@sts; |
3823
|
|
|
|
|
|
|
} |
3824
|
|
|
|
|
|
|
|
3825
|
|
|
|
|
|
|
|
3826
|
|
|
|
|
|
|
# Subroutine to get the semantic type's tui of a concept |
3827
|
|
|
|
|
|
|
# input : |
3828
|
|
|
|
|
|
|
# output: $array <- reference to an array containing all the semantic |
3829
|
|
|
|
|
|
|
# type's TUIs |
3830
|
|
|
|
|
|
|
sub _getAllSts { |
3831
|
|
|
|
|
|
|
|
3832
|
0
|
|
|
0
|
|
|
my $self = shift; |
3833
|
|
|
|
|
|
|
|
3834
|
0
|
|
|
|
|
|
my $function = "_getAllSt"; |
3835
|
0
|
|
|
|
|
|
&_debug($function); |
3836
|
|
|
|
|
|
|
|
3837
|
|
|
|
|
|
|
# check self |
3838
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3839
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3840
|
|
|
|
|
|
|
} |
3841
|
|
|
|
|
|
|
|
3842
|
|
|
|
|
|
|
# set the database |
3843
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3844
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3845
|
|
|
|
|
|
|
|
3846
|
|
|
|
|
|
|
# get the TUI |
3847
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct(TUI) from MRSTY"); |
3848
|
|
|
|
|
|
|
|
3849
|
|
|
|
|
|
|
# check for database errors |
3850
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3851
|
|
|
|
|
|
|
|
3852
|
0
|
|
|
|
|
|
return $arrRef; |
3853
|
|
|
|
|
|
|
} |
3854
|
|
|
|
|
|
|
|
3855
|
|
|
|
|
|
|
# subroutine to get the relation(s) between two semantic types |
3856
|
|
|
|
|
|
|
# input : $st1 <- semantic type abbreviation |
3857
|
|
|
|
|
|
|
# $st2 <- semantic type abbreviation |
3858
|
|
|
|
|
|
|
# output: $array <- reference to an array of semantic relation(s) |
3859
|
|
|
|
|
|
|
sub _getSemanticRelation { |
3860
|
|
|
|
|
|
|
|
3861
|
0
|
|
|
0
|
|
|
my $self = shift; |
3862
|
0
|
|
|
|
|
|
my $st1 = shift; |
3863
|
0
|
|
|
|
|
|
my $st2 = shift; |
3864
|
|
|
|
|
|
|
|
3865
|
0
|
|
|
|
|
|
my $function = "_getSemanticRelation"; |
3866
|
0
|
|
|
|
|
|
&_debug($function); |
3867
|
|
|
|
|
|
|
|
3868
|
|
|
|
|
|
|
# check self |
3869
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3870
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3871
|
|
|
|
|
|
|
} |
3872
|
|
|
|
|
|
|
|
3873
|
|
|
|
|
|
|
# check input |
3874
|
0
|
0
|
|
|
|
|
if(!defined $st1) { |
3875
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$st1.", 4); |
3876
|
|
|
|
|
|
|
} |
3877
|
0
|
0
|
|
|
|
|
if(!defined $st2) { |
3878
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$st2.", 4); |
3879
|
|
|
|
|
|
|
} |
3880
|
|
|
|
|
|
|
|
3881
|
|
|
|
|
|
|
# set the database |
3882
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3883
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3884
|
|
|
|
|
|
|
|
3885
|
0
|
|
|
|
|
|
my $string1 = $self->_getStString($st1); |
3886
|
0
|
|
|
|
|
|
my $string2 = $self->_getStString($st2); |
3887
|
|
|
|
|
|
|
|
3888
|
|
|
|
|
|
|
# get the string associated with the semantic type |
3889
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct RL from SRSTR where STY_RL1=\'$string1\' and STY_RL2=\'$string2\'"); |
3890
|
|
|
|
|
|
|
|
3891
|
|
|
|
|
|
|
# check database errors |
3892
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3893
|
|
|
|
|
|
|
|
3894
|
0
|
|
|
|
|
|
my @rarray = shift @{$arrRef}; |
|
0
|
|
|
|
|
|
|
3895
|
0
|
|
|
|
|
|
return \@rarray;; |
3896
|
|
|
|
|
|
|
} |
3897
|
|
|
|
|
|
|
|
3898
|
|
|
|
|
|
|
# subroutine to get the name of a semantic type given its abbreviation |
3899
|
|
|
|
|
|
|
# input : $st <- string containing the abbreviation of the semantic type |
3900
|
|
|
|
|
|
|
# output: $string <- string containing the full name of the semantic type |
3901
|
|
|
|
|
|
|
sub _getStString { |
3902
|
|
|
|
|
|
|
|
3903
|
0
|
|
|
0
|
|
|
my $self = shift; |
3904
|
0
|
|
|
|
|
|
my $st = shift; |
3905
|
|
|
|
|
|
|
|
3906
|
0
|
|
|
|
|
|
my $function = "_getStString"; |
3907
|
0
|
|
|
|
|
|
&_debug($function); |
3908
|
|
|
|
|
|
|
|
3909
|
|
|
|
|
|
|
# check self |
3910
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3911
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3912
|
|
|
|
|
|
|
} |
3913
|
|
|
|
|
|
|
|
3914
|
|
|
|
|
|
|
# check parameter exists |
3915
|
0
|
0
|
|
|
|
|
if(!defined $st) { |
3916
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$st.", 4); |
3917
|
|
|
|
|
|
|
} |
3918
|
|
|
|
|
|
|
|
3919
|
|
|
|
|
|
|
# set the database |
3920
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3921
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3922
|
|
|
|
|
|
|
|
3923
|
|
|
|
|
|
|
# get the string associated with the semantic type |
3924
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select STY_RL from SRDEF where ABR=\'$st\'"); |
3925
|
|
|
|
|
|
|
|
3926
|
|
|
|
|
|
|
# check database errors |
3927
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3928
|
|
|
|
|
|
|
|
3929
|
0
|
|
|
|
|
|
return (shift @{$arrRef}); |
|
0
|
|
|
|
|
|
|
3930
|
|
|
|
|
|
|
} |
3931
|
|
|
|
|
|
|
|
3932
|
|
|
|
|
|
|
|
3933
|
|
|
|
|
|
|
# subroutine to get the name of a semantic type given its TUI (UI) |
3934
|
|
|
|
|
|
|
# input : $tui <- string containing the semantic type's TUI |
3935
|
|
|
|
|
|
|
# output: $string <- string containing the semantic type's abbreviation |
3936
|
|
|
|
|
|
|
sub _getStAbr { |
3937
|
|
|
|
|
|
|
|
3938
|
0
|
|
|
0
|
|
|
my $self = shift; |
3939
|
0
|
|
|
|
|
|
my $tui = shift; |
3940
|
|
|
|
|
|
|
|
3941
|
0
|
|
|
|
|
|
my $function = "_getStAbr"; |
3942
|
0
|
|
|
|
|
|
&_debug($function); |
3943
|
|
|
|
|
|
|
|
3944
|
|
|
|
|
|
|
# check self |
3945
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3946
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3947
|
|
|
|
|
|
|
} |
3948
|
|
|
|
|
|
|
|
3949
|
|
|
|
|
|
|
# check parameter exists |
3950
|
0
|
0
|
|
|
|
|
if(!defined $tui) { |
3951
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$tui.", 4); |
3952
|
|
|
|
|
|
|
} |
3953
|
|
|
|
|
|
|
|
3954
|
|
|
|
|
|
|
# if tui is the root return ROOT |
3955
|
0
|
0
|
|
|
|
|
if($tui eq "T000") { |
3956
|
0
|
|
|
|
|
|
return "ST ROOT"; |
3957
|
|
|
|
|
|
|
} |
3958
|
|
|
|
|
|
|
|
3959
|
|
|
|
|
|
|
# set the database |
3960
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3961
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3962
|
|
|
|
|
|
|
|
3963
|
|
|
|
|
|
|
# obtain the abbreviation |
3964
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select ABR from SRDEF where UI=\'$tui\'"); |
3965
|
|
|
|
|
|
|
|
3966
|
|
|
|
|
|
|
# check database errors |
3967
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
3968
|
|
|
|
|
|
|
|
3969
|
0
|
|
|
|
|
|
return (shift @{$arrRef}); |
|
0
|
|
|
|
|
|
|
3970
|
|
|
|
|
|
|
} |
3971
|
|
|
|
|
|
|
|
3972
|
|
|
|
|
|
|
|
3973
|
|
|
|
|
|
|
# subroutine to get the name of a semantic type's TUI given its abbrevation |
3974
|
|
|
|
|
|
|
# input : $string <- string containing the semantic type's abbreviation |
3975
|
|
|
|
|
|
|
# output: $tui <- string containing the semantic type's TUI |
3976
|
|
|
|
|
|
|
sub _getStTui { |
3977
|
|
|
|
|
|
|
|
3978
|
0
|
|
|
0
|
|
|
my $self = shift; |
3979
|
0
|
|
|
|
|
|
my $abbrev = shift; |
3980
|
|
|
|
|
|
|
|
3981
|
0
|
|
|
|
|
|
my $function = "_getStTui"; |
3982
|
0
|
|
|
|
|
|
&_debug($function); |
3983
|
|
|
|
|
|
|
|
3984
|
|
|
|
|
|
|
# check self |
3985
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
3986
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
3987
|
|
|
|
|
|
|
} |
3988
|
|
|
|
|
|
|
|
3989
|
|
|
|
|
|
|
# check parameter exists |
3990
|
0
|
0
|
|
|
|
|
if(!defined $abbrev) { |
3991
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$abbrev.", 4); |
3992
|
|
|
|
|
|
|
} |
3993
|
|
|
|
|
|
|
|
3994
|
|
|
|
|
|
|
# set the database |
3995
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
3996
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
3997
|
|
|
|
|
|
|
|
3998
|
|
|
|
|
|
|
# obtain the abbreviation |
3999
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select UI from SRDEF where ABR=\'$abbrev\'"); |
4000
|
|
|
|
|
|
|
|
4001
|
|
|
|
|
|
|
# check database errors |
4002
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
4003
|
|
|
|
|
|
|
|
4004
|
0
|
|
|
|
|
|
return (shift @{$arrRef}); |
|
0
|
|
|
|
|
|
|
4005
|
|
|
|
|
|
|
} |
4006
|
|
|
|
|
|
|
|
4007
|
|
|
|
|
|
|
|
4008
|
|
|
|
|
|
|
# subroutine to get the definition of a given TUI |
4009
|
|
|
|
|
|
|
# input : $st <- string containing the semantic type's abbreviation |
4010
|
|
|
|
|
|
|
# output: $string <- string containing the semantic type's definition |
4011
|
|
|
|
|
|
|
sub _getStDef { |
4012
|
|
|
|
|
|
|
|
4013
|
0
|
|
|
0
|
|
|
my $self = shift; |
4014
|
0
|
|
|
|
|
|
my $st = shift; |
4015
|
|
|
|
|
|
|
|
4016
|
0
|
|
|
|
|
|
my $function = "_getStDef"; |
4017
|
0
|
|
|
|
|
|
&_debug($function); |
4018
|
|
|
|
|
|
|
|
4019
|
|
|
|
|
|
|
# check self |
4020
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4021
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4022
|
|
|
|
|
|
|
} |
4023
|
|
|
|
|
|
|
|
4024
|
|
|
|
|
|
|
# check parameter exists |
4025
|
0
|
0
|
|
|
|
|
if(!defined $st) { |
4026
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$st.", 4); |
4027
|
|
|
|
|
|
|
} |
4028
|
|
|
|
|
|
|
|
4029
|
|
|
|
|
|
|
# set the database |
4030
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
4031
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
4032
|
|
|
|
|
|
|
|
4033
|
|
|
|
|
|
|
# get the definition |
4034
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select DEF from SRDEF where ABR=\'$st\'"); |
4035
|
|
|
|
|
|
|
|
4036
|
|
|
|
|
|
|
# check database errors |
4037
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
4038
|
|
|
|
|
|
|
|
4039
|
0
|
|
|
|
|
|
return $arrRef; |
4040
|
|
|
|
|
|
|
} |
4041
|
|
|
|
|
|
|
|
4042
|
|
|
|
|
|
|
# method returns the semantic group(s) associated with the concept |
4043
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
4044
|
|
|
|
|
|
|
# output: $array <- reference to an array containing semantic groups |
4045
|
|
|
|
|
|
|
sub _getSemanticGroup { |
4046
|
0
|
|
|
0
|
|
|
my $self = shift; |
4047
|
0
|
|
|
|
|
|
my $concept = shift; |
4048
|
|
|
|
|
|
|
|
4049
|
0
|
|
|
|
|
|
my $function = "_getSemanticGroup"; |
4050
|
0
|
|
|
|
|
|
&_debug($function); |
4051
|
|
|
|
|
|
|
|
4052
|
|
|
|
|
|
|
# check self |
4053
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4054
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4055
|
|
|
|
|
|
|
} |
4056
|
|
|
|
|
|
|
|
4057
|
|
|
|
|
|
|
# check parameter exists |
4058
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4059
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4060
|
|
|
|
|
|
|
} |
4061
|
|
|
|
|
|
|
|
4062
|
0
|
|
|
|
|
|
my $sts = $self->_getSt($concept); |
4063
|
|
|
|
|
|
|
|
4064
|
0
|
|
|
|
|
|
my %groups = (); |
4065
|
0
|
|
|
|
|
|
foreach my $st (@{$sts}) { |
|
0
|
|
|
|
|
|
|
4066
|
0
|
|
|
|
|
|
my $abr = $self->_getStAbr($st); |
4067
|
0
|
|
|
|
|
|
my $string = $self->_getStString($abr); |
4068
|
0
|
|
|
|
|
|
foreach my $group (@{$semanticGroups{$string}}) { |
|
0
|
|
|
|
|
|
|
4069
|
0
|
|
|
|
|
|
$groups{$group}++; |
4070
|
|
|
|
|
|
|
} |
4071
|
|
|
|
|
|
|
} |
4072
|
|
|
|
|
|
|
|
4073
|
0
|
|
|
|
|
|
my @array = (); |
4074
|
0
|
|
|
|
|
|
foreach my $group (sort keys %groups) { |
4075
|
0
|
|
|
|
|
|
push @array, $group; |
4076
|
|
|
|
|
|
|
} |
4077
|
|
|
|
|
|
|
|
4078
|
0
|
|
|
|
|
|
return \@array; |
4079
|
|
|
|
|
|
|
} |
4080
|
|
|
|
|
|
|
|
4081
|
|
|
|
|
|
|
# method returns the semantic groups |
4082
|
|
|
|
|
|
|
# input : |
4083
|
|
|
|
|
|
|
# output: $array <- reference to an array containing semantic groups |
4084
|
|
|
|
|
|
|
sub _getAllSemanticGroups { |
4085
|
0
|
|
|
0
|
|
|
my $self = shift; |
4086
|
|
|
|
|
|
|
|
4087
|
0
|
|
|
|
|
|
my $function = "_getSemanticGroup"; |
4088
|
0
|
|
|
|
|
|
&_debug($function); |
4089
|
|
|
|
|
|
|
|
4090
|
|
|
|
|
|
|
# check self |
4091
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4092
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4093
|
|
|
|
|
|
|
} |
4094
|
|
|
|
|
|
|
|
4095
|
0
|
|
|
|
|
|
my %groups = (); |
4096
|
0
|
|
|
|
|
|
foreach my $st (sort keys %semanticGroups) { |
4097
|
0
|
|
|
|
|
|
foreach my $group (@{$semanticGroups{$st}}) { |
|
0
|
|
|
|
|
|
|
4098
|
0
|
|
|
|
|
|
$groups{$group}++; |
4099
|
|
|
|
|
|
|
} |
4100
|
|
|
|
|
|
|
} |
4101
|
|
|
|
|
|
|
|
4102
|
0
|
|
|
|
|
|
my @array = (); |
4103
|
0
|
|
|
|
|
|
foreach my $group (sort keys %groups) { |
4104
|
0
|
|
|
|
|
|
my $code = $sgConversion1{$group}; |
4105
|
0
|
|
|
|
|
|
push @array, $code; |
4106
|
|
|
|
|
|
|
} |
4107
|
|
|
|
|
|
|
|
4108
|
0
|
|
|
|
|
|
return \@array; |
4109
|
|
|
|
|
|
|
} |
4110
|
|
|
|
|
|
|
|
4111
|
|
|
|
|
|
|
# method returns the semantic group(s) associated with a semantic type |
4112
|
|
|
|
|
|
|
# input : $st <- string containing a st |
4113
|
|
|
|
|
|
|
# output: $array <- reference to an array containing semantic groups |
4114
|
|
|
|
|
|
|
sub _stGetSemanticGroup { |
4115
|
0
|
|
|
0
|
|
|
my $self = shift; |
4116
|
0
|
|
|
|
|
|
my $st = shift; |
4117
|
|
|
|
|
|
|
|
4118
|
0
|
|
|
|
|
|
my $function = "_stGetSemanticGroup"; |
4119
|
0
|
|
|
|
|
|
&_debug($function); |
4120
|
|
|
|
|
|
|
|
4121
|
|
|
|
|
|
|
# check self |
4122
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4123
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4124
|
|
|
|
|
|
|
} |
4125
|
0
|
|
|
|
|
|
my %groups = (); |
4126
|
|
|
|
|
|
|
|
4127
|
0
|
|
|
|
|
|
my $string = $self->_getStString($st); |
4128
|
|
|
|
|
|
|
|
4129
|
0
|
|
|
|
|
|
foreach my $group (@{$semanticGroups{$string}}) { |
|
0
|
|
|
|
|
|
|
4130
|
0
|
|
|
|
|
|
$groups{$group}++; |
4131
|
|
|
|
|
|
|
} |
4132
|
|
|
|
|
|
|
|
4133
|
0
|
|
|
|
|
|
my @array = (); |
4134
|
0
|
|
|
|
|
|
foreach my $group (sort keys %groups) { push @array, $group; } |
|
0
|
|
|
|
|
|
|
4135
|
|
|
|
|
|
|
|
4136
|
0
|
|
|
|
|
|
return \@array; |
4137
|
|
|
|
|
|
|
} |
4138
|
|
|
|
|
|
|
|
4139
|
|
|
|
|
|
|
|
4140
|
|
|
|
|
|
|
# method returns the semantic group(s) associated with the concept |
4141
|
|
|
|
|
|
|
# input : $st <- string containing a semantic type abbreviation |
4142
|
|
|
|
|
|
|
# output: $array <- reference to an array containing semantic groups |
4143
|
|
|
|
|
|
|
sub _getSemanticGroupOfSt { |
4144
|
0
|
|
|
0
|
|
|
my $self = shift; |
4145
|
0
|
|
|
|
|
|
my $st = shift; |
4146
|
|
|
|
|
|
|
|
4147
|
0
|
|
|
|
|
|
my $function = "_getSemanticGroupOfSt"; |
4148
|
0
|
|
|
|
|
|
&_debug($function); |
4149
|
|
|
|
|
|
|
|
4150
|
|
|
|
|
|
|
# check self |
4151
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4152
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4153
|
|
|
|
|
|
|
} |
4154
|
|
|
|
|
|
|
|
4155
|
|
|
|
|
|
|
# check parameter exists |
4156
|
0
|
0
|
|
|
|
|
if(!defined $st) { |
4157
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$st.", 4); |
4158
|
|
|
|
|
|
|
} |
4159
|
|
|
|
|
|
|
|
4160
|
0
|
|
|
|
|
|
my $string = $self->_getStString($st); |
4161
|
|
|
|
|
|
|
|
4162
|
0
|
|
|
|
|
|
my %groups = (); |
4163
|
0
|
|
|
|
|
|
foreach my $group (@{$semanticGroups{$string}}) { |
|
0
|
|
|
|
|
|
|
4164
|
0
|
|
|
|
|
|
$groups{$group}++; |
4165
|
|
|
|
|
|
|
} |
4166
|
|
|
|
|
|
|
|
4167
|
0
|
|
|
|
|
|
my @array = (); |
4168
|
0
|
|
|
|
|
|
foreach my $group (sort keys %groups) { push @array, $group; } |
|
0
|
|
|
|
|
|
|
4169
|
|
|
|
|
|
|
|
4170
|
0
|
|
|
|
|
|
return \@array; |
4171
|
|
|
|
|
|
|
} |
4172
|
|
|
|
|
|
|
|
4173
|
|
|
|
|
|
|
|
4174
|
|
|
|
|
|
|
# method that returns a list of concepts (@concepts) related |
4175
|
|
|
|
|
|
|
# to a concept $concept through a relation $rel |
4176
|
|
|
|
|
|
|
# input : $concept <- string containing cui |
4177
|
|
|
|
|
|
|
# $rel <- string containing a relation |
4178
|
|
|
|
|
|
|
# output: $array <- reference to an array of cuis |
4179
|
|
|
|
|
|
|
sub _getExtendedRelated { |
4180
|
|
|
|
|
|
|
|
4181
|
0
|
|
|
0
|
|
|
my $self = shift; |
4182
|
0
|
|
|
|
|
|
my $concept = shift; |
4183
|
0
|
|
|
|
|
|
my $rel = shift; |
4184
|
|
|
|
|
|
|
|
4185
|
0
|
|
|
|
|
|
my $function = "_getExtendedRelated"; |
4186
|
0
|
|
|
|
|
|
&_debug($function); |
4187
|
|
|
|
|
|
|
|
4188
|
|
|
|
|
|
|
# check self |
4189
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4190
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4191
|
|
|
|
|
|
|
} |
4192
|
|
|
|
|
|
|
|
4193
|
|
|
|
|
|
|
# check parameter exists |
4194
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4195
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4196
|
|
|
|
|
|
|
} |
4197
|
|
|
|
|
|
|
|
4198
|
0
|
0
|
|
|
|
|
if(!defined $rel) { |
4199
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$rel.", 4); |
4200
|
|
|
|
|
|
|
} |
4201
|
|
|
|
|
|
|
|
4202
|
|
|
|
|
|
|
# check if valid concept |
4203
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
4204
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
4205
|
|
|
|
|
|
|
} |
4206
|
|
|
|
|
|
|
|
4207
|
|
|
|
|
|
|
# set up database |
4208
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
4209
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
4210
|
|
|
|
|
|
|
|
4211
|
|
|
|
|
|
|
# check if sources are specified and it is not umlsall |
4212
|
0
|
|
|
|
|
|
my $optional = ""; |
4213
|
0
|
0
|
|
|
|
|
if(!$umlsall) { |
4214
|
0
|
0
|
|
|
|
|
if($sabdefsources ne "") { |
4215
|
0
|
|
|
|
|
|
$optional = " and ($sabdefsources)"; |
4216
|
|
|
|
|
|
|
} |
4217
|
|
|
|
|
|
|
} |
4218
|
|
|
|
|
|
|
# if the relations is either a parent or a child add the reladefparents if specified |
4219
|
0
|
0
|
0
|
|
|
|
if( ($rel=~/PAR|RB/) && ($reladefparents ne "") ) { |
4220
|
0
|
|
|
|
|
|
$optional .= " and ($reladefparents)"; |
4221
|
|
|
|
|
|
|
} |
4222
|
0
|
0
|
0
|
|
|
|
if( ($rel=~/CHD|RN/) && ($reladefchildren ne "") ) { |
4223
|
0
|
|
|
|
|
|
$optional .= " and ($reladefchildren)"; |
4224
|
|
|
|
|
|
|
} |
4225
|
|
|
|
|
|
|
# return all the relations 'rel' for cui 'concept' |
4226
|
0
|
|
|
|
|
|
my $arrRef = $db->selectcol_arrayref("select distinct CUI2 from MRREL where CUI1='$concept' and REL='$rel' and CUI2!='$concept' $optional"); |
4227
|
|
|
|
|
|
|
|
4228
|
|
|
|
|
|
|
# check for errors |
4229
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $db); |
4230
|
|
|
|
|
|
|
|
4231
|
0
|
|
|
|
|
|
return $arrRef; |
4232
|
|
|
|
|
|
|
} |
4233
|
|
|
|
|
|
|
|
4234
|
|
|
|
|
|
|
# subroutine to get the extended definition of a concept from |
4235
|
|
|
|
|
|
|
# the concept and its surrounding relations as specified in the |
4236
|
|
|
|
|
|
|
# the configuration file. |
4237
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
4238
|
|
|
|
|
|
|
# output: $array <- reference to an array containing the definitions |
4239
|
|
|
|
|
|
|
sub _getExtendedDefinition { |
4240
|
|
|
|
|
|
|
|
4241
|
0
|
|
|
0
|
|
|
my $self = shift; |
4242
|
0
|
|
|
|
|
|
my $concept = shift; |
4243
|
|
|
|
|
|
|
|
4244
|
0
|
|
|
|
|
|
my $function = "_getExtendedDefinition"; |
4245
|
|
|
|
|
|
|
|
4246
|
|
|
|
|
|
|
# check self |
4247
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4248
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4249
|
|
|
|
|
|
|
} |
4250
|
|
|
|
|
|
|
|
4251
|
|
|
|
|
|
|
# check parameter exists |
4252
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4253
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4254
|
|
|
|
|
|
|
} |
4255
|
|
|
|
|
|
|
|
4256
|
|
|
|
|
|
|
# check if valid concept |
4257
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
4258
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
4259
|
|
|
|
|
|
|
} |
4260
|
|
|
|
|
|
|
|
4261
|
|
|
|
|
|
|
# get database |
4262
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
4263
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
4264
|
|
|
|
|
|
|
|
4265
|
0
|
|
|
|
|
|
my $sabflag = 1; |
4266
|
|
|
|
|
|
|
|
4267
|
0
|
|
|
|
|
|
my @defs = (); |
4268
|
|
|
|
|
|
|
|
4269
|
0
|
|
|
|
|
|
my $dkeys = keys %relDefHash; |
4270
|
|
|
|
|
|
|
|
4271
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"ST"}) ) { |
4272
|
0
|
|
|
|
|
|
my $sts = $self->_getSt($concept); |
4273
|
0
|
|
|
|
|
|
foreach my $st (@{$sts}) { |
|
0
|
|
|
|
|
|
|
4274
|
0
|
|
|
|
|
|
my $abr = $self->_getStAbr($st); |
4275
|
0
|
|
|
|
|
|
my $def = $self->_getStDef($abr); |
4276
|
0
|
|
|
|
|
|
my $str = "$concept ST $abr STDEF : @{$def}"; |
|
0
|
|
|
|
|
|
|
4277
|
0
|
|
|
|
|
|
push @defs, $str; |
4278
|
|
|
|
|
|
|
} |
4279
|
|
|
|
|
|
|
} |
4280
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"PAR"}) ) { |
4281
|
0
|
|
|
|
|
|
my $parents = $self->_getExtendedRelated($concept, "PAR"); |
4282
|
0
|
|
|
|
|
|
foreach my $parent (@{$parents}) { |
|
0
|
|
|
|
|
|
|
4283
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($parent, $sabflag); |
4284
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4285
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4286
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4287
|
0
|
|
|
|
|
|
my $def = "$concept PAR $parent $sab : " . (join " ", @darray); |
4288
|
0
|
|
|
|
|
|
push @defs, $def; |
4289
|
|
|
|
|
|
|
} |
4290
|
|
|
|
|
|
|
} |
4291
|
|
|
|
|
|
|
} |
4292
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"CHD"}) ) { |
4293
|
0
|
|
|
|
|
|
my $children = $self->_getExtendedRelated($concept, "CHD"); |
4294
|
0
|
|
|
|
|
|
foreach my $child (@{$children}) { |
|
0
|
|
|
|
|
|
|
4295
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($child, $sabflag); |
4296
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4297
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4298
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4299
|
0
|
|
|
|
|
|
my $def = "$concept CHD $child $sab : " . (join " ", @darray); |
4300
|
0
|
|
|
|
|
|
push @defs, $def; |
4301
|
|
|
|
|
|
|
} |
4302
|
|
|
|
|
|
|
} |
4303
|
|
|
|
|
|
|
} |
4304
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"SIB"}) ) { |
4305
|
0
|
|
|
|
|
|
my $siblings = $self->_getExtendedRelated($concept, "SIB"); |
4306
|
0
|
|
|
|
|
|
foreach my $sib (@{$siblings}) { |
|
0
|
|
|
|
|
|
|
4307
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($sib, $sabflag); |
4308
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4309
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4310
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4311
|
0
|
|
|
|
|
|
my $def = "$concept SIB $sib $sab : " . (join " ", @darray); |
4312
|
0
|
|
|
|
|
|
push @defs, $def; |
4313
|
|
|
|
|
|
|
} |
4314
|
|
|
|
|
|
|
} |
4315
|
|
|
|
|
|
|
} |
4316
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"SYN"}) ) { |
4317
|
0
|
|
|
|
|
|
my $syns = $self->_getExtendedRelated($concept, "SYN"); |
4318
|
0
|
|
|
|
|
|
foreach my $syn (@{$syns}) { |
|
0
|
|
|
|
|
|
|
4319
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($syn, $sabflag); |
4320
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4321
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4322
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4323
|
0
|
|
|
|
|
|
my $def = "$concept SYN $syn $sab : " . (join " ", @darray); |
4324
|
0
|
|
|
|
|
|
push @defs, $def; |
4325
|
|
|
|
|
|
|
} |
4326
|
|
|
|
|
|
|
} |
4327
|
|
|
|
|
|
|
} |
4328
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"RB"}) ) { |
4329
|
0
|
|
|
|
|
|
my $rbs = $self->_getExtendedRelated($concept, "RB"); |
4330
|
0
|
|
|
|
|
|
foreach my $rb (@{$rbs}) { |
|
0
|
|
|
|
|
|
|
4331
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($rb, $sabflag); |
4332
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4333
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4334
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4335
|
0
|
|
|
|
|
|
my $def = "$concept RB $rb $sab : " . (join " ", @darray); |
4336
|
0
|
|
|
|
|
|
push @defs, $def; |
4337
|
|
|
|
|
|
|
} |
4338
|
|
|
|
|
|
|
} |
4339
|
|
|
|
|
|
|
} |
4340
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"RN"}) ) { |
4341
|
0
|
|
|
|
|
|
my $rns = $self->_getExtendedRelated($concept, "RN"); |
4342
|
0
|
|
|
|
|
|
foreach my $rn (@{$rns}) { |
|
0
|
|
|
|
|
|
|
4343
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($rn, $sabflag); |
4344
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4345
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4346
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4347
|
0
|
|
|
|
|
|
my $def = "$concept RN $rn $sab : " . (join " ", @darray); |
4348
|
0
|
|
|
|
|
|
push @defs, $def; |
4349
|
|
|
|
|
|
|
} |
4350
|
|
|
|
|
|
|
} |
4351
|
|
|
|
|
|
|
} |
4352
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"RO"}) ) { |
4353
|
0
|
|
|
|
|
|
my $ros = $self->_getExtendedRelated($concept, "RO"); |
4354
|
0
|
|
|
|
|
|
foreach my $ro (@{$ros}) { |
|
0
|
|
|
|
|
|
|
4355
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($ro, $sabflag); |
4356
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4357
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4358
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4359
|
0
|
|
|
|
|
|
my $def = "$concept RO $ro $sab : " . (join " ", @darray); |
4360
|
0
|
|
|
|
|
|
push @defs, $def; |
4361
|
|
|
|
|
|
|
} |
4362
|
|
|
|
|
|
|
} |
4363
|
|
|
|
|
|
|
} |
4364
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"CUI"}) ) { |
4365
|
0
|
|
|
|
|
|
my $odefs = $self->_getCuiDef($concept, $sabflag); |
4366
|
0
|
|
|
|
|
|
foreach my $d (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4367
|
0
|
|
|
|
|
|
my @darray = split/\s+/, $d; |
4368
|
0
|
|
|
|
|
|
my $sab = shift @darray; |
4369
|
0
|
|
|
|
|
|
my $def = "$concept CUI $concept $sab : " . (join " ", @darray); |
4370
|
0
|
|
|
|
|
|
push @defs, $def; |
4371
|
|
|
|
|
|
|
} |
4372
|
|
|
|
|
|
|
} |
4373
|
0
|
0
|
0
|
|
|
|
if( ($dkeys <= 0) or (exists $relDefHash{"TERM"}) ) { |
4374
|
0
|
|
|
|
|
|
my $odefs = $self->_getTermSabList($concept); |
4375
|
0
|
|
|
|
|
|
foreach my $item (@{$odefs}) { |
|
0
|
|
|
|
|
|
|
4376
|
0
|
|
|
|
|
|
my ($sab, $term) = split/\s*\:\s*/, $item; |
4377
|
0
|
|
|
|
|
|
my $def = "$concept TERM $concept $sab : $term"; |
4378
|
0
|
|
|
|
|
|
push @defs, $def; |
4379
|
|
|
|
|
|
|
} |
4380
|
|
|
|
|
|
|
} |
4381
|
0
|
|
|
|
|
|
return \@defs; |
4382
|
|
|
|
|
|
|
} |
4383
|
|
|
|
|
|
|
|
4384
|
|
|
|
|
|
|
# subroutine to get a CUIs definition |
4385
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
4386
|
|
|
|
|
|
|
# output: $array <- reference to an array of definitions (strings) |
4387
|
|
|
|
|
|
|
sub _getCuiDef { |
4388
|
|
|
|
|
|
|
|
4389
|
0
|
|
|
0
|
|
|
my $self = shift; |
4390
|
0
|
|
|
|
|
|
my $concept = shift; |
4391
|
0
|
|
|
|
|
|
my $sabflag = shift; |
4392
|
|
|
|
|
|
|
|
4393
|
0
|
|
|
|
|
|
my $function = "_getCuiDef"; |
4394
|
|
|
|
|
|
|
|
4395
|
|
|
|
|
|
|
# check self |
4396
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4397
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4398
|
|
|
|
|
|
|
} |
4399
|
|
|
|
|
|
|
|
4400
|
|
|
|
|
|
|
# check parameter exists |
4401
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4402
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4403
|
|
|
|
|
|
|
} |
4404
|
|
|
|
|
|
|
|
4405
|
|
|
|
|
|
|
# check if valid concept |
4406
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
4407
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
4408
|
|
|
|
|
|
|
} |
4409
|
|
|
|
|
|
|
|
4410
|
|
|
|
|
|
|
# get database |
4411
|
0
|
|
|
|
|
|
my $db = $self->{'db'}; |
4412
|
0
|
0
|
|
|
|
|
if(!$db) { $errorhandler->_error($pkg, $function, "Error with db.", 3); } |
|
0
|
|
|
|
|
|
|
4413
|
|
|
|
|
|
|
|
4414
|
|
|
|
|
|
|
# set the query |
4415
|
0
|
|
|
|
|
|
my $sql = ""; |
4416
|
|
|
|
|
|
|
|
4417
|
0
|
0
|
|
|
|
|
if($sabdefsources ne "") { |
4418
|
0
|
|
|
|
|
|
$sql = qq{ SELECT DEF, SAB FROM MRDEF WHERE CUI=\'$concept\' and ($sabdefsources) }; |
4419
|
|
|
|
|
|
|
} |
4420
|
|
|
|
|
|
|
else { |
4421
|
0
|
|
|
|
|
|
$sql = qq{ SELECT DEF, SAB FROM MRDEF WHERE CUI=\'$concept\' }; |
4422
|
|
|
|
|
|
|
} |
4423
|
|
|
|
|
|
|
|
4424
|
|
|
|
|
|
|
# get the information from the database |
4425
|
0
|
|
|
|
|
|
my $sth = $db->prepare( $sql ); |
4426
|
0
|
|
|
|
|
|
$sth->execute(); |
4427
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
4428
|
|
|
|
|
|
|
|
4429
|
|
|
|
|
|
|
# set the output variable |
4430
|
0
|
|
|
|
|
|
my($def, $sab); |
4431
|
0
|
|
|
|
|
|
my @defs = (); |
4432
|
0
|
|
|
|
|
|
$sth->bind_columns( undef, \$def, \$sab ); |
4433
|
0
|
|
|
|
|
|
while( $sth->fetch() ) { |
4434
|
0
|
0
|
|
|
|
|
if(defined $sabflag) { push @defs, "$sab $def"; } |
|
0
|
|
|
|
|
|
|
4435
|
0
|
|
|
|
|
|
else { push @defs, $def; } |
4436
|
0
|
|
|
|
|
|
} $sth->finish(); |
4437
|
|
|
|
|
|
|
|
4438
|
0
|
|
|
|
|
|
return \@defs; |
4439
|
|
|
|
|
|
|
} |
4440
|
|
|
|
|
|
|
|
4441
|
|
|
|
|
|
|
|
4442
|
|
|
|
|
|
|
# returns the table names in both human readable and hex form |
4443
|
|
|
|
|
|
|
# input : |
4444
|
|
|
|
|
|
|
# output: $hash <- reference to a hash containin the table |
4445
|
|
|
|
|
|
|
# names in human readable and hex form |
4446
|
|
|
|
|
|
|
sub _returnTableNames { |
4447
|
0
|
|
|
0
|
|
|
my $self = shift; |
4448
|
|
|
|
|
|
|
|
4449
|
0
|
|
|
|
|
|
my $function = "_returnTableNames"; |
4450
|
|
|
|
|
|
|
|
4451
|
|
|
|
|
|
|
# check self |
4452
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4453
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4454
|
|
|
|
|
|
|
} |
4455
|
|
|
|
|
|
|
|
4456
|
|
|
|
|
|
|
# set the output variable |
4457
|
0
|
|
|
|
|
|
my %hash = (); |
4458
|
0
|
|
|
|
|
|
$hash{$parentTableHuman} = $parentTable; |
4459
|
0
|
|
|
|
|
|
$hash{$childTableHuman} = $childTable; |
4460
|
0
|
|
|
|
|
|
$hash{$intrinsicTableHuman} = $intrinsicTable; |
4461
|
0
|
|
|
|
|
|
$hash{$tableNameHuman} = $tableName; |
4462
|
0
|
|
|
|
|
|
$hash{$cacheTableHuman} = $cacheTable; |
4463
|
|
|
|
|
|
|
|
4464
|
0
|
|
|
|
|
|
return \%hash; |
4465
|
|
|
|
|
|
|
} |
4466
|
|
|
|
|
|
|
|
4467
|
|
|
|
|
|
|
# sets the semantic groups |
4468
|
|
|
|
|
|
|
# input: |
4469
|
|
|
|
|
|
|
# output: |
4470
|
|
|
|
|
|
|
sub _setSemanticGroups { |
4471
|
|
|
|
|
|
|
|
4472
|
0
|
|
|
0
|
|
|
%semanticGroups = (); |
4473
|
|
|
|
|
|
|
|
4474
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Activity"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4475
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Behavior"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4476
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Daily or Recreational Activity"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4477
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Event"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4478
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Governmental or Regulatory Activity"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4479
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Individual Behavior"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4480
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Machine Activity"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4481
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Occupational Activity"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4482
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Social Behavior"}}, "Activities & Behaviors"; |
|
0
|
|
|
|
|
|
|
4483
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Anatomical Structure"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4484
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Body Location or Region"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4485
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Body Part, Organ, or Organ Component"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4486
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Body Space or Junction"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4487
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Body Substance"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4488
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Body System"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4489
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Cell"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4490
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Cell Component"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4491
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Embryonic Structure"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4492
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Fully Formed Anatomical Structure"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4493
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Tissue"}}, "Anatomy"; |
|
0
|
|
|
|
|
|
|
4494
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Amino Acid, Peptide, or Protein"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4495
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Antibiotic"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4496
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Biologically Active Substance"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4497
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Biomedical or Dental Material"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4498
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Carbohydrate"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4499
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Chemical"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4500
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Chemical Viewed Functionally"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4501
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Chemical Viewed Structurally"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4502
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Clinical Drug"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4503
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Eicosanoid"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4504
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Element, Ion, or Isotope"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4505
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Enzyme"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4506
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Hazardous or Poisonous Substance"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4507
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Hormone"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4508
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Immunologic Factor"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4509
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Indicator, Reagent, or Diagnostic Aid"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4510
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Inorganic Chemical"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4511
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Lipid"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4512
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Neuroreactive Substance or Biogenic Amine"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4513
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Nucleic Acid, Nucleoside, or Nucleotide"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4514
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organic Chemical"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4515
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organophosphorus Compound"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4516
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Pharmacologic Substance"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4517
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Receptor"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4518
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Steroid"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4519
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Vitamin"}}, "Chemicals & Drugs"; |
|
0
|
|
|
|
|
|
|
4520
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Classification"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4521
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Conceptual Entity"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4522
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Functional Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4523
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Group Attribute"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4524
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Idea or Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4525
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Intellectual Product"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4526
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Language"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4527
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Qualitative Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4528
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Quantitative Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4529
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Regulation or Law"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4530
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Spatial Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4531
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Temporal Concept"}}, "Concepts & Ideas"; |
|
0
|
|
|
|
|
|
|
4532
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Drug Delivery Device"}}, "Devices"; |
|
0
|
|
|
|
|
|
|
4533
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Medical Device"}}, "Devices"; |
|
0
|
|
|
|
|
|
|
4534
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Research Device"}}, "Devices"; |
|
0
|
|
|
|
|
|
|
4535
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Acquired Abnormality"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4536
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Anatomical Abnormality"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4537
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Cell or Molecular Dysfunction"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4538
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Congenital Abnormality"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4539
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Disease or Syndrome"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4540
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Experimental Model of Disease"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4541
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Finding"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4542
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Injury or Poisoning"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4543
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Mental or Behavioral Dysfunction"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4544
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Neoplastic Process"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4545
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Pathologic Function"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4546
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Sign or Symptom"}}, "Disorders"; |
|
0
|
|
|
|
|
|
|
4547
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Amino Acid Sequence"}}, "Genes & Molecular Sequences"; |
|
0
|
|
|
|
|
|
|
4548
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Carbohydrate Sequence"}}, "Genes & Molecular Sequences"; |
|
0
|
|
|
|
|
|
|
4549
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Gene or Genome"}}, "Genes & Molecular Sequences"; |
|
0
|
|
|
|
|
|
|
4550
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Molecular Sequence"}}, "Genes & Molecular Sequences"; |
|
0
|
|
|
|
|
|
|
4551
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Nucleotide Sequence"}}, "Genes & Molecular Sequences"; |
|
0
|
|
|
|
|
|
|
4552
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Geographic Area"}}, "Geographic Areas"; |
|
0
|
|
|
|
|
|
|
4553
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Age Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4554
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Amphibian"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4555
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Animal"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4556
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Archaeon"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4557
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Bacterium"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4558
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Bird"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4559
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Eukaryote"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4560
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Family Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4561
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Fish"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4562
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Fungus"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4563
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4564
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Human"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4565
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Mammal"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4566
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organism"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4567
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Patient or Disabled Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4568
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Plant"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4569
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Population Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4570
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Professional or Occupational Group"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4571
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Reptile"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4572
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Vertebrate"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4573
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Virus"}}, "Living Beings"; |
|
0
|
|
|
|
|
|
|
4574
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Entity"}}, "Objects"; |
|
0
|
|
|
|
|
|
|
4575
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Food"}}, "Objects"; |
|
0
|
|
|
|
|
|
|
4576
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Manufactured Object"}}, "Objects"; |
|
0
|
|
|
|
|
|
|
4577
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Physical Object"}}, "Objects"; |
|
0
|
|
|
|
|
|
|
4578
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Substance"}}, "Objects"; |
|
0
|
|
|
|
|
|
|
4579
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Biomedical Occupation or Discipline"}}, "Occupations"; |
|
0
|
|
|
|
|
|
|
4580
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Occupation or Discipline"}}, "Occupations"; |
|
0
|
|
|
|
|
|
|
4581
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Health Care Related Organization"}}, "Organizations"; |
|
0
|
|
|
|
|
|
|
4582
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organization"}}, "Organizations"; |
|
0
|
|
|
|
|
|
|
4583
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Professional Society"}}, "Organizations"; |
|
0
|
|
|
|
|
|
|
4584
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Self-help or Relief Organization"}}, "Organizations"; |
|
0
|
|
|
|
|
|
|
4585
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Biologic Function"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4586
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Environmental Effect of Humans"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4587
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Human-caused Phenomenon or Process"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4588
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Laboratory or Test Result"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4589
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Natural Phenomenon or Process"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4590
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Phenomenon or Process"}}, "Phenomena"; |
|
0
|
|
|
|
|
|
|
4591
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Cell Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4592
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Clinical Attribute"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4593
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Genetic Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4594
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Mental Process"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4595
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Molecular Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4596
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organism Attribute"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4597
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organism Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4598
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Organ or Tissue Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4599
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Physiologic Function"}}, "Physiology"; |
|
0
|
|
|
|
|
|
|
4600
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Diagnostic Procedure"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4601
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Educational Activity"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4602
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Health Care Activity"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4603
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Laboratory Procedure"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4604
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Molecular Biology Research Technique"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4605
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Research Activity"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4606
|
0
|
|
|
|
|
|
push @{$semanticGroups{"Therapeutic or Preventive Procedure"}}, "Procedures"; |
|
0
|
|
|
|
|
|
|
4607
|
|
|
|
|
|
|
|
4608
|
0
|
|
|
|
|
|
$sgConversion{"ACTI"} = "Activities & Behaviors"; |
4609
|
0
|
|
|
|
|
|
$sgConversion{"ANAT"} = "Anatomy"; |
4610
|
0
|
|
|
|
|
|
$sgConversion{"CHEM"} = "Chemicals & Drugs"; |
4611
|
0
|
|
|
|
|
|
$sgConversion{"CONC"} = "Concepts & Ideas"; |
4612
|
0
|
|
|
|
|
|
$sgConversion{"DEVI"} = "Devices"; |
4613
|
0
|
|
|
|
|
|
$sgConversion{"DISO"} = "Disorders"; |
4614
|
0
|
|
|
|
|
|
$sgConversion{"GENE"} = "Genes & Molecular Sequences"; |
4615
|
0
|
|
|
|
|
|
$sgConversion{"GEOG"} = "Geographic Areas"; |
4616
|
0
|
|
|
|
|
|
$sgConversion{"LIVB"} = "Living Beings"; |
4617
|
0
|
|
|
|
|
|
$sgConversion{"OBJC"} = "Objects"; |
4618
|
0
|
|
|
|
|
|
$sgConversion{"OCCU"} = "Occupations"; |
4619
|
0
|
|
|
|
|
|
$sgConversion{"ORGA"} = "Organizations"; |
4620
|
0
|
|
|
|
|
|
$sgConversion{"PHEN"} = "Phenomena"; |
4621
|
0
|
|
|
|
|
|
$sgConversion{"PHYS"} = "Physiology"; |
4622
|
0
|
|
|
|
|
|
$sgConversion{"PROC"} = "Procedures"; |
4623
|
|
|
|
|
|
|
|
4624
|
0
|
|
|
|
|
|
$sgConversion1{"Activities & Behaviors"} = "ACTI"; |
4625
|
0
|
|
|
|
|
|
$sgConversion1{"Anatomy"} = "ANAT"; |
4626
|
0
|
|
|
|
|
|
$sgConversion1{"Chemicals & Drugs"} = "CHEM"; |
4627
|
0
|
|
|
|
|
|
$sgConversion1{"Concepts & Ideas"} = "CONC"; |
4628
|
0
|
|
|
|
|
|
$sgConversion1{"Devices"} = "DEVI"; |
4629
|
0
|
|
|
|
|
|
$sgConversion1{"Disorders"} = "DISO"; |
4630
|
0
|
|
|
|
|
|
$sgConversion1{"Genes & Molecular Sequences"} = "GENE"; |
4631
|
0
|
|
|
|
|
|
$sgConversion1{"Geographic Areas"} = "GEOG"; |
4632
|
0
|
|
|
|
|
|
$sgConversion1{"Living Beings"} = "LIVB"; |
4633
|
0
|
|
|
|
|
|
$sgConversion1{"Objects"} = "OBJ"; |
4634
|
0
|
|
|
|
|
|
$sgConversion1{"Occupations"} = "OCCU"; |
4635
|
0
|
|
|
|
|
|
$sgConversion1{"Organizations"} = "ORGA"; |
4636
|
0
|
|
|
|
|
|
$sgConversion1{"Phenomena"} = "PHEN"; |
4637
|
0
|
|
|
|
|
|
$sgConversion1{"Physiology"} = "PHYS"; |
4638
|
0
|
|
|
|
|
|
$sgConversion1{"Procedures"} = "PROC"; |
4639
|
|
|
|
|
|
|
} |
4640
|
|
|
|
|
|
|
|
4641
|
|
|
|
|
|
|
# removes the configuration tables |
4642
|
|
|
|
|
|
|
# input : |
4643
|
|
|
|
|
|
|
# output: |
4644
|
|
|
|
|
|
|
sub _dropConfigTable { |
4645
|
|
|
|
|
|
|
|
4646
|
0
|
|
|
0
|
|
|
my $self = shift; |
4647
|
|
|
|
|
|
|
|
4648
|
0
|
|
|
|
|
|
my $function = "_dropConfigTable"; |
4649
|
0
|
|
|
|
|
|
&_debug($function); |
4650
|
|
|
|
|
|
|
|
4651
|
|
|
|
|
|
|
# check self |
4652
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4653
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4654
|
|
|
|
|
|
|
} |
4655
|
|
|
|
|
|
|
|
4656
|
|
|
|
|
|
|
# connect to the database |
4657
|
0
|
|
|
|
|
|
my $sdb = $self->_connectIndexDB(); |
4658
|
0
|
0
|
|
|
|
|
if(!$sdb) { $errorhandler->_error($pkg, $function, "Error with sdb.", 3); } |
|
0
|
|
|
|
|
|
|
4659
|
|
|
|
|
|
|
|
4660
|
|
|
|
|
|
|
# show all of the tables |
4661
|
0
|
|
|
|
|
|
my $sth = $sdb->prepare("show tables"); |
4662
|
0
|
|
|
|
|
|
$sth->execute(); |
4663
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sth); |
4664
|
|
|
|
|
|
|
|
4665
|
|
|
|
|
|
|
# get all the tables in mysql |
4666
|
0
|
|
|
|
|
|
my $table = ""; |
4667
|
0
|
|
|
|
|
|
my %tables = (); |
4668
|
0
|
|
|
|
|
|
while(($table) = $sth->fetchrow()) { |
4669
|
0
|
|
|
|
|
|
$tables{$table}++; |
4670
|
|
|
|
|
|
|
} |
4671
|
0
|
|
|
|
|
|
$sth->finish(); |
4672
|
|
|
|
|
|
|
|
4673
|
0
|
0
|
|
|
|
|
if(exists $tables{$intrinsicTable}) { |
4674
|
0
|
|
|
|
|
|
$sdb->do("drop table $intrinsicTable"); |
4675
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4676
|
|
|
|
|
|
|
} |
4677
|
0
|
0
|
|
|
|
|
if(exists $tables{$parentTable}) { |
4678
|
0
|
|
|
|
|
|
$sdb->do("drop table $parentTable"); |
4679
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4680
|
|
|
|
|
|
|
} |
4681
|
0
|
0
|
|
|
|
|
if(exists $tables{$childTable}) { |
4682
|
0
|
|
|
|
|
|
$sdb->do("drop table $childTable"); |
4683
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4684
|
|
|
|
|
|
|
} |
4685
|
0
|
0
|
|
|
|
|
if(exists $tables{$cacheTable}) { |
4686
|
0
|
|
|
|
|
|
$sdb->do("drop table $cacheTable"); |
4687
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4688
|
|
|
|
|
|
|
} |
4689
|
0
|
0
|
|
|
|
|
if(exists $tables{$tableName}) { |
4690
|
0
|
|
|
|
|
|
$sdb->do("drop table $tableName"); |
4691
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4692
|
|
|
|
|
|
|
} |
4693
|
0
|
0
|
|
|
|
|
if(exists $tables{$infoTable}) { |
4694
|
0
|
|
|
|
|
|
$sdb->do("drop table $infoTable"); |
4695
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4696
|
|
|
|
|
|
|
} |
4697
|
0
|
0
|
|
|
|
|
if(exists $tables{"tableindex"}) { |
4698
|
|
|
|
|
|
|
|
4699
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$intrinsicTable'"); |
4700
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4701
|
|
|
|
|
|
|
|
4702
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$parentTable'"); |
4703
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4704
|
|
|
|
|
|
|
|
4705
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$childTable'"); |
4706
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4707
|
|
|
|
|
|
|
|
4708
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$cacheTable'"); |
4709
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4710
|
|
|
|
|
|
|
|
4711
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$tableName'"); |
4712
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4713
|
|
|
|
|
|
|
|
4714
|
0
|
|
|
|
|
|
$sdb->do("delete from tableindex where HEX='$infoTable'"); |
4715
|
0
|
|
|
|
|
|
$errorhandler->_checkDbError($pkg, $function, $sdb); |
4716
|
|
|
|
|
|
|
} |
4717
|
|
|
|
|
|
|
} |
4718
|
|
|
|
|
|
|
|
4719
|
|
|
|
|
|
|
# removes the configuration files |
4720
|
|
|
|
|
|
|
# input : |
4721
|
|
|
|
|
|
|
# output: |
4722
|
|
|
|
|
|
|
sub _removeConfigFiles { |
4723
|
|
|
|
|
|
|
|
4724
|
0
|
|
|
0
|
|
|
my $self = shift; |
4725
|
|
|
|
|
|
|
|
4726
|
0
|
|
|
|
|
|
my $function = "_removeConfigFiles"; |
4727
|
0
|
|
|
|
|
|
&_debug($function); |
4728
|
|
|
|
|
|
|
|
4729
|
|
|
|
|
|
|
# check self |
4730
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4731
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4732
|
|
|
|
|
|
|
} |
4733
|
|
|
|
|
|
|
|
4734
|
|
|
|
|
|
|
# remove the files |
4735
|
0
|
0
|
|
|
|
|
if(-e $tableFile) { |
4736
|
0
|
|
|
|
|
|
system "rm $tableFile"; |
4737
|
|
|
|
|
|
|
} |
4738
|
0
|
0
|
|
|
|
|
if(-e $childFile) { |
4739
|
0
|
|
|
|
|
|
system "rm $childFile"; |
4740
|
|
|
|
|
|
|
} |
4741
|
0
|
0
|
|
|
|
|
if(-e $parentFile) { |
4742
|
0
|
|
|
|
|
|
system "rm $parentFile"; |
4743
|
|
|
|
|
|
|
} |
4744
|
0
|
0
|
|
|
|
|
if(-e $configFile) { |
4745
|
0
|
|
|
|
|
|
system "rm $configFile"; |
4746
|
|
|
|
|
|
|
} |
4747
|
|
|
|
|
|
|
|
4748
|
|
|
|
|
|
|
} |
4749
|
|
|
|
|
|
|
|
4750
|
|
|
|
|
|
|
# checks to see if the cui is in the parent taxonomy |
4751
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
4752
|
|
|
|
|
|
|
# output: $bool <- indicating if the cui exists in |
4753
|
|
|
|
|
|
|
# the upper level taxonamy |
4754
|
|
|
|
|
|
|
sub _inParentTaxonomy { |
4755
|
|
|
|
|
|
|
|
4756
|
0
|
|
|
0
|
|
|
my $self = shift; |
4757
|
0
|
|
|
|
|
|
my $concept = shift; |
4758
|
|
|
|
|
|
|
|
4759
|
0
|
|
|
|
|
|
my $function = "_inParentTaxonomy"; |
4760
|
0
|
|
|
|
|
|
&_debug($function); |
4761
|
|
|
|
|
|
|
|
4762
|
|
|
|
|
|
|
# check self |
4763
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4764
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4765
|
|
|
|
|
|
|
} |
4766
|
|
|
|
|
|
|
|
4767
|
|
|
|
|
|
|
# check parameter exists |
4768
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4769
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4770
|
|
|
|
|
|
|
} |
4771
|
|
|
|
|
|
|
|
4772
|
|
|
|
|
|
|
# check if valid concept |
4773
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
4774
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
4775
|
|
|
|
|
|
|
} |
4776
|
|
|
|
|
|
|
|
4777
|
0
|
0
|
|
|
|
|
if(exists $parentTaxonomyArray{$concept}) { return 1; } |
|
0
|
|
|
|
|
|
|
4778
|
0
|
|
|
|
|
|
else { return 0; } |
4779
|
|
|
|
|
|
|
} |
4780
|
|
|
|
|
|
|
|
4781
|
|
|
|
|
|
|
# checks to see if the cui is in the child taxonomy |
4782
|
|
|
|
|
|
|
# input : $concept <- string containing a cui |
4783
|
|
|
|
|
|
|
# output: $bool <- indicating if the cui exists in |
4784
|
|
|
|
|
|
|
# the upper level taxonamy |
4785
|
|
|
|
|
|
|
sub _inChildTaxonomy { |
4786
|
|
|
|
|
|
|
|
4787
|
0
|
|
|
0
|
|
|
my $self = shift; |
4788
|
0
|
|
|
|
|
|
my $concept = shift; |
4789
|
|
|
|
|
|
|
|
4790
|
0
|
|
|
|
|
|
my $function = "_inChildTaxonomy"; |
4791
|
0
|
|
|
|
|
|
&_debug($function); |
4792
|
|
|
|
|
|
|
|
4793
|
|
|
|
|
|
|
# check self |
4794
|
0
|
0
|
0
|
|
|
|
if(!defined $self || !ref $self) { |
4795
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "", 2); |
4796
|
|
|
|
|
|
|
} |
4797
|
|
|
|
|
|
|
|
4798
|
|
|
|
|
|
|
# check parameter exists |
4799
|
0
|
0
|
|
|
|
|
if(!defined $concept) { |
4800
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Error with input variable \$concept.", 4); |
4801
|
|
|
|
|
|
|
} |
4802
|
|
|
|
|
|
|
|
4803
|
|
|
|
|
|
|
# check if valid concept |
4804
|
0
|
0
|
|
|
|
|
if(! ($errorhandler->_validCui($concept)) ) { |
4805
|
0
|
|
|
|
|
|
$errorhandler->_error($pkg, $function, "Concept ($concept) is not valid.", 6); |
4806
|
|
|
|
|
|
|
} |
4807
|
|
|
|
|
|
|
|
4808
|
0
|
0
|
|
|
|
|
if(exists $childTaxonomyArray{$concept}) { return 1; } |
|
0
|
|
|
|
|
|
|
4809
|
0
|
|
|
|
|
|
else { return 0; } |
4810
|
|
|
|
|
|
|
} |
4811
|
|
|
|
|
|
|
|
4812
|
|
|
|
|
|
|
|
4813
|
|
|
|
|
|
|
# function to create a timestamp |
4814
|
|
|
|
|
|
|
# input : |
4815
|
|
|
|
|
|
|
# output: $string <- containing the time stamp |
4816
|
|
|
|
|
|
|
sub _timeStamp { |
4817
|
|
|
|
|
|
|
|
4818
|
0
|
|
|
0
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
4819
|
|
|
|
|
|
|
|
4820
|
0
|
|
|
|
|
|
$year += 1900; |
4821
|
0
|
|
|
|
|
|
$mon++; |
4822
|
0
|
|
|
|
|
|
my $d = sprintf("%4d%2.2d%2.2d",$year,$mon,$mday); |
4823
|
0
|
|
|
|
|
|
my $t = sprintf("%2.2d%2.2d%2.2d",$hour,$min,$sec); |
4824
|
|
|
|
|
|
|
|
4825
|
0
|
|
|
|
|
|
my $stamp = $d . $t; |
4826
|
|
|
|
|
|
|
|
4827
|
0
|
|
|
|
|
|
return $stamp; |
4828
|
|
|
|
|
|
|
} |
4829
|
|
|
|
|
|
|
|
4830
|
|
|
|
|
|
|
# function to get the time |
4831
|
|
|
|
|
|
|
# input : |
4832
|
|
|
|
|
|
|
# output: $string <- containing the time |
4833
|
|
|
|
|
|
|
sub _printTime { |
4834
|
0
|
|
|
0
|
|
|
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
4835
|
|
|
|
|
|
|
|
4836
|
0
|
|
|
|
|
|
$year += 1900; |
4837
|
0
|
|
|
|
|
|
$mon++; |
4838
|
|
|
|
|
|
|
|
4839
|
0
|
|
|
|
|
|
my $d = sprintf("%4d%2.2d%2.2d",$year,$mon,$mday); |
4840
|
0
|
|
|
|
|
|
my $t = sprintf("%2.2d%2.2d%2.2d",$hour,$min,$sec); |
4841
|
|
|
|
|
|
|
|
4842
|
0
|
|
|
|
|
|
print STDERR "$t\n"; |
4843
|
|
|
|
|
|
|
|
4844
|
|
|
|
|
|
|
} |
4845
|
|
|
|
|
|
|
|
4846
|
|
|
|
|
|
|
# return the file name containing the index table |
4847
|
|
|
|
|
|
|
sub _getTableFile { |
4848
|
|
|
|
|
|
|
|
4849
|
0
|
|
|
0
|
|
|
return $tableFile; |
4850
|
|
|
|
|
|
|
} |
4851
|
|
|
|
|
|
|
|
4852
|
|
|
|
|
|
|
|
4853
|
|
|
|
|
|
|
# return the table name in the index - this is the hex |
4854
|
|
|
|
|
|
|
sub _getTableName { |
4855
|
|
|
|
|
|
|
|
4856
|
0
|
|
|
0
|
|
|
return $tableName; |
4857
|
|
|
|
|
|
|
} |
4858
|
|
|
|
|
|
|
|
4859
|
|
|
|
|
|
|
# return the table name in the index in human form |
4860
|
|
|
|
|
|
|
sub _getTableNameHuman { |
4861
|
|
|
|
|
|
|
|
4862
|
0
|
|
|
0
|
|
|
return $tableNameHuman; |
4863
|
|
|
|
|
|
|
} |
4864
|
|
|
|
|
|
|
|
4865
|
|
|
|
|
|
|
sub _getCacheTableName { |
4866
|
0
|
|
|
0
|
|
|
return $cacheTable; |
4867
|
|
|
|
|
|
|
} |
4868
|
|
|
|
|
|
|
|
4869
|
|
|
|
|
|
|
sub _getCacheTableNameHuman{ |
4870
|
0
|
|
|
0
|
|
|
return $cacheTableHuman; |
4871
|
|
|
|
|
|
|
} |
4872
|
|
|
|
|
|
|
|
4873
|
|
|
|
|
|
|
sub _getInfoTableName { |
4874
|
0
|
|
|
0
|
|
|
return $infoTable; |
4875
|
|
|
|
|
|
|
} |
4876
|
|
|
|
|
|
|
|
4877
|
|
|
|
|
|
|
sub _getInfoTableNameHuman { |
4878
|
0
|
|
|
0
|
|
|
return $infoTableHuman; |
4879
|
|
|
|
|
|
|
} |
4880
|
|
|
|
|
|
|
|
4881
|
|
|
|
|
|
|
sub _getIntrinsicTableName { |
4882
|
0
|
|
|
0
|
|
|
return $intrinsicTable; |
4883
|
|
|
|
|
|
|
} |
4884
|
|
|
|
|
|
|
|
4885
|
|
|
|
|
|
|
sub _getIntrinsicTableNameHuman { |
4886
|
0
|
|
|
0
|
|
|
return $intrinsicTableHuman; |
4887
|
|
|
|
|
|
|
} |
4888
|
|
|
|
|
|
|
|
4889
|
|
|
|
|
|
|
1; |
4890
|
|
|
|
|
|
|
|
4891
|
|
|
|
|
|
|
|
4892
|
|
|
|
|
|
|
|
4893
|
|
|
|
|
|
|
|
4894
|
|
|
|
|
|
|
__END__ |