| 1 | #!/usr/bin/perl | ||||||||||
| 2 | |||||||||||
| 3 | =head1 NAME | ||||||||||
| 4 | |||||||||||
| 5 | removeConfigData.pl - This program removes the temporary table | ||||||||||
| 6 | and associated files that are created based on the configuration | ||||||||||
| 7 | file. | ||||||||||
| 8 | |||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||
| 10 | |||||||||||
| 11 | This program removes the temporary table and associated files that | ||||||||||
| 12 | are created based on the configuration file. | ||||||||||
| 13 | |||||||||||
| 14 | =head1 USAGE | ||||||||||
| 15 | |||||||||||
| 16 | Usage: removeConfigData.pl [OPTIONS] CONFIGFILE | ||||||||||
| 17 | |||||||||||
| 18 | =head1 INPUT | ||||||||||
| 19 | |||||||||||
| 20 | =head2 CONFIGFILE | ||||||||||
| 21 | |||||||||||
| 22 | This is the configuration file. The format of the configuration | ||||||||||
| 23 | file is as follows: | ||||||||||
| 24 | |||||||||||
| 25 | SAB :: <include|exclude> <source1, source2, ... sourceN> | ||||||||||
| 26 | |||||||||||
| 27 | REL :: <include|exclude> <relation1, relation2, ... relationN> | ||||||||||
| 28 | |||||||||||
| 29 | For example, if we wanted to use the MSH vocabulary with only | ||||||||||
| 30 | the RB/RN relations, the configuration file would be: | ||||||||||
| 31 | |||||||||||
| 32 | SAB :: include MSH | ||||||||||
| 33 | REL :: include RB, RN | ||||||||||
| 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 | =head2 Optional Arguments: | ||||||||||
| 45 | |||||||||||
| 46 | =head3 --debug | ||||||||||
| 47 | |||||||||||
| 48 | Sets the debug flag for testing | ||||||||||
| 49 | |||||||||||
| 50 | =head3 --username STRING | ||||||||||
| 51 | |||||||||||
| 52 | Username is required to access the umls database on MySql | ||||||||||
| 53 | unless it was specified in the my.cnf file at installation | ||||||||||
| 54 | |||||||||||
| 55 | =head3 --password STRING | ||||||||||
| 56 | |||||||||||
| 57 | Password is required to access the umls database on MySql | ||||||||||
| 58 | unless it was specified in the my.cnf file at installation | ||||||||||
| 59 | |||||||||||
| 60 | =head3 --hostname STRING | ||||||||||
| 61 | |||||||||||
| 62 | Hostname where mysql is located. DEFAULT: localhost | ||||||||||
| 63 | |||||||||||
| 64 | =head3 --socket STRING | ||||||||||
| 65 | |||||||||||
| 66 | The socket your mysql is using. DEFAULT: /tmp/mysql.sock | ||||||||||
| 67 | |||||||||||
| 68 | =head3 --database STRING | ||||||||||
| 69 | |||||||||||
| 70 | Database contain UMLS DEFAULT: umls | ||||||||||
| 71 | |||||||||||
| 72 | =head4 --help | ||||||||||
| 73 | |||||||||||
| 74 | Displays the quick summary of program options. | ||||||||||
| 75 | |||||||||||
| 76 | =head4 --version | ||||||||||
| 77 | |||||||||||
| 78 | Displays the version information. | ||||||||||
| 79 | |||||||||||
| 80 | =head1 OUTPUT | ||||||||||
| 81 | |||||||||||
| 82 | List of CUIs that are associated with the input term | ||||||||||
| 83 | |||||||||||
| 84 | =head1 SYSTEM REQUIREMENTS | ||||||||||
| 85 | |||||||||||
| 86 | =over | ||||||||||
| 87 | |||||||||||
| 88 | =item * Perl (version 5.8.5 or better) - http://www.perl.org | ||||||||||
| 89 | |||||||||||
| 90 | =back | ||||||||||
| 91 | |||||||||||
| 92 | =head1 AUTHOR | ||||||||||
| 93 | |||||||||||
| 94 | Bridget T. McInnes, University of Minnesota | ||||||||||
| 95 | |||||||||||
| 96 | =head1 COPYRIGHT | ||||||||||
| 97 | |||||||||||
| 98 | Copyright (c) 2007-2009, | ||||||||||
| 99 | |||||||||||
| 100 | Bridget T. McInnes, University of Minnesota | ||||||||||
| 101 | bthomson at cs.umn.edu | ||||||||||
| 102 | |||||||||||
| 103 | Ted Pedersen, University of Minnesota Duluth | ||||||||||
| 104 | tpederse at d.umn.edu | ||||||||||
| 105 | |||||||||||
| 106 | Siddharth Patwardhan, University of Utah, Salt Lake City | ||||||||||
| 107 | sidd@cs.utah.edu | ||||||||||
| 108 | |||||||||||
| 109 | Serguei Pakhomov, University of Minnesota Twin Cities | ||||||||||
| 110 | pakh0002@umn.edu | ||||||||||
| 111 | |||||||||||
| 112 | This program is free software; you can redistribute it and/or modify it under | ||||||||||
| 113 | the terms of the GNU General Public License as published by the Free Software | ||||||||||
| 114 | Foundation; either version 2 of the License, or (at your option) any later | ||||||||||
| 115 | version. | ||||||||||
| 116 | |||||||||||
| 117 | This program is distributed in the hope that it will be useful, but WITHOUT | ||||||||||
| 118 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||||||||||
| 119 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||||||||
| 120 | |||||||||||
| 121 | You should have received a copy of the GNU General Public License along with | ||||||||||
| 122 | this program; if not, write to: | ||||||||||
| 123 | |||||||||||
| 124 | The Free Software Foundation, Inc., | ||||||||||
| 125 | 59 Temple Place - Suite 330, | ||||||||||
| 126 | Boston, MA 02111-1307, USA. | ||||||||||
| 127 | |||||||||||
| 128 | =cut | ||||||||||
| 129 | |||||||||||
| 130 | ############################################################################### | ||||||||||
| 131 | |||||||||||
| 132 | # THE CODE STARTS HERE | ||||||||||
| 133 | ############################################################################### | ||||||||||
| 134 | |||||||||||
| 135 | # ================================ | ||||||||||
| 136 | # COMMAND LINE OPTIONS AND USAGE | ||||||||||
| 137 | # ================================ | ||||||||||
| 138 | |||||||||||
| 139 | |||||||||||
| 140 | 1 | ▶ | use UMLS::Interface; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 141 | 1 | ▶ | use Getopt::Long; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 142 | |||||||||||
| 143 | 1 | ▶ | eval(GetOptions( "version", "help", "debug", "username=s", "password=s", "hostname=s", "database=s", "socket=s")) or die ("Please check the above mentioned option(s).\n"); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 144 | |||||||||||
| 145 | |||||||||||
| 146 | # if help is defined, print out help | ||||||||||
| 147 | 1 | ▶ | if( defined $opt_help ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 0 | $opt_help = 1; | |||||||||
| 149 | 0 | &showHelp(); | |||||||||
| 150 | 0 | exit; | |||||||||
| 151 | } | ||||||||||
| 152 | |||||||||||
| 153 | # if version is requested, show version | ||||||||||
| 154 | 1 | ▶ | if( defined $opt_version ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 155 | 0 | $opt_version = 1; | |||||||||
| 156 | 0 | &showVersion(); | |||||||||
| 157 | 0 | exit; | |||||||||
| 158 | } | ||||||||||
| 159 | |||||||||||
| 160 | # At least 1 CUI should be given on the command line. | ||||||||||
| 161 | 1 | ▶ | if(scalar(@ARGV) < 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 162 | 1 | print STDERR "Configuration file was not specified on the command line\n"; | |||||||||
| 163 | 1 | &minimalUsageNotes(); | |||||||||
| 164 | 0 | exit; | |||||||||
| 165 | } | ||||||||||
| 166 | |||||||||||
| 167 | 0 | my $config = shift; | |||||||||
| 168 | |||||||||||
| 169 | 0 | my %option_hash = (); | |||||||||
| 170 | |||||||||||
| 171 | 0 | $option_hash{"config"} = $config; | |||||||||
| 172 | |||||||||||
| 173 | 0 | ▶ | if(defined $opt_debug) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 174 | 0 | $option_hash{"debug"} = $opt_debug; | |||||||||
| 175 | } | ||||||||||
| 176 | 0 | ▶ | if(defined $opt_username) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 177 | 0 | $option_hash{"username"} = $opt_username; | |||||||||
| 178 | } | ||||||||||
| 179 | 0 | ▶ | if(defined $opt_driver) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 180 | 0 | $option_hash{"driver"} = $opt_driver; | |||||||||
| 181 | } | ||||||||||
| 182 | 0 | ▶ | if(defined $opt_database) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 183 | 0 | $option_hash{"database"} = $opt_database; | |||||||||
| 184 | } | ||||||||||
| 185 | 0 | ▶ | if(defined $opt_password) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 186 | 0 | $option_hash{"password"} = $opt_password; | |||||||||
| 187 | } | ||||||||||
| 188 | 0 | ▶ | if(defined $opt_hostname) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 189 | 0 | $option_hash{"hostname"} = $opt_hostname; | |||||||||
| 190 | } | ||||||||||
| 191 | 0 | ▶ | if(defined $opt_socket) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 192 | 0 | $option_hash{"socket"} = $opt_socket; | |||||||||
| 193 | } | ||||||||||
| 194 | |||||||||||
| 195 | 0 | $umls = UMLS::Interface->new(\%option_hash); | |||||||||
| 196 | 0 | ▶ | die "Unable to create UMLS::Interface object.\n" if(!$umls); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 197 | |||||||||||
| 198 | 0 | $umls->dropConfigTable(); | |||||||||
| 199 | 0 | $umls->removeConfigFiles(); | |||||||||
| 200 | |||||||||||
| 201 | ############################################################################## | ||||||||||
| 202 | # function to output minimal usage notes | ||||||||||
| 203 | ############################################################################## | ||||||||||
| 204 | sub minimalUsageNotes { | ||||||||||
| 205 | |||||||||||
| 206 | 1 | ▶ | print "Usage: removeConfigData.pl [OPTIONS] CONFIGFILE \n"; | ||||||||
|
Subroutine
minimalUsageNotes: called CC=1 SCAR=0.0
| |||||||||||
| 207 | 1 | &askHelp(); | |||||||||
| 208 | 1 | exit; | |||||||||
| 209 | } | ||||||||||
| 210 | |||||||||||
| 211 | ############################################################################## | ||||||||||
| 212 | # function to output help messages for this program | ||||||||||
| 213 | ############################################################################## | ||||||||||
| 214 | sub showHelp() { | ||||||||||
| 215 | |||||||||||
| 216 | |||||||||||
| 217 | 0 | ▶ | print "This is a utility that removes the temporary database and \n"; | ||||||||
|
Subroutine
showHelp: not called CC=1 SCAR=6.9
| |||||||||||
| 218 | 0 | print "files associated with the configuration file information.\n\n"; | |||||||||
| 219 | |||||||||||
| 220 | 0 | print "Usage: removeConfigData.pl [OPTIONS] CONFIGFILE\n\n"; | |||||||||
| 221 | |||||||||||
| 222 | 0 | print "Options:\n\n"; | |||||||||
| 223 | |||||||||||
| 224 | 0 | print "--debug Sets the debug flag for testing\n\n"; | |||||||||
| 225 | |||||||||||
| 226 | 0 | print "--username STRING Username required to access mysql\n\n"; | |||||||||
| 227 | |||||||||||
| 228 | 0 | print "--password STRING Password required to access mysql\n\n"; | |||||||||
| 229 | |||||||||||
| 230 | 0 | print "--hostname STRING Hostname for mysql (DEFAULT: localhost)\n\n"; | |||||||||
| 231 | |||||||||||
| 232 | 0 | print "--database STRING Database contain UMLS (DEFAULT: umls)\n\n"; | |||||||||
| 233 | |||||||||||
| 234 | 0 | print "--socket STRING Socket used by mysql (DEFAULT: /tmp.mysql.sock)\n\n"; | |||||||||
| 235 | |||||||||||
| 236 | 0 | print "--version Prints the version number\n\n"; | |||||||||
| 237 | |||||||||||
| 238 | 0 | print "--help Prints this help message.\n\n"; | |||||||||
| 239 | } | ||||||||||
| 240 | |||||||||||
| 241 | ############################################################################## | ||||||||||
| 242 | # function to output the version number | ||||||||||
| 243 | ############################################################################## | ||||||||||
| 244 | sub showVersion { | ||||||||||
| 245 | 0 | ▶ | print '$Id: removeConfigData.pl,v 1.6 2011/08/29 16:37:03 btmcinnes Exp $'; | ||||||||
|
Subroutine
showVersion: not called CC=1 SCAR=6.9
| |||||||||||
| 246 | 0 | print "\nCopyright (c) 2008, Ted Pedersen & Bridget McInnes\n"; | |||||||||
| 247 | } | ||||||||||
| 248 | |||||||||||
| 249 | ############################################################################## | ||||||||||
| 250 | # function to output "ask for help" message when user's goofed | ||||||||||
| 251 | ############################################################################## | ||||||||||
| 252 | sub askHelp { | ||||||||||
| 253 | 1 | ▶ | print STDERR "Type removeConfigData.pl --help for help.\n"; | ||||||||
|
Subroutine
askHelp: called CC=1 SCAR=0.0
| |||||||||||
| 254 | } | ||||||||||
| 255 | |||||||||||