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