| 1 |
|
| |
| 2 |
|
| =head1 NAME |
| 3 |
|
| |
| 4 |
|
| WebService::UMLSKS::DisplayInfo - Display the required information like definitions, CUI about the input term. |
| 5 |
|
| |
| 6 |
|
| =head1 SYNOPSIS |
| 7 |
|
| |
| 8 |
|
| =head2 Basic Usage |
| 9 |
|
| |
| 10 |
|
| use WebService::UMLSKS::DisplayInfo; |
| 11 |
|
| use WebService::UMLSKS::Query; |
| 12 |
|
| |
| 13 |
|
| my $display_obj = new DisplayInfo; |
| 14 |
|
| my $query = new Query; |
| 15 |
|
| |
| 16 |
|
| my $object_ref = $query->runQuery($service, $qterm, 'getConceptProperties', {params}); |
| 17 |
|
| # object_ref is a hash reference returned by web service getConceptProperties. |
| 18 |
|
| my $object_f = $display_obj->display_object($object_ref); |
| 19 |
|
| |
| 20 |
|
| |
| 21 |
|
| =head1 DESCRIPTION |
| 22 |
|
| |
| 23 |
|
| This module has package DisplayInfo which has subroutines 'new', format _object, format_scalar, format_homogenous_hash, format_homogenous_array and extract_object_class. |
| 24 |
|
| This module displays required information about the concept. |
| 25 |
|
| |
| 26 |
|
| =head1 SUBROUTINES |
| 27 |
|
| |
| 28 |
|
| The subroutines are as follows: |
| 29 |
|
| |
| 30 |
|
| =cut |
| 31 |
|
| |
| 32 |
|
| ############################################################################### |
| 33 |
|
| ########## CODE STARTS HERE ################################################# |
| 34 |
|
| |
| 35 |
|
| |
| 36 |
|
| use strict; |
| 37 |
|
| use SOAP::Lite; |
| 38 |
|
| use warnings; |
| 39 |
|
| no warnings qw/redefine/; |
| 40 |
|
| |
| 41 |
|
| |
| 42 |
|
| package WebService::UMLSKS::DisplayInfo; |
| 43 |
|
| |
| 44 |
|
| my $indentation = 0; |
| 45 |
|
| |
| 46 |
|
| =head2 new |
| 47 |
|
| |
| 48 |
|
| This sub creates a new object of DisplayInfo. |
| 49 |
|
| |
| 50 |
|
| =cut |
| 51 |
|
| |
| 52 |
|
| sub new { |
| 53 |
|
| my $class = shift; |
| 54 |
|
| my $self = {}; |
| 55 |
|
| #print "in new in display_info"; |
| 56 |
|
| bless( $self, $class ); |
| 57 |
|
| return $self; |
| 58 |
|
| } |
| 59 |
|
| |
| 60 |
|
| =head2 display_object |
| 61 |
|
| |
| 62 |
|
| This sub calls format_object. |
| 63 |
|
| |
| 64 |
|
| =cut |
| 65 |
|
| |
| 66 |
|
| |
| 67 |
|
| |
| 68 |
|
| sub display_object { |
| 69 |
|
| my $self = shift; |
| 70 |
|
| my $object_refr = shift; |
| 71 |
|
| my $return_ref = format_object ($object_refr); |
| 72 |
|
| #print "\n array : @t"; |
| 73 |
|
| return $return_ref; |
| 74 |
|
| } |
| 75 |
|
| |
| 76 |
|
| # This sub formats the structures returned by the web service. It calls |
| 77 |
|
| # the appropriate subroutines depending on the type of structure |
| 78 |
|
| # it is called with. If the input reference is a hash reference it calls |
| 79 |
|
| # format_homogenous_hash method. If input is array reference, |
| 80 |
|
| # it calls format homogenous array and simillarly for scalar input |
| 81 |
|
| # reference it calls format_scalar. |
| 82 |
|
| |
| 83 |
|
| |
| 84 |
|
| =head2 format_object |
| 85 |
|
| |
| 86 |
|
| This sub calls appropriate formatting sub. |
| 87 |
|
| |
| 88 |
|
| =cut |
| 89 |
|
| |
| 90 |
|
| sub format_object { |
| 91 |
|
| |
| 92 |
|
| my $object_ref = shift; |
| 93 |
|
| |
| 94 |
|
| #print "in format object"; |
| 95 |
|
| |
| 96 |
|
| unless ( defined $object_ref ) { |
| 97 |
|
| return 'undefined'; |
| 98 |
|
| } |
| 99 |
|
| else { |
| 100 |
|
| if ( $object_ref =~ /HASH/o ) { |
| 101 |
|
| return format_homogeneous_hash($object_ref); |
| 102 |
|
| } |
| 103 |
|
| elsif ( $object_ref =~ /ARRAY/o ) { |
| 104 |
|
| return format_homogeneous_array($object_ref); |
| 105 |
|
| } |
| 106 |
|
| elsif ( $object_ref =~ /SCALAR/o ) { |
| 107 |
|
| return format_scalar($object_ref); |
| 108 |
|
| } |
| 109 |
|
| elsif ( defined $object_ref ) { |
| 110 |
|
| return $object_ref; |
| 111 |
|
| } |
| 112 |
|
| else { |
| 113 |
|
| return 'term is not present'; |
| 114 |
|
| } |
| 115 |
|
| } |
| 116 |
|
| } |
| 117 |
|
| |
| 118 |
|
| |
| 119 |
|
| =head2 format_scalar |
| 120 |
|
| |
| 121 |
|
| This sub formats scalar object. |
| 122 |
|
| |
| 123 |
|
| =cut |
| 124 |
|
| |
| 125 |
|
| sub format_scalar { |
| 126 |
|
| |
| 127 |
|
| my $scalar_ref = shift; |
| 128 |
|
| #print "in format_scalar"; |
| 129 |
|
| print $$scalar_ref; |
| 130 |
|
| return format_object($$scalar_ref); |
| 131 |
|
| |
| 132 |
|
| } |
| 133 |
|
| |
| 134 |
|
| |
| 135 |
|
| |
| 136 |
|
| =head2 indent |
| 137 |
|
| |
| 138 |
|
| This sub is used for indentation. |
| 139 |
|
| |
| 140 |
|
| =cut |
| 141 |
|
| |
| 142 |
|
| sub indent { |
| 143 |
|
| |
| 144 |
|
| #print "\n"; |
| 145 |
|
| my $number = shift; |
| 146 |
|
| my $i; |
| 147 |
|
| for ( $i = 0 ; $i < $number ; $i++ ) { |
| 148 |
|
| print " "; |
| 149 |
|
| } |
| 150 |
|
| |
| 151 |
|
| } |
| 152 |
|
| |
| 153 |
|
| |
| 154 |
|
| =head2 format_homogeneous_hash |
| 155 |
|
| |
| 156 |
|
| This sub formats hash. |
| 157 |
|
| |
| 158 |
|
| =cut |
| 159 |
|
| |
| 160 |
|
| sub format_homogeneous_hash { |
| 161 |
|
| $indentation++; |
| 162 |
|
| my $hash_ref = shift; |
| 163 |
|
| #print "in format_hash"; |
| 164 |
|
| my @incl_rows = (); |
| 165 |
|
| |
| 166 |
|
| #print "\n"; |
| 167 |
|
| indent($indentation); |
| 168 |
|
| |
| 169 |
|
| #print "hash{"; |
| 170 |
|
| foreach my $att ( keys %$hash_ref ) { #---- removed rels |
| 171 |
|
| |
| 172 |
|
| |
| 173 |
|
| #Follwing regular expression is used to display just the required information. |
| 174 |
|
| if ( $att =~ |
| 175 |
|
| /\bqueryInput\b|\brelease\b|\bkey\b|\bempty\b|\bperformance\b|\bperformanceMode\b|\bRAs\b|\bCAs\b|\bSTYs\b|\bdefs\b|\bConcept\b|\bterms\b|\bSGs\b|\bCOCs\b|\bCXTs\b|\bcontentClass\b|\bcontentClassName\b|\bSATUI\b|\bDefinition\b|\bAUI\b|\bATUI\b|\bcontents\b|\brels\b/ |
| 176 |
|
| ) |
| 177 |
|
| { |
| 178 |
|
| |
| 179 |
|
| } |
| 180 |
|
| else { #---------------------------------------------------------- |
| 181 |
|
| |
| 182 |
|
| if ( $att =~ /\brel\b/ && $hash_ref->{$att} =~ /RO|SIB/ ) { |
| 183 |
|
| if ( |
| 184 |
|
| $att =~ /CUI|RUI|type|CN|autoGen|SRUI|directionality|relA/ ) |
| 185 |
|
| { |
| 186 |
|
| |
| 187 |
|
| } |
| 188 |
|
| } |
| 189 |
|
| elsif($att !~ /\bCUI\b/) { |
| 190 |
|
| |
| 191 |
|
| print "\n"; |
| 192 |
|
| indent($indentation); |
| 193 |
|
| if ( $att =~ /CN/ ) { |
| 194 |
|
| print "Preferred Term"; |
| 195 |
|
| } |
| 196 |
|
| else { |
| 197 |
|
| |
| 198 |
|
| print $att; |
| 199 |
|
| } |
| 200 |
|
| print ":"; |
| 201 |
|
| |
| 202 |
|
| print $hash_ref->{$att}; |
| 203 |
|
| |
| 204 |
|
| } |
| 205 |
|
| } |
| 206 |
|
| |
| 207 |
|
| |
| 208 |
|
| #---added rels,relation and relsources |
| 209 |
|
| #Follwing regular expression is used to display just the required information. |
| 210 |
|
| if ( $att =~ |
| 211 |
|
| /contents|CUI|CN|defs|Concept|rels|Relation|relSources/ ) |
| 212 |
|
| { |
| 213 |
|
| if ( $att =~ /defs/ ) { |
| 214 |
|
| my $def_ref = $hash_ref->{$att}; |
| 215 |
|
| |
| 216 |
|
| my $contents_def_ref = $def_ref->{"contents"}; |
| 217 |
|
| if ( !@$contents_def_ref ) { |
| 218 |
|
| |
| 219 |
|
| # if content_ref is empty |
| 220 |
|
| |
| 221 |
|
| print |
| 222 |
|
| "\n\tThere are no definitions available for your query term/CUI in UMLS using current configuaration."; |
| 223 |
|
| |
| 224 |
|
| } |
| 225 |
|
| } |
| 226 |
|
| |
| 227 |
|
| push @incl_rows, $att, format_object( $hash_ref->{$att} ); |
| 228 |
|
| } |
| 229 |
|
| |
| 230 |
|
| |
| 231 |
|
| |
| 232 |
|
| } |
| 233 |
|
| |
| 234 |
|
| #print "};"; |
| 235 |
|
| $indentation--; |
| 236 |
|
| |
| 237 |
|
| #my $bgcolor = $BGCOLOR{extract_object_class($hash_ref) || 'HASH'}; |
| 238 |
|
| #my $incl_table = $q->table({border => 1, bgcolor => $bgcolor}, @incl_rows); |
| 239 |
|
| return @incl_rows; |
| 240 |
|
| } |
| 241 |
|
| |
| 242 |
|
| |
| 243 |
|
| |
| 244 |
|
| =head2 format_homogeneous_array |
| 245 |
|
| |
| 246 |
|
| This sub formats array. |
| 247 |
|
| |
| 248 |
|
| =cut |
| 249 |
|
| |
| 250 |
|
| sub format_homogeneous_array { |
| 251 |
|
| $indentation++; |
| 252 |
|
| my $array_ref = shift; |
| 253 |
|
| #print "in format_array"; |
| 254 |
|
| my @incl_rows = (); |
| 255 |
|
| |
| 256 |
|
| #print "\n"; |
| 257 |
|
| indent($indentation); |
| 258 |
|
| |
| 259 |
|
| #print "array("; |
| 260 |
|
| foreach my $val (@$array_ref) { |
| 261 |
|
| |
| 262 |
|
| if ( $val =~ /contents|Definition|Concept/ ) { |
| 263 |
|
| if ( $val =~ /contents/) |
| 264 |
|
| { |
| 265 |
|
| |
| 266 |
|
| } |
| 267 |
|
| } |
| 268 |
|
| else { |
| 269 |
|
| if ( $val =~ /Definition|defs/ ) { |
| 270 |
|
| if ( !@$array_ref ) { |
| 271 |
|
| print "There is no $val information for this query"; |
| 272 |
|
| } |
| 273 |
|
| } |
| 274 |
|
| |
| 275 |
|
| #indent($indentation); |
| 276 |
|
| print "\n"; |
| 277 |
|
| indent($indentation); |
| 278 |
|
| print $val; |
| 279 |
|
| } |
| 280 |
|
| push @incl_rows, format_object($val); |
| 281 |
|
| |
| 282 |
|
| } |
| 283 |
|
| |
| 284 |
|
| #print ");"; |
| 285 |
|
| $indentation--; |
| 286 |
|
| @incl_rows = ('no values') unless @incl_rows; |
| 287 |
|
| |
| 288 |
|
| #my $bgcolor = $BGCOLOR{extract_object_class($array_ref) || 'ARRAY'}; |
| 289 |
|
| #my $incl_table = $q->table({border => 1, bgcolor => $bgcolor}, @incl_rows); |
| 290 |
|
| return @incl_rows; |
| 291 |
|
| } |
| 292 |
|
| |
| 293 |
|
| |
| 294 |
|
| |
| 295 |
|
| =head2 extract_object_class |
| 296 |
|
| |
| 297 |
|
| This sub is used to remove exact reference to object. |
| 298 |
|
| |
| 299 |
|
| =cut |
| 300 |
|
| |
| 301 |
|
| sub extract_object_class { |
| 302 |
|
| my $object_ref = shift; |
| 303 |
|
| |
| 304 |
|
| # remove exact reference |
| 305 |
|
| $object_ref =~ s/\(0x[\d\w]+\)$//o; |
| 306 |
|
| |
| 307 |
|
| my ( $class, $type ) = split /=/, $object_ref; |
| 308 |
|
| |
| 309 |
|
| my $res = undef; |
| 310 |
|
| if ($type) { |
| 311 |
|
| $res = $class; |
| 312 |
|
| } |
| 313 |
|
| else { |
| 314 |
|
| $res = $object_ref; |
| 315 |
|
| } |
| 316 |
|
| |
| 317 |
|
| return $res; |
| 318 |
|
| } |
| 319 |
|
| |
| 320 |
|
| |
| 321 |
|
| |
| 322 |
|
| #-------------------------------PERLDOC STARTS HERE------------------------------------------------------------- |
| 323 |
|
| |
| 324 |
|
| |
| 325 |
|
| |
| 326 |
|
| =head1 SEE ALSO |
| 327 |
|
| |
| 328 |
|
| ValidateTerm.pm GetUserData.pm Query.pm ws-getUMLSInfo.pl |
| 329 |
|
| |
| 330 |
|
| =cut |
| 331 |
|
| |
| 332 |
|
| =head1 AUTHORS |
| 333 |
|
| |
| 334 |
|
| Mugdha Choudhari, University of Minnesota Duluth |
| 335 |
|
| E<lt>chou0130 at d.umn.eduE<gt> |
| 336 |
|
| |
| 337 |
|
| Ted Pedersen, University of Minnesota Duluth |
| 338 |
|
| E<lt>tpederse at d.umn.eduE<gt> |
| 339 |
|
| |
| 340 |
|
| |
| 341 |
|
| |
| 342 |
|
| |
| 343 |
|
| =head1 COPYRIGHT |
| 344 |
|
| |
| 345 |
|
| Copyright (C) 2011, Mugdha Choudhari, Ted Pedersen |
| 346 |
|
| |
| 347 |
|
| This program is free software; you can redistribute it and/or modify |
| 348 |
|
| it under the terms of the GNU General Public License as published by |
| 349 |
|
| the Free Software Foundation; either version 2 of the License, or (at |
| 350 |
|
| your option) any later version. |
| 351 |
|
| |
| 352 |
|
| This program is distributed in the hope that it will be useful, but |
| 353 |
|
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| 354 |
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 355 |
|
| General Public License for more details. |
| 356 |
|
| |
| 357 |
|
| You should have received a copy of the GNU General Public License |
| 358 |
|
| along with this program; if not, write to |
| 359 |
|
| The Free Software Foundation, Inc., |
| 360 |
|
| 59 Temple Place - Suite 330, |
| 361 |
|
| Boston, MA 02111-1307, USA. |
| 362 |
|
| |
| 363 |
|
| =cut |
| 364 |
|
| |
| 365 |
|
| #---------------------------------PERLDOC ENDS HERE--------------------------------------------------------------- |
| 366 |
|
| 1; |