| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | getCuiList.pl - This program returns a list of CUIs based on the configuration | ||||||||||||||||||||||||||||
| 6 | file. | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | This program returns a list of CUIs based on the sources and relations | ||||||||||||||||||||||||||||
| 11 | specified in the configuration file. | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 USAGE | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Usage: getCuiList.pl [OPTIONS] CONFIGFILE | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 INPUT | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head2 CONFIGFILE | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | This is the configuration file. The format of the configuration | ||||||||||||||||||||||||||||
| 22 | file is as follows: | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | SAB :: <include|exclude> <source1, source2, ... sourceN> | ||||||||||||||||||||||||||||
| 25 | REL :: <include|exclude> <relation1, relation2, ... relationN> | ||||||||||||||||||||||||||||
| 26 | RELA :: <include|exclude> <rela1, rela2, .... relaN> (optional) | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | For example, if we wanted to use the MSH vocabulary with only | ||||||||||||||||||||||||||||
| 29 | the RB/RN relations, the configuration file would be: | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 32 | REL :: include RB, RN | ||||||||||||||||||||||||||||
| 33 | RELA :: include inverse_isa, isa | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | or | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | SAB :: include MSH | ||||||||||||||||||||||||||||
| 38 | REL :: exclude PAR, CHD | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | If you go to the configuration file directory, there will | ||||||||||||||||||||||||||||
| 41 | be example configuration files for the different runs that | ||||||||||||||||||||||||||||
| 42 | you have performed. | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =head1 OUTPUT | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | List of CUIs that are associated with the input term | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =head1 OPTIONAL ARGUMENTS: | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =head2 --children | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | Returns the number of children of a given CUI. The format for just using | ||||||||||||||||||||||||||||
| 53 | --children is: | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | CUI children | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =head2 --parents | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Returns the number of children of a given CUI. The format for just using | ||||||||||||||||||||||||||||
| 60 | --parents is: | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | CUI parents | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | The format for using both --parents and --children is: | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | CUI children|parents | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =head2 --relations REL | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | Returns the number of relations of a given CUI. The REL input can be | ||||||||||||||||||||||||||||
| 71 | a list of comma seperated relations. For example: | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | --relation "SIB,RO" | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | This would return the number of SIB and RO relations for a given concept | ||||||||||||||||||||||||||||
| 76 | in the format : CUI sib|ro | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | This option current can not be used with the --children and --parent | ||||||||||||||||||||||||||||
| 79 | option because if you want them just add them to the list. For example: | ||||||||||||||||||||||||||||
| 80 | --relation "SIB,PAR,CHD" | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head2 --term | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Returns the terms associated with the CUI in the following format: | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | CUI term1|term2|term3|... | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | If used with the --parents and/or --children options or the --relation | ||||||||||||||||||||||||||||
| 89 | options, the following format is returned: | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | CUI children|parents|term1|term2|... | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Remember children and parents is a number! | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head2 --st <semantic type abbreviation> | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Returns only those CUIs with the specified semantic type | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | =head2 --sg <semantic group name> | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | Returns only those CUIs with the specified semantic group | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =head2 --debug | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | Sets the debug flag for testing | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =head2 --username STRING | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Username is required to access the umls database on MySql | ||||||||||||||||||||||||||||
| 110 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | =head2 --password STRING | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | Password is required to access the umls database on MySql | ||||||||||||||||||||||||||||
| 115 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head2 --hostname STRING | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Hostname where mysql is located. DEFAULT: localhost | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head2 --socket STRING | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | The socket your mysql is using. DEFAULT: /tmp/mysql.sock | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head2 --database STRING | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | Database contain UMLS DEFAULT: umls | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | =head2 --help | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | Displays the quick summary of program options. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head2 --version | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | Displays the version information. | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =head1 SYSTEM REQUIREMENTS | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =over | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item * Perl (version 5.8.5 or better) - http://www.perl.org | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =back | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | Copyright (c) 2007-2011, | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||
| 154 | bthomson at cs.umn.edu | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | Ted Pedersen, University of Minnesota Duluth | ||||||||||||||||||||||||||||
| 157 | tpederse at d.umn.edu | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | Serguei Pakhomov, University of Minnesota Twin Cities | ||||||||||||||||||||||||||||
| 160 | pakh0002@umn.edu | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 163 | the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||
| 164 | Foundation; either version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||
| 165 | version. | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||
| 168 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||
| 169 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||
| 172 | this program; if not, write to: | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | The Free Software Foundation, Inc., | ||||||||||||||||||||||||||||
| 175 | 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||
| 176 | Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | =cut | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | ############################################################################### | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # THE CODE STARTS HERE | ||||||||||||||||||||||||||||
| 183 | ############################################################################### | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # ================================ | ||||||||||||||||||||||||||||
| 186 | # COMMAND LINE OPTIONS AND USAGE | ||||||||||||||||||||||||||||
| 187 | # ================================ | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 1 | ▶ | use UMLS::Interface; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 191 | 1 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 1 | ▶ | eval(GetOptions( "version", "help", "debug", "username=s", "password=s", "hostname=s", "database=s", "socket=s", "term", "st=s", "sg=s", "relations=s", "children", "parents")) or die ("Please check the above mentioned option(s).\n"); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | # if help is defined, print out help | ||||||||||||||||||||||||||||
| 197 | 1 | ▶ | if( defined $opt_help ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 198 | 0 | $opt_help = 1; | |||||||||||||||||||||||||||
| 199 | 0 | &showHelp(); | |||||||||||||||||||||||||||
| 200 | 0 | exit; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | # if version is requested, show version | ||||||||||||||||||||||||||||
| 204 | 1 | ▶ | if( defined $opt_version ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | 0 | $opt_version = 1; | |||||||||||||||||||||||||||
| 206 | 0 | &showVersion(); | |||||||||||||||||||||||||||
| 207 | 0 | exit; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # At least 1 CUI should be given on the command line. | ||||||||||||||||||||||||||||
| 211 | 1 | ▶ | if(scalar(@ARGV) < 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 212 | 1 | print STDERR "Configuration file was not specified on the command line\n"; | |||||||||||||||||||||||||||
| 213 | 1 | &minimalUsageNotes(); | |||||||||||||||||||||||||||
| 214 | 0 | exit; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if(defined $opt_relations && $opt_children) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opt_relations and $opt_children
MC/DC0%0/2
defined $opt_relations and $opt_children
defined $opt_relations
$opt_children
Truth table0%0/3
A and B
A= defined $opt_relationsB= $opt_children
| |||||||||||||||||||||||||||||
| 218 | 0 | print STDERR "The --relation and --children option can not be used\n"; | |||||||||||||||||||||||||||
| 219 | 0 | print STDERR "together. Just add CHD to your relations. For example:\n"; | |||||||||||||||||||||||||||
| 220 | 0 | print STDERR " --relations \"SIB,PAR,CHD\"\n"; | |||||||||||||||||||||||||||
| 221 | 0 | &minimalUsageNotes(); | |||||||||||||||||||||||||||
| 222 | 0 | exit; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | ▶ | if(defined $opt_relations && $opt_parents) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opt_relations and $opt_parents
MC/DC0%0/2
defined $opt_relations and $opt_parents
defined $opt_relations
$opt_parents
Truth table0%0/3
A and B
A= defined $opt_relationsB= $opt_parents
| |||||||||||||||||||||||||||||
| 226 | 0 | print STDERR "The --relation and --parents option can not be used\n"; | |||||||||||||||||||||||||||
| 227 | 0 | print STDERR "together. Just add CHD to your relations. For example:\n"; | |||||||||||||||||||||||||||
| 228 | 0 | print STDERR " --relations \"SIB,PAR,CHD\"\n"; | |||||||||||||||||||||||||||
| 229 | 0 | &minimalUsageNotes(); | |||||||||||||||||||||||||||
| 230 | 0 | exit; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | my $config = shift; | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | my %option_hash = (); | |||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | $option_hash{"config"} = $config; | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if(defined $opt_debug) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | $option_hash{"debug"} = $opt_debug; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | 0 | ▶ | if(defined $opt_username) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 0 | $option_hash{"username"} = $opt_username; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if(defined $opt_driver) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | $option_hash{"driver"} = $opt_driver; | |||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if(defined $opt_database) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | $option_hash{"database"} = $opt_database; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if(defined $opt_password) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | $option_hash{"password"} = $opt_password; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | 0 | ▶ | if(defined $opt_hostname) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | $option_hash{"hostname"} = $opt_hostname; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if(defined $opt_socket) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | $option_hash{"socket"} = $opt_socket; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | $umls = UMLS::Interface->new(\%option_hash); | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | die "Unable to create UMLS::Interface object.\n" if(!$umls); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 0 | my $hashref = $umls->getCuiList(); | |||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | foreach my $cui (sort keys %{$hashref}) { | |||||||||||||||||||||||||||
| 268 | # flag to determine whether the cui is to be printed | ||||||||||||||||||||||||||||
| 269 | 0 | my $flag = 1; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | # if --st, check to make certain the cui is of the | ||||||||||||||||||||||||||||
| 272 | # appropriate semantic type | ||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if(defined $opt_st) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 0 | $flag = 0; | |||||||||||||||||||||||||||
| 275 | 0 | my $sts = $umls->getSt($cui); | |||||||||||||||||||||||||||
| 276 | 0 | foreach my $st (@{$sts}) { | |||||||||||||||||||||||||||
| 277 | 0 | my $abbrev = $umls->getStAbr($st); | |||||||||||||||||||||||||||
| 278 | 0 | ▶ | if($abbrev eq $opt_st) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | 0 | $flag = 1; | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | # if --sg, check to make certain the cui is of the | ||||||||||||||||||||||||||||
| 285 | # appropriate semantic group | ||||||||||||||||||||||||||||
| 286 | 0 | ▶ | if(defined $opt_sg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 287 | 0 | $flag = 0; | |||||||||||||||||||||||||||
| 288 | 0 | my $sgs = $umls->getSemanticGroup($cui); | |||||||||||||||||||||||||||
| 289 | 0 | foreach my $sg (@{$sgs}) { | |||||||||||||||||||||||||||
| 290 | 0 | ▶ | if($sg eq $opt_sg) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 291 | 0 | $flag = 1; | |||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if($flag == 0) { next; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 0 | my @output = (); | |||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||
| 300 | 0 | ▶ | if(defined $opt_term) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | $terms = $umls->getTermList($cui); | |||||||||||||||||||||||||||
| 302 | 0 | @output = @{$terms}; | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | if(defined $opt_parents) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | 0 | my $array = $umls->getParents($cui); | |||||||||||||||||||||||||||
| 307 | 0 | my $parents = $#{$array} + 1; | |||||||||||||||||||||||||||
| 308 | 0 | unshift @output, $parents; | |||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if(defined $opt_children) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 0 | my $array = $umls->getChildren($cui); | |||||||||||||||||||||||||||
| 313 | 0 | my $children = $#{$array} + 1; | |||||||||||||||||||||||||||
| 314 | 0 | unshift @output, $children; | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | ▶ | if(defined $opt_relations) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 318 | 0 | my @relations = split/\,/, $opt_relations; | |||||||||||||||||||||||||||
| 319 | 0 | foreach my $relation (reverse @relations) { | |||||||||||||||||||||||||||
| 320 | 0 | my $array = $umls->getRelated($cui, $relation); | |||||||||||||||||||||||||||
| 321 | 0 | my $rel = $#{$array}+1; | |||||||||||||||||||||||||||
| 322 | 0 | unshift @output, $rel; | |||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if($#output >= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 0 | my $outputstring = join "|", @output; | |||||||||||||||||||||||||||
| 328 | 0 | print "$cui $outputstring\n"; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | else { | ||||||||||||||||||||||||||||
| 331 | 0 | print "$cui\n"; | |||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | ############################################################################## | ||||||||||||||||||||||||||||
| 337 | # function to output minimal usage notes | ||||||||||||||||||||||||||||
| 338 | ############################################################################## | ||||||||||||||||||||||||||||
| 339 | sub minimalUsageNotes { | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 1 | ▶ | print "Usage: getCuiList.pl [OPTIONS] CONFIGFILE\n"; | ||||||||||||||||||||||||||
|
Subroutine
minimalUsageNotes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 342 | 1 | &askHelp(); | |||||||||||||||||||||||||||
| 343 | 1 | exit; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | ############################################################################## | ||||||||||||||||||||||||||||
| 347 | # function to output help messages for this program | ||||||||||||||||||||||||||||
| 348 | ############################################################################## | ||||||||||||||||||||||||||||
| 349 | sub showHelp() { | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | 0 | ▶ | print "This is a utility returns all the CUIs associated with a\n"; | ||||||||||||||||||||||||||
|
Subroutine
showHelp: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 353 | 0 | print "configuration file.\n\n"; | |||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 0 | print "Usage: getCuiList.pl [OPTIONS] CONFIGFILE\n\n"; | |||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 0 | print "Options:\n\n"; | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 0 | print "--term Returns CUIs associated terms\n\n"; | |||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | 0 | print "--parents Returns number of CUIs parents\n\n"; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | print "--children Returns number of CUIs children\n\n"; | |||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 0 | print "--relations RELs Returns the number of CUIs relations\n\n"; | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 0 | print "--st <semantic type> Returns CUIs with specified semantic\n"; | |||||||||||||||||||||||||||
| 368 | 0 | print " type\n\n"; | |||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | print "--sg <semantic group> Returns CUIs with specified semantic\n"; | |||||||||||||||||||||||||||
| 371 | 0 | print " group\n\n"; | |||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 0 | print "--debug Sets the debug flag for testing\n\n"; | |||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | 0 | print "--username STRING Username required to access mysql\n\n"; | |||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 0 | print "--password STRING Password required to access mysql\n\n"; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | print "--hostname STRING Hostname for mysql (DEFAULT: localhost)\n\n"; | |||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 0 | print "--database STRING Database contain UMLS (DEFAULT: umls)\n\n"; | |||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | 0 | print "--socket STRING Socket used by mysql (DEFAULT: /tmp.mysql.sock)\n\n"; | |||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | print "--version Prints the version number\n\n"; | |||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | 0 | print "--help Prints this help message.\n\n"; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | ############################################################################## | ||||||||||||||||||||||||||||
| 391 | # function to output the version number | ||||||||||||||||||||||||||||
| 392 | ############################################################################## | ||||||||||||||||||||||||||||
| 393 | sub showVersion { | ||||||||||||||||||||||||||||
| 394 | 0 | ▶ | print '$Id: getCuiList.pl,v 1.10 2011/11/02 13:52:58 btmcinnes Exp $'; | ||||||||||||||||||||||||||
|
Subroutine
showVersion: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 395 | 0 | print "\nCopyright (c) 2008, Ted Pedersen & Bridget McInnes\n"; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | ############################################################################## | ||||||||||||||||||||||||||||
| 399 | # function to output "ask for help" message when user's goofed | ||||||||||||||||||||||||||||
| 400 | ############################################################################## | ||||||||||||||||||||||||||||
| 401 | sub askHelp { | ||||||||||||||||||||||||||||
| 402 | 1 | ▶ | print STDERR "Type getCuiList.pl --help for help.\n"; | ||||||||||||||||||||||||||
|
Subroutine
askHelp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||