| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | findCuiDepth.pl - This program returns the minimum and maximum depth | ||||||||||||||||||||||||||||
| 6 | of a given CUI or term. | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This program takes in a CUI or a term and returns its minimum and | ||||||||||||||||||||||||||||
| 11 | maximum depth. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 USAGE | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Usage: findCuiDepth.pl [OPTIONS] [TERM|CUI] | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 INPUT | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head2 Required Arguments: | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | =head3 [TERM|CUI] | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | Concept Unique Identifier (CUI) or a term from the Unified | ||||||||||||||||||||||||||||
| 24 | Medical Language System (UMLS) | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =head2 Optional Arguments: | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =head3 --config FILE | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | This is the configuration file. The format of the configuration | ||||||||||||||||||||||||||||
| 31 | file is as follows: | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | SAB :: <include|exclude> <source1, source2, ... sourceN> | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | REL :: <include|exclude> <relation1, relation2, ... relationN> | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | RELA :: <include|exclude> <rela1, rela2, ... relaN> (optional) | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | For example, if we wanted to use the MSH vocabulary with only | ||||||||||||||||||||||||||||
| 40 | the RB/RN relations, the configuration file would be: | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 43 | REL :: include RB, RN | ||||||||||||||||||||||||||||
| 44 | RELA :: include isa, inverse_isa | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | or | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 49 | REL :: exclude PAR, CHD | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | If you go to the configuration file directory, there will | ||||||||||||||||||||||||||||
| 52 | be example configuration files for the different runs that | ||||||||||||||||||||||||||||
| 53 | you have performed. | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | =head3 --debug | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | This sets the debug flag for testing | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head3 --infile FILE | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | This option takes a list of CUIs or TERMs and returns their | ||||||||||||||||||||||||||||
| 62 | depth. Note one CUI or TERM per line is the expected format. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head3 --minimum | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Finds just the minimum CUI depth | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head3 --maximum | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Finds just the maximum CUI depth | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =head3 --username STRING | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Username is required to access the umls database on MySql | ||||||||||||||||||||||||||||
| 75 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head3 --password STRING | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Password is required to access the umls database on MySql | ||||||||||||||||||||||||||||
| 80 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head3 --hostname STRING | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Hostname where mysql is located. DEFAULT: localhost | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head3 --socket STRING | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | The socket your mysql is using. DEFAULT: /tmp/mysql.sock | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head3 --database STRING | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Database contain UMLS DEFAULT: umls | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head3 --realtime | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | This option will not create a database of the path information | ||||||||||||||||||||||||||||
| 97 | for all of concepts in the specified set of sources and relations | ||||||||||||||||||||||||||||
| 98 | in the config file but obtain the information for just the | ||||||||||||||||||||||||||||
| 99 | input concept | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | =head3 --forcerun | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | This option will bypass any command prompts such as asking | ||||||||||||||||||||||||||||
| 104 | if you would like to continue with the index creation. | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head3 --verbose | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | This option will print out the table information to the | ||||||||||||||||||||||||||||
| 109 | config file that you specified. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =head3 --debugpath FILE | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | This option prints out the path information for debugging | ||||||||||||||||||||||||||||
| 114 | purposes. This option is only really available with the | ||||||||||||||||||||||||||||
| 115 | --reatime option because otherwise the path information is | ||||||||||||||||||||||||||||
| 116 | stored in the database. You can get this information in a | ||||||||||||||||||||||||||||
| 117 | file if you use the --verbose option while creating the index. | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =head3 --cuilist FILE | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | This option takes in a file containing a list of CUIs (one CUI | ||||||||||||||||||||||||||||
| 122 | per line) and stores only the path information for those CUIs | ||||||||||||||||||||||||||||
| 123 | rather than for all of the CUIs given the specified set of | ||||||||||||||||||||||||||||
| 124 | sources and relations | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head3 --help | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | Displays the quick summary of program options. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head3 --version | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Displays the version information. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =head1 OUTPUT | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | The minimum depth of a given CUI or term | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =head1 CONFIGURATION FILE | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | There exist a configuration files to specify which source and what | ||||||||||||||||||||||||||||
| 141 | relations are to be used. The default source is the Medical Subject | ||||||||||||||||||||||||||||
| 142 | Heading (MSH) vocabulary and the default relations are the PAR/CHD | ||||||||||||||||||||||||||||
| 143 | relation. | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | The format of the configuration file is as follows: | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | SAB :: <include|exclude> <source1, source2, ... sourceN> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | REL :: <include|exclude> <relation1, relation2, ... relationN> | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | The SAB and REL are for specifing what sources and relations | ||||||||||||||||||||||||||||
| 152 | should be used when traversing the UMLS. For example, if we | ||||||||||||||||||||||||||||
| 153 | wanted to use the MSH vocabulary with only the RB/RN relations, | ||||||||||||||||||||||||||||
| 154 | the configuration file would be: | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 157 | REL :: include RB, RN | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | or if we wanted to use MSH and use any relation except for PAR/CHD, | ||||||||||||||||||||||||||||
| 160 | the configuration would be: | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 163 | REL :: exclude PAR, CHD | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | An example of the configuration file can be seen in the samples/ directory. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head1 SYSTEM REQUIREMENTS | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =over | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =item * Perl (version 5.8.5 or better) - http://www.perl.org | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =back | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | Copyright (c) 2007-2009, | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||
| 184 | bthomson at cs.umn.edu | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Ted Pedersen, University of Minnesota Duluth | ||||||||||||||||||||||||||||
| 187 | tpederse at d.umn.edu | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | Siddharth Patwardhan, University of Utah, Salt Lake City | ||||||||||||||||||||||||||||
| 190 | sidd@cs.utah.edu | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | Serguei Pakhomov, University of Minnesota Twin Cities | ||||||||||||||||||||||||||||
| 193 | pakh0002@umn.edu | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 196 | the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 197 | Foundation; either version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||
| 198 | version. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||
| 201 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||
| 202 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||
| 205 | this program; if not, write to: | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | The Free Software Foundation, Inc., | ||||||||||||||||||||||||||||
| 208 | 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||
| 209 | Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | =cut | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | ############################################################################### | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | # THE CODE STARTS HERE | ||||||||||||||||||||||||||||
| 216 | ############################################################################### | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # ================================ | ||||||||||||||||||||||||||||
| 219 | # COMMAND LINE OPTIONS AND USAGE | ||||||||||||||||||||||||||||
| 220 | # ================================ | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 4 | ▶ | use UMLS::Interface; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 224 | 4 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 225 | # catch, abort and print the message for unknown options specified | ||||||||||||||||||||||||||||
| 226 | 4 | ▶ | eval(GetOptions( "version", "help", "username=s", "password=s", "hostname=s", "database=s", "socket=s", "config=s", "forcerun", "debug", "verbose", "debugpath=s", "cuilist=s", "realtime", "minimum", "maximum", "infile=s")) or die ("Please check the above mentioned option(s).\n"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | # if help is defined, print out help | ||||||||||||||||||||||||||||
| 230 | 4 | ▶ | if( defined $opt_help ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | 0 | $opt_help = 1; | |||||||||||||||||||||||||||
| 232 | 0 | &showHelp(); | |||||||||||||||||||||||||||
| 233 | 0 | exit; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | # if version is requested, show version | ||||||||||||||||||||||||||||
| 237 | 4 | ▶ | if( defined $opt_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 0 | $opt_version = 1; | |||||||||||||||||||||||||||
| 239 | 0 | &showVersion(); | |||||||||||||||||||||||||||
| 240 | 0 | exit; | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | # At least 1 CUI should be given on the command line. | ||||||||||||||||||||||||||||
| 244 | 4 | ▶ | if( (!defined $opt_infile) and (scalar(@ARGV) < 1) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $opt_infile and scalar @ARGV < 1
MC/DC50%1/2
not defined $opt_infile and scalar @ARGV < 1
not defined $opt_infile
scalar @ARGV < 1
Truth table66%2/3
not(A) and B
A= not defined $opt_infileB= scalar @ARGV < 1
| |||||||||||||||||||||||||||||
| 245 | 2 | print STDERR "No term was specified on the command line\n"; | |||||||||||||||||||||||||||
| 246 | 2 | &minimalUsageNotes(); | |||||||||||||||||||||||||||
| 247 | 0 | exit; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 2 | my $umls = ""; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 2 | my %option_hash = (); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 2 | ▶ | if(defined $opt_realtime) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | $option_hash{"realtime"} = $opt_realtime; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | 2 | ▶ | if(defined $opt_config) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 258 | 0 | $option_hash{"config"} = $opt_config; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | 2 | ▶ | if(defined $opt_forcerun) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 261 | 0 | $option_hash{"forcerun"} = $opt_forcerun; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | 2 | ▶ | if(defined $opt_debug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | $option_hash{"debug"} = $opt_debug; | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | 2 | ▶ | if(defined $opt_verbose) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 0 | $option_hash{"verbose"} = $opt_verbose; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | 2 | ▶ | if(defined $opt_debugpath) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 270 | 0 | $option_hash{"debugpath"} = $opt_debugpath; | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | 2 | ▶ | if(defined $opt_cuilist) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | 0 | $option_hash{"cuilist"} = $opt_cuilist; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | 2 | ▶ | if(defined $opt_username) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | $option_hash{"username"} = $opt_username; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 2 | ▶ | if(defined $opt_driver) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | $option_hash{"driver"} = $opt_driver; #"mysql"; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | 2 | ▶ | if(defined $opt_database) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | 0 | $option_hash{"database"} = $opt_database; | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | 2 | ▶ | if(defined $opt_password) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | 0 | $option_hash{"password"} = $opt_password; | |||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | 2 | ▶ | if(defined $opt_hostname) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 0 | $option_hash{"hostname"} = $opt_hostname; | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | 2 | ▶ | if(defined $opt_socket) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 0 | $option_hash{"socket"} = $opt_socket; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 2 | $umls = UMLS::Interface->new(\%option_hash); | |||||||||||||||||||||||||||
| 295 | 0 | ▶ | die "Unable to create UMLS::Interface object.\n" if(!$umls); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | # get the relations from the configuration file | ||||||||||||||||||||||||||||
| 298 | 0 | my $configrel = $umls->getRelString(); | |||||||||||||||||||||||||||
| 299 | 0 | $configrel=~/(REL) (\:\:) (include|exclude) (.*?)$/; | |||||||||||||||||||||||||||
| 300 | 0 | my $relationstring = $4; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | # check to make certain the configuration file only contains | ||||||||||||||||||||||||||||
| 303 | # heirarchical relations (PAR/CHD or RB/RN). | ||||||||||||||||||||||||||||
| 304 | 0 | my @relations = split/\s*\,\s*/, $relationstring; | |||||||||||||||||||||||||||
| 305 | 0 | foreach my $rel (@relations) { | |||||||||||||||||||||||||||
| 306 | 0 | ▶ | if(! ($rel=~/(PAR|CHD|RB|RN)/) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 0 | print STDERR "The findCuiDepth.pl program only supports heirarchical relations (PAR/CHD or RB/RN).\n"; | |||||||||||||||||||||||||||
| 308 | 0 | &minimalUsageNotes(); | |||||||||||||||||||||||||||
| 309 | 0 | exit; | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | 0 | my @inputarray = (); | |||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if(defined $opt_infile) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | open(FILE, $opt_infile) || die "Could not open infile : $opt_infile\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | while(<FILE>) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 0 | chomp; | |||||||||||||||||||||||||||
| 319 | 0 | $_=~s/^\s+//g; | |||||||||||||||||||||||||||
| 320 | 0 | $_=~s/\s+$//g; | |||||||||||||||||||||||||||
| 321 | 0 | push @inputarray, $_; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | else { | ||||||||||||||||||||||||||||
| 325 | 0 | my $input = shift; | |||||||||||||||||||||||||||
| 326 | 0 | push @inputarray, $input; | |||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||
| 329 | 0 | foreach my $input (@inputarray) { | |||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | if($input=~/^\s*$/) { next; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 0 | my $term = $input; | |||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||
| 335 | 0 | my @c = (); | |||||||||||||||||||||||||||
| 336 | 0 | ▶ | if($input=~/C[0-9]+/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 0 | push @{$c}, $input; | |||||||||||||||||||||||||||
| 338 | 0 | my $termlist = $umls->getTermList($input); | |||||||||||||||||||||||||||
| 339 | 0 | $term = shift @{$termlist}; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | else { | ||||||||||||||||||||||||||||
| 342 | 0 | $c = $umls->getConceptList($input); | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | my $printFlag = 0; | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 0 | foreach my $cui (@{$c}) { | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | # make certain cui exists in this view | ||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if(! ($umls->exists($cui)) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 0 | next; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | # get the minimum depth | ||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if(defined $opt_minimum) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 356 | 0 | my $min = $umls->findMinimumDepth($cui); | |||||||||||||||||||||||||||
| 357 | 0 | print "The minimum depth of $term ($cui) is $min\n"; | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | # get the maximum depth | ||||||||||||||||||||||||||||
| 360 | elsif(defined $opt_maximum) { | ||||||||||||||||||||||||||||
| 361 | 0 | my $max = $umls->findMaximumDepth($cui); | |||||||||||||||||||||||||||
| 362 | 0 | print "The maximum depth of $term ($cui) is $max\n"; | |||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | else { | ||||||||||||||||||||||||||||
| 365 | 0 | my $min = $umls->findMinimumDepth($cui); | |||||||||||||||||||||||||||
| 366 | 0 | print "The minimum depth of $term ($cui) is $min\n"; | |||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | 0 | my $max = $umls->findMaximumDepth($cui); | |||||||||||||||||||||||||||
| 369 | 0 | print "The maximum depth of $term ($cui) is $max\n"; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | $printFlag = 1; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if(! ($printFlag) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 376 | 0 | print "$input does not exist in this view of the UMLS.\n"; | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | ############################################################################## | ||||||||||||||||||||||||||||
| 381 | # function to output minimal usage notes | ||||||||||||||||||||||||||||
| 382 | ############################################################################## | ||||||||||||||||||||||||||||
| 383 | sub minimalUsageNotes { | ||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 2 | ▶ | print "Usage: findCuiDepth.pl [OPTIONS] [TERM|CUI] \n"; | ||||||||||||||||||||||||||
|
Subroutine
minimalUsageNotes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 386 | 2 | &askHelp(); | |||||||||||||||||||||||||||
| 387 | 2 | exit; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | ############################################################################## | ||||||||||||||||||||||||||||
| 391 | # function to output help messages for this program | ||||||||||||||||||||||||||||
| 392 | ############################################################################## | ||||||||||||||||||||||||||||
| 393 | sub showHelp() { | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | print "This is a utility that takes as input a CUI or a TERM\n"; | ||||||||||||||||||||||||||
|
Subroutine
showHelp: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 397 | 0 | print "and returns its minimum depth.\n\n"; | |||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 0 | print "Usage: findCuiDepth.pl [OPTIONS] [TERM|CUI]\n\n"; | |||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | 0 | print "Options:\n\n"; | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | print "--debug This option prints out the debug\n"; | |||||||||||||||||||||||||||
| 404 | 0 | print " information.\n\n"; | |||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 0 | print "--infile This option takes a list of CUIs or\n"; | |||||||||||||||||||||||||||
| 407 | 0 | print " TERMS and returns their depth. \n\n"; | |||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | print "--minimum Returns the minimum depth (DEFAULT)\n\n"; | |||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | print "--maximum Returns the maximum depth\n\n"; | |||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | print "--username STRING Username required to access mysql\n\n"; | |||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 0 | print "--password STRING Password required to access mysql\n\n"; | |||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | 0 | print "--hostname STRING Hostname for mysql (DEFAULT: localhost)\n\n"; | |||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | print "--database STRING Database contain UMLS (DEFAULT: umls)\n\n"; | |||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | print "--socket STRING Socket used by mysql (DEFAULT: /tmp.mysql.sock)\n\n"; | |||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 0 | print "--config FILE Configuration file\n\n"; | |||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 0 | print "--realtime This option will not create a database of the\n"; | |||||||||||||||||||||||||||
| 426 | 0 | print " path information for all of concepts but just\n"; | |||||||||||||||||||||||||||
| 427 | 0 | print " obtain the information for the input concept\n\n"; | |||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | print "--debug Sets the debug flag for testing.\n\n"; | |||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | 0 | print "--forcerun This option will bypass any command \n"; | |||||||||||||||||||||||||||
| 432 | 0 | print " prompts such as asking if you would \n"; | |||||||||||||||||||||||||||
| 433 | 0 | print " like to continue with the index \n"; | |||||||||||||||||||||||||||
| 434 | 0 | print " creation. \n\n"; | |||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | 0 | print "--debugpath FILE This option prints out the path\n"; | |||||||||||||||||||||||||||
| 437 | 0 | print " information for debugging purposes\n\n"; | |||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 0 | print "--verbose This option prints out the table \n"; | |||||||||||||||||||||||||||
| 440 | 0 | print " information to a file in your\n"; | |||||||||||||||||||||||||||
| 441 | 0 | print " specified config directory\n\n"; | |||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | 0 | print "--cuilist FILE This option takes in a file containing a \n"; | |||||||||||||||||||||||||||
| 444 | 0 | print " list of CUIs (one CUI per line) and stores\n"; | |||||||||||||||||||||||||||
| 445 | 0 | print " only the path information for those CUIs\n"; | |||||||||||||||||||||||||||
| 446 | 0 | print " rather than for all of the CUIs\n\n"; | |||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | 0 | print "--version Prints the version number\n\n"; | |||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 0 | print "--help Prints this help message.\n\n"; | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | ############################################################################## | ||||||||||||||||||||||||||||
| 454 | # function to output the version number | ||||||||||||||||||||||||||||
| 455 | ############################################################################## | ||||||||||||||||||||||||||||
| 456 | sub showVersion { | ||||||||||||||||||||||||||||
| 457 | 0 | ▶ | print '$Id: findCuiDepth.pl,v 1.16 2011/08/29 16:37:03 btmcinnes Exp $'; | ||||||||||||||||||||||||||
|
Subroutine
showVersion: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 458 | 0 | print "\nCopyright (c) 2008, Ted Pedersen & Bridget McInnes\n"; | |||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | ############################################################################## | ||||||||||||||||||||||||||||
| 462 | # function to output "ask for help" message when user's goofed | ||||||||||||||||||||||||||||
| 463 | ############################################################################## | ||||||||||||||||||||||||||||
| 464 | sub askHelp { | ||||||||||||||||||||||||||||
| 465 | 2 | ▶ | print STDERR "Type findCuiDepth.pl --help for help.\n"; | ||||||||||||||||||||||||||
|
Subroutine
askHelp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||