| 1 | # UMLS::Association | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Perl module for scoring the semantic association of terms in the Unified | ||||||||||||||||||||||||||||
| 4 | # Medical Language System (UMLS). | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This module borrows heavily from the UMLS::Interface package so you will | ||||||||||||||||||||||||||||
| 7 | # see similarities | ||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||
| 9 | # Copyright (c) 2015 | ||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||
| 11 | # Bridget T. McInnes, Virginia Commonwealth University | ||||||||||||||||||||||||||||
| 12 | # btmcinnes at vcu.edu | ||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||
| 14 | # Keith Herbert, Virginia Commonwealth University | ||||||||||||||||||||||||||||
| 15 | # herbertkb at vcu.edu | ||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||
| 17 | # Alexander D. McQuilkin, Virginia Commonwealth University | ||||||||||||||||||||||||||||
| 18 | # alexmcq99 at yahoo.com | ||||||||||||||||||||||||||||
| 19 | # | ||||||||||||||||||||||||||||
| 20 | # This program is free software; you can redistribute it and/or | ||||||||||||||||||||||||||||
| 21 | # modify it under the terms of the GNU General Public License | ||||||||||||||||||||||||||||
| 22 | # as published by the Free Software Foundation; either version 2 | ||||||||||||||||||||||||||||
| 23 | # of the License, or (at your option) any later version. | ||||||||||||||||||||||||||||
| 24 | # | ||||||||||||||||||||||||||||
| 25 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||
| 26 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 27 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||
| 28 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||
| 30 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||
| 31 | # along with this program; if not, write to | ||||||||||||||||||||||||||||
| 32 | # | ||||||||||||||||||||||||||||
| 33 | # The Free Software Foundation, Inc., | ||||||||||||||||||||||||||||
| 34 | # 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||
| 35 | # Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head1 NAME | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | UMLS::Association - A suite of Perl modules that implement a number of semantic | ||||||||||||||||||||||||||||
| 40 | association measures in order to calculate the semantic association between two | ||||||||||||||||||||||||||||
| 41 | concepts in the UMLS. | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =head1 INSTALL | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | To install the module, run the following magic commands: | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | perl Makefile.PL | ||||||||||||||||||||||||||||
| 51 | make | ||||||||||||||||||||||||||||
| 52 | make test | ||||||||||||||||||||||||||||
| 53 | make install | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | This will install the module in the standard location. You will, most | ||||||||||||||||||||||||||||
| 56 | probably, require root privileges to install in standard system | ||||||||||||||||||||||||||||
| 57 | directories. To install in a non-standard directory, specify a prefix | ||||||||||||||||||||||||||||
| 58 | during the 'perl Makefile.PL' stage as: | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | perl Makefile.PL PREFIX=/home/sid | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | It is possible to modify other parameters during installation. The | ||||||||||||||||||||||||||||
| 63 | details of these can be found in the ExtUtils::MakeMaker | ||||||||||||||||||||||||||||
| 64 | documentation. However, it is highly recommended not messing around | ||||||||||||||||||||||||||||
| 65 | with other parameters, unless you know what you're doing. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | This package provides a Perl interface to | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 DATABASE SETUP | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | The interface assumes that the CUI network extracted from the MetaMapped | ||||||||||||||||||||||||||||
| 74 | Medline Baseline is present in a mysql database. The name of the database | ||||||||||||||||||||||||||||
| 75 | can be passed as configuration options at initialization. However, if the | ||||||||||||||||||||||||||||
| 76 | names of the databases are not provided at initialization, then default | ||||||||||||||||||||||||||||
| 77 | value is used -- the database is called 'CUI_BIGRAMS'. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | The CUI_BIGRAMS database must contain four? tables: | ||||||||||||||||||||||||||||
| 80 | 1. N11 | ||||||||||||||||||||||||||||
| 81 | 2. N1P | ||||||||||||||||||||||||||||
| 82 | 3. NP1 | ||||||||||||||||||||||||||||
| 83 | 4. NPP | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | All other tables in the databases will be ignored, and any of these | ||||||||||||||||||||||||||||
| 86 | tables missing would raise an error. | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | A script explaining how to create the CUI network and the mysql database | ||||||||||||||||||||||||||||
| 89 | are in the INSTALL file. | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head1 INITIALIZING THE MODULE | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | To create an instance of the interface object, using default values | ||||||||||||||||||||||||||||
| 94 | for all configuration options: | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 97 | my $associaton = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Database connection options can be passed through the my.cnf file. For | ||||||||||||||||||||||||||||
| 100 | example: | ||||||||||||||||||||||||||||
| 101 | [client] | ||||||||||||||||||||||||||||
| 102 | user = <username> | ||||||||||||||||||||||||||||
| 103 | password = <password> | ||||||||||||||||||||||||||||
| 104 | port = 3306 | ||||||||||||||||||||||||||||
| 105 | socket = /tmp/mysql.sock | ||||||||||||||||||||||||||||
| 106 | database = mmb | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | Or through the by passing the connection information when first | ||||||||||||||||||||||||||||
| 109 | instantiating an instance. For example: | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | $associaton = UMLS::Association->new({"driver" => "mysql", | ||||||||||||||||||||||||||||
| 112 | "database" => "$database", | ||||||||||||||||||||||||||||
| 113 | "username" => "$username", | ||||||||||||||||||||||||||||
| 114 | "password" => "$password", | ||||||||||||||||||||||||||||
| 115 | "hostname" => "$hostname", | ||||||||||||||||||||||||||||
| 116 | "socket" => "$socket"}); | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 'driver' -> Default value 'mysql'. This option specifies the Perl | ||||||||||||||||||||||||||||
| 119 | DBD driver that should be used to access the | ||||||||||||||||||||||||||||
| 120 | database. This implies that the some other DBMS | ||||||||||||||||||||||||||||
| 121 | system (such as PostgresSQL) could also be used, | ||||||||||||||||||||||||||||
| 122 | as long as there exist Perl DBD drivers to | ||||||||||||||||||||||||||||
| 123 | access the database. | ||||||||||||||||||||||||||||
| 124 | 'database' -> Default value 'CUI_BIGRAM'. This option specifies the name | ||||||||||||||||||||||||||||
| 125 | of the database. | ||||||||||||||||||||||||||||
| 126 | 'hostname' -> Default value 'localhost'. The name or the IP address | ||||||||||||||||||||||||||||
| 127 | of the machine on which the database server is | ||||||||||||||||||||||||||||
| 128 | running. | ||||||||||||||||||||||||||||
| 129 | 'socket' -> Default value '/tmp/mysql.sock'. The socket on which | ||||||||||||||||||||||||||||
| 130 | the database server is using. | ||||||||||||||||||||||||||||
| 131 | 'port' -> The port number on which the database server accepts | ||||||||||||||||||||||||||||
| 132 | connections. | ||||||||||||||||||||||||||||
| 133 | 'username' -> Username to use to connect to the database server. If | ||||||||||||||||||||||||||||
| 134 | not provided, the module attempts to connect as an | ||||||||||||||||||||||||||||
| 135 | anonymous user. | ||||||||||||||||||||||||||||
| 136 | 'password' -> Password for access to the database server. If not | ||||||||||||||||||||||||||||
| 137 | provided, the module attempts to access the server | ||||||||||||||||||||||||||||
| 138 | without a password. | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | More information is provided in the INSTALL file. | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =head1 PARAMETERS | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | You can also pass other parameters which controls the functionality | ||||||||||||||||||||||||||||
| 145 | of the Association.pm module. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | $assoc = UMLS::Association->new({"measure" => "lch"}); | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 'measure' -> This modifies the association measure | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head1 FUNCTION DESCRIPTIONS | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | package UMLS::Association; | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 1 | ▶ | use Fcntl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 158 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 159 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 160 | 1 | ▶ | use DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 161 | 1 | ▶ | use bytes; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 1 | ▶ | use UMLS::Association::CuiFinder; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 164 | 1 | ▶ | use UMLS::Association::StatFinder; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 165 | 1 | ▶ | use UMLS::Association::ErrorHandler; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 1 | my $errorhandler = ""; | |||||||||||||||||||||||||||
| 169 | 1 | my $cuifinder = ""; | |||||||||||||||||||||||||||
| 170 | 1 | my $statfinder = ""; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 1 | my $pkg = "UMLS::Association"; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 1 | $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 1 | my $debug = 0; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | # UMLS-specific stuff ends ---------- | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # -------------------- Class methods start here -------------------- | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | # method to create a new UMLS::Association object | ||||||||||||||||||||||||||||
| 185 | # input : $params <- reference to hash containing the parameters | ||||||||||||||||||||||||||||
| 186 | # output: | ||||||||||||||||||||||||||||
| 187 | sub new { | ||||||||||||||||||||||||||||
| 188 | 1 | ▶ | my $self = {}; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 189 | 1 | my $className = shift; | |||||||||||||||||||||||||||
| 190 | 1 | my $params = shift; | |||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | # bless the object. | ||||||||||||||||||||||||||||
| 193 | 1 | bless($self, $className); | |||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # initialize error handler | ||||||||||||||||||||||||||||
| 196 | 1 | $errorhandler = UMLS::Association::ErrorHandler->new(); | |||||||||||||||||||||||||||
| 197 | 1 | ▶ | if(! defined $errorhandler) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | print STDERR "The error handler did not get passed properly.\n"; | |||||||||||||||||||||||||||
| 199 | 0 | exit; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | # check options | ||||||||||||||||||||||||||||
| 203 | 1 | $self->_checkOptions($params); | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | # Initialize the object. | ||||||||||||||||||||||||||||
| 206 | 1 | $self->_initialize($params); | |||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | 0 | return $self; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | # initialize the variables and set the parameters | ||||||||||||||||||||||||||||
| 212 | # input : $params <- reference to hash containing the parameters | ||||||||||||||||||||||||||||
| 213 | # output: | ||||||||||||||||||||||||||||
| 214 | sub _initialize { | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=5 SCAR=25.6
| |||||||||||||||||||||||||||||
| 217 | 1 | my $params = shift; | |||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | 1 | my $function = "_initialize"; | |||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | # check self | ||||||||||||||||||||||||||||
| 222 | 1 | ▶ | if(!defined $self || !ref $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self and ref $self
MC/DC0%0/2
defined $self and ref $self
defined $self
ref $self
Truth table33%1/3
A and B
A= defined $selfB= ref $self
| |||||||||||||||||||||||||||||
| 223 | 0 | $errorhandler->_error($pkg, $function, "", 2); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | # set the cuifinder | ||||||||||||||||||||||||||||
| 227 | 1 | $cuifinder = UMLS::Association::CuiFinder->new($params); | |||||||||||||||||||||||||||
| 228 | 0 | ▶ | if(! defined $cuifinder) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 0 | my $str = "The UMLS::Association::CuiFinder object was not created."; | |||||||||||||||||||||||||||
| 230 | 0 | $errorhandler->_error($pkg, $function, $str, 8); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | # set the statfinder | ||||||||||||||||||||||||||||
| 234 | 0 | $statfinder = UMLS::Association::StatFinder->new($params, $cuifinder); | |||||||||||||||||||||||||||
| 235 | 0 | ▶ | if(! defined $statfinder) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | my $str = "The UMLS::Association::StatFinder object was not created."; | |||||||||||||||||||||||||||
| 237 | 0 | $errorhandler->_error($pkg, $function, $str, 8); | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | # method checks the parameters based to the UMLS::Association package | ||||||||||||||||||||||||||||
| 242 | # input : $params <- reference to hash containing the parameters | ||||||||||||||||||||||||||||
| 243 | # output: | ||||||||||||||||||||||||||||
| 244 | sub _checkOptions { | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_checkOptions: called CC=9 SCAR=27.1
| |||||||||||||||||||||||||||||
| 247 | 1 | my $params = shift; | |||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 1 | my $function = "_checkOptions"; | |||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | # check self | ||||||||||||||||||||||||||||
| 252 | 1 | ▶ | if(!defined $self || !ref $self) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self and ref $self
MC/DC0%0/2
defined $self and ref $self
defined $self
ref $self
Truth table33%1/3
A and B
A= defined $selfB= ref $self
| |||||||||||||||||||||||||||||
| 253 | 0 | $errorhandler->_error($pkg, $function, "", 2); | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | # database options | ||||||||||||||||||||||||||||
| 257 | 1 | my $database = $params->{'database'}; | |||||||||||||||||||||||||||
| 258 | 1 | my $hostname = $params->{'hostname'}; | |||||||||||||||||||||||||||
| 259 | 1 | my $socket = $params->{'socket'}; | |||||||||||||||||||||||||||
| 260 | 1 | my $port = $params->{'port'}; | |||||||||||||||||||||||||||
| 261 | 1 | my $username = $params->{'username'}; | |||||||||||||||||||||||||||
| 262 | 1 | my $password = $params->{'password'}; | |||||||||||||||||||||||||||
| 263 | 1 | my $getDescendants = $params->{'getdescendants'}; | |||||||||||||||||||||||||||
| 264 | 1 | my $umls = $params->{'umls'}; | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | # cuifinder options | ||||||||||||||||||||||||||||
| 267 | 1 | my $measure = $params->{'config'}; | |||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | # general options | ||||||||||||||||||||||||||||
| 270 | 1 | my $debugoption = $params->{'debug'}; | |||||||||||||||||||||||||||
| 271 | 1 | my $verbose = $params->{'verbose'}; | |||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 1 | ▶ | if( (defined $username) && (!defined $password) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $username and not defined $password
MC/DC0%0/2
defined $username and not defined $password
defined $username
not defined $password
Truth table33%1/3
A and not(B)
A= defined $usernameB= not defined $password
| |||||||||||||||||||||||||||||
| 274 | 0 | my $str = "The --password option must be defined when using --username."; | |||||||||||||||||||||||||||
| 275 | 0 | $errorhandler->_error($pkg, $function, $str, 10); | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 1 | ▶ | if( (!defined $username) && (defined $password) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $username and defined $password
MC/DC0%0/2
not defined $username and defined $password
not defined $username
defined $password
Truth table33%1/3
not(A) and B
A= not defined $usernameB= defined $password
| |||||||||||||||||||||||||||||
| 279 | 0 | my $str = "The --username option must be defined when using --password."; | |||||||||||||||||||||||||||
| 280 | 0 | $errorhandler->_error($pkg, $function, $str, 10); | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 1 | ▶ | if((defined $getDescendants) && (!defined $umls)) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $getDescendants and not defined $umls
MC/DC0%0/2
defined $getDescendants and not defined $umls
defined $getDescendants
not defined $umls
Truth table33%1/3
A and not(B)
A= defined $getDescendantsB= not defined $umls
| |||||||||||||||||||||||||||||
| 284 | { | ||||||||||||||||||||||||||||
| 285 | 0 | my $str = "There must be a UMLS Interface object for getDescendants to be used."; | |||||||||||||||||||||||||||
| 286 | 0 | $errorhandler->_error($pkg, $function, $str, 10); | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =head3 exists | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | description: | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | function to check if a concept ID exists in the database. | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | input: | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | $concept <- string containing a cui | ||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | output: | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 1 | 0 <- integers indicating if the cui exists | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | example: | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 307 | my $umls = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | my $concept = "C0018563"; | ||||||||||||||||||||||||||||
| 310 | if($umls->exists($concept)) { | ||||||||||||||||||||||||||||
| 311 | print "$concept exists\n"; | ||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =cut | ||||||||||||||||||||||||||||
| 315 | sub exists() { | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
exists: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 318 | 0 | my $concept = shift; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | my $bool = $cuifinder->_exists($concept); | |||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | return $bool; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =head3 getFrequency | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | description: | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | function returns the frequency of a given concept pair | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | input: | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | $concept1 <- cui | ||||||||||||||||||||||||||||
| 335 | $concept2 <- cui | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | output: | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | $frequency <- number | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | example: | ||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 344 | my $associator = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 345 | my $freq = $mmb->getFrequency($concept1, $concept2) | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | =cut | ||||||||||||||||||||||||||||
| 348 | sub getFrequency { | ||||||||||||||||||||||||||||
| 349 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getFrequency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 350 | 0 | my $c1 = shift; | |||||||||||||||||||||||||||
| 351 | 0 | my $c2 = shift; | |||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | return $statfinder->_getFrequency($c1, $c2); | |||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||
| 356 | =head3 calculateStatistic | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | description: | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | function returns the given statistical score of a given concept pair | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | input: | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | $concept1 <- cui | ||||||||||||||||||||||||||||
| 365 | $concept2 <- cui | ||||||||||||||||||||||||||||
| 366 | $measure <- statistical measure | ||||||||||||||||||||||||||||
| 367 | output: | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | $score <- float | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | example: | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 374 | my $associator = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 375 | my $stat = $associator->calculateStatistic($concept1, $concept2, $measure) | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | =cut | ||||||||||||||||||||||||||||
| 378 | sub calculateStatistic { | ||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
calculateStatistic: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 380 | 0 | my $c1 = shift; | |||||||||||||||||||||||||||
| 381 | 0 | my $c2 = shift; | |||||||||||||||||||||||||||
| 382 | 0 | my $meas = shift; | |||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | 0 | return $statfinder->_calculateStatistic($c1, $c2, $meas); | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | =head3 getParents | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | description: | ||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | returns the parents of a concept - the relations that are considered parents | ||||||||||||||||||||||||||||
| 392 | are predefined by the user in the configuration file. The default is the PAR | ||||||||||||||||||||||||||||
| 393 | relation. | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | input: | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | $concept <- string containing cui | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | output: | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | $array <- reference to an array containing a list of cuis | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | example: | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 406 | my $umls = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 407 | my $concept = "C0018563"; | ||||||||||||||||||||||||||||
| 408 | my $parents = $umls->getParents($concept); | ||||||||||||||||||||||||||||
| 409 | print "The parents of $concept are:\n"; | ||||||||||||||||||||||||||||
| 410 | foreach my $parent (@{$parents}) { print " $parent\n"; } | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | =cut | ||||||||||||||||||||||||||||
| 413 | sub getParents { | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getParents: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 416 | 0 | my $concept = shift; | |||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 0 | my $array = $cuifinder->_getParents($concept); | |||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | return $array; | |||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =head3 getChildren | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | description: | ||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | returns the children of a concept - the relations that are considered children | ||||||||||||||||||||||||||||
| 429 | are predefined by the user in the configuration file. The default is the CHD | ||||||||||||||||||||||||||||
| 430 | relation. | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | input: | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | $concept <- string containing cui | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | output: | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | $array <- reference to an array containing a list of cuis | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | example: | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | use UMLS::Association; | ||||||||||||||||||||||||||||
| 443 | my $umls = UMLS::Association->new(); | ||||||||||||||||||||||||||||
| 444 | my $concept = "C0018563"; | ||||||||||||||||||||||||||||
| 445 | my $children = $umls->getChildren($concept); | ||||||||||||||||||||||||||||
| 446 | print "The children of $concept are:\n"; | ||||||||||||||||||||||||||||
| 447 | foreach my $child (@{$children}) { print " $child\n"; } | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||
| 450 | sub getChildren { | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
getChildren: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 453 | 0 | my $concept = shift; | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | 0 | my $array = $cuifinder->_getChildren($concept); | |||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | return $array; | |||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | 1 | 1; | |||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | __END__ | ||||||||||||||||||||||||||||