| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | getSts.pl - This program returns a concepts semantic type(s). | ||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | This program takes in a CUI or a TERM and returns its semantic type(s). | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | =head1 USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | Usage: getSts.pl [OPTIONS] [TERM|CUI] | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | =head1 INPUT | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =head2 Required Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head3 [TERM|CUI] | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | A Concept Unique Identifier (CUI) or a term from the Unified | ||||||||||||||||||||||||||||||||||||||||||
| 22 | Medical Language System (UMLS) | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | =head2 Optional Arguments: | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | =head3 --infile FILE | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | A file containing a list of concepts or terms. The format requires | ||||||||||||||||||||||||||||||||||||||||||
| 29 | a single concept and/or term per line. For example: | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | cui1 | ||||||||||||||||||||||||||||||||||||||||||
| 32 | term1 | ||||||||||||||||||||||||||||||||||||||||||
| 33 | cui2 | ||||||||||||||||||||||||||||||||||||||||||
| 34 | term2 | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ... | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =head3 --debug | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Sets the debug flag for testing | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | =head3 --username STRING | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | Username is required to access the umls database on MySql | ||||||||||||||||||||||||||||||||||||||||||
| 44 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | =head3 --password STRING | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | Password is required to access the umls database on MySql | ||||||||||||||||||||||||||||||||||||||||||
| 49 | unless it was specified in the my.cnf file at installation | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | =head3 --hostname STRING | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | Hostname where mysql is located. DEFAULT: localhost | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head3 --socket STRING | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | The socket your mysql is using. DEFAULT: /tmp/mysql.sock | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | =head3 --database STRING | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | Database contain UMLS DEFAULT: umls | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | =head4 --help | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | Displays the quick summary of program options. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | =head4 --version | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | Displays the version information. | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | =head1 OUTPUT | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | List of CUIs that are associated with the input term | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | =head1 SYSTEM REQUIREMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =item * Perl (version 5.8.5 or better) - http://www.perl.org | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | Copyright (c) 2007-2011, | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Bridget T. McInnes, University of Minnesota | ||||||||||||||||||||||||||||||||||||||||||
| 92 | bthomson at cs.umn.edu | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | Ted Pedersen, University of Minnesota Duluth | ||||||||||||||||||||||||||||||||||||||||||
| 95 | tpederse at d.umn.edu | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | Siddharth Patwardhan, University of Utah, Salt Lake City | ||||||||||||||||||||||||||||||||||||||||||
| 98 | sidd@cs.utah.edu | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | Serguei Pakhomov, University of Minnesota Twin Cities | ||||||||||||||||||||||||||||||||||||||||||
| 101 | pakh0002@umn.edu | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | This program is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 104 | the terms of the GNU General Public License as published by the Free Software | ||||||||||||||||||||||||||||||||||||||||||
| 105 | Foundation; either version 2 of the License, or (at your option) any later | ||||||||||||||||||||||||||||||||||||||||||
| 106 | version. | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||||||||||||||||||||||||||||||||||
| 109 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||||||||||||||||||||||||||||||||||
| 110 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | You should have received a copy of the GNU General Public License along with | ||||||||||||||||||||||||||||||||||||||||||
| 113 | this program; if not, write to: | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | The Free Software Foundation, Inc., | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 59 Temple Place - Suite 330, | ||||||||||||||||||||||||||||||||||||||||||
| 117 | Boston, MA 02111-1307, USA. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # THE CODE STARTS HERE | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | # ================================ | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # COMMAND LINE OPTIONS AND USAGE | ||||||||||||||||||||||||||||||||||||||||||
| 128 | # ================================ | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | use UMLS::Interface; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | use Getopt::Long; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 2 | ▶ | eval(GetOptions( "version", "help", "debug", "username=s", "password=s", "hostname=s", "database=s", "socket=s", "infile=s", "all", "sg")) or die ("Please check the above mentioned option(s).\n"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | # if help is defined, print out help | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 2 | ▶ | if( defined $opt_help ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $opt_help = 1; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | &showHelp(); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | # if version is requested, show version | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | ▶ | if( defined $opt_version ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $opt_version = 1; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | &showVersion(); | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | # At least 1 term or cui should be given on the command line. | ||||||||||||||||||||||||||||||||||||||||||
| 152 | # unless the infile option was specified | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | ▶ | if( !(defined $opt_infile) and !(defined $opt_all) and (scalar(@ARGV) < 1) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
not defined $opt_infile || defined $opt_all and scalar @ARGV < 1
defined $opt_infile || defined $opt_all
MC/DC0%0/3
not defined $opt_infile || defined $opt_all and scalar @ARGV < 1
defined $opt_infile
defined $opt_all
scalar @ARGV < 1
Truth table0%0/4
not(A || B) and C
A= defined $opt_infileB= defined $opt_allC= scalar @ARGV < 1
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | print STDERR "At least 1 term or CUI should be given on the \n"; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | print STDERR "command line or use the --infile option\n"; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 1 | &minimalUsageNotes(); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | my $umls = ""; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | my %option_hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | ▶ | if(defined $opt_verbose) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $option_hash{"verbose"} = $opt_verbose; | |||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | if(defined $opt_debug) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $option_hash{"debug"} = $opt_debug | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | if(defined $opt_username) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $option_hash{"username"} = $opt_username; | |||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | ▶ | if(defined $opt_driver) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $option_hash{"driver"} = $opt_driver; #mysql | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 1 | ▶ | if(defined $opt_database) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $option_hash{"database"} = $opt_database; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 1 | ▶ | if(defined $opt_password) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $option_hash{"password"} = $opt_password; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | if(defined $opt_hostname) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $option_hash{"hostname"} = $opt_hostname; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | if(defined $opt_socket) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $option_hash{"socket"} = $opt_socket; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1 | $option_hash{"t"} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 189 | 1 | $umls = UMLS::Interface->new(\%option_hash); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | die "Unable to create UMLS::Interface object.\n" if(!$umls); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if(defined $opt_all) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $sts = $umls->getAllSts(); | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | foreach my $st (@{$sts}) { | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $abr = $umls->getStAbr($st); | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $string = $umls->getStString($abr); | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | print " $string ($abr) ($st)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my @terms = (); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if(defined $opt_infile) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | open(INFILE, $opt_infile) || die "Could not open infile ($opt_infile)\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | while(<INFILE>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | push @terms, $_; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | } close INFILE; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $term = shift; | |||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | push @terms, $term; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if(defined $opt_sg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | foreach my $input (@terms) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $array = $umls->getStsFromSg($input); | |||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | print "The semantic types associated with $input : \n"; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | foreach my $abr (@{$array}) { | |||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | my $string = $umls->getStString($abr); | |||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | print " $string ($abr)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | foreach my $input (@terms) { | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | my $c = undef; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if($input=~/C[0-9]/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | push @{$c}, $input; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $ts = $umls->getTermList($input); | |||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | $term = shift @{$ts}; | |||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||
| 242 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $c = $umls->getConceptList($input); | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $printFlag = 0; | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | foreach my $cui (@{$c}) { | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | my $sts = $umls->getSt($cui); | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if($#{$sts} < 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | print "There are no semantic types associated with $term ($cui)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||
| 255 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | print "The semantic types associated with $term ($cui):\n"; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | foreach my $st (@{$sts}) { | |||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | my $abr = $umls->getStAbr($st); | |||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my $string = $umls->getStString($abr); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | print " $string ($abr)\n"; | |||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $printFlag = 1; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if(! ($printFlag) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | print "There are no semantic types associated with $input\n"; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 272 | # function to output minimal usage notes | ||||||||||||||||||||||||||||||||||||||||||
| 273 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 274 | sub minimalUsageNotes { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | 1 | ▶ | print "Usage: getSts.pl [OPTIONS] [TERM|CUI] \n"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
minimalUsageNotes: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | &askHelp(); | |||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | exit; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 282 | # function to output help messages for this program | ||||||||||||||||||||||||||||||||||||||||||
| 283 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 284 | sub showHelp() { | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | print "This is a utility that takes as input a TERM or\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
showHelp: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | print "a CUI and returns all of its semantic types.\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | print "Usage: getSts.pl [OPTIONS] [TERM|CUI]\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | print "Options:\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | print "--infile FILE A file containing a list of concepts \n"; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | print " or terms.\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | print "--debug Sets the debug flag for testing\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | print "--username STRING Username required to access mysql\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | print "--password STRING Password required to access mysql\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | print "--hostname STRING Hostname for mysql (DEFAULT: localhost)\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | print "--database STRING Database contain UMLS (DEFAULT: umls)\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | print "--socket STRING Socket used by mysql (DEFAULT: /tmp.mysql.sock)\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | print "--version Prints the version number\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | print "--help Prints this help message.\n\n"; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # function to output the version number | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 317 | sub showVersion { | ||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | print '$Id: getSts.pl,v 1.17 2016/07/11 16:36:48 btmcinnes Exp $'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
showVersion: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print "\nCopyright (c) 2011, Ted Pedersen & Bridget McInnes\n"; | |||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 323 | # function to output "ask for help" message when user's goofed | ||||||||||||||||||||||||||||||||||||||||||
| 324 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 325 | sub askHelp { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | ▶ | print STDERR "Type getSts.pl --help for help.\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
askHelp: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||