++ed by:

1 PAUSE user

Bridget McInnes
and 1 contributors


UMLS::Similarity::upath - Perl module for computing semantic similarity of concepts in the UMLS by simple edge counting regardless of the direction


  use UMLS::Interface;
  use UMLS::Similarity::upath;

  my $umls = UMLS::Interface->new(); 
  die "Unable to create UMLS::Interface object.\n" if(!$umls);

  my $upath = UMLS::Similarity::upath->new($umls);
  die "Unable to create measure object.\n" if(!$upath);

  my $cui1 = "C0005767";
  my $cui2 = "C0007634";

  $ts1 = $umls->getTermList($cui1);
  my $term1 = pop @{$ts1};

  $ts2 = $umls->getTermList($cui2);
  my $term2 = pop @{$ts2};

  my $value = $upath->getRelatedness($cui1, $cui2);

  print "The similarity between $cui1 ($term1) and $cui2 ($term2) is $value\n";


If the concepts being compared are the same, then the resulting similarity score will be 1. For example, the score for C0005767 and C0005767 is 1.

The relatedness value return by getRelatedness() is the multiplicative inverse of the path length between the two synsets (1/path_length). This has a slightly subtle effect: it shifts the relative magnitude of scores. For example, if we have the following pairs of synsets with the given path lengths:

  concept1 concept2: 3
  concept3 concept4: 4
  concept5 concept6: 5

We observe that the difference in the score for concept1-concept2 and concept3-concept4 is the same as for concept3-concept4 and concept5-concept6. When we take the multiplicative inverse of them, we get:

  concept1 concept2: .333
  concept3 concept4: .25
  concept5 concept6: .2

Now the difference between the scores for concept3-concept4 is less than the difference for concept1-concept2 and concept3-concept4. This can have negative consequences when computing correlation coefficients. It might be useful to compute relatedness as max_distance - path_length, where max_distance is the longest possible shortest path between two conceps. The original path length can be easily determined by taking the multiplicative inverse of the returned relatedness score: 1/score = 1/(1/path_length) = path_length.

If two different terms are given as input to getRelatedness, but both terms belong to the same concept, then 1 is returned (e.g., car and auto both belong to the same concept).


The semantic relatedness modules in this distribution are built as classes that expose the following methods: new() getRelatedness()


To create an object of the upath measure, we would have the following lines of code in the perl program.

   use UMLS::Similarity::upath;
   $measure = UMLS::Similarity::upath->new($interface);

The reference of the initialized object is stored in the scalar variable '$measure'. '$interface' contains an interface object that should have been created earlier in the program (UMLS-Interface).

If the 'new' method is unable to create the object, '$measure' would be undefined.

To find the semantic relatedness of the concept 'blood' (C0005767) and the concept 'cell' (C0007634) using the measure, we would write the following piece of code:

   $relatedness = $measure->getRelatedness('C0005767', 'C0007634');


The UMLS-Interface package takes a configuration file to determine which sources and relations to use when obtaining the path information.

The format of the configuration file is as follows:

SAB :: <include|exclude> <source1, source2, ... sourceN>

REL :: <include|exclude> <relation1, relation2, ... relationN>

For example, if we wanted to use the MSH vocabulary with only the RB/RN relations, the configuration file would be:

SAB :: include MSH REL :: include RB, RN


SAB :: include MSH REL :: exclude PAR, CHD

If you go to the configuration file directory, there will be example configuration files for the different runs that you have performed.

For more information about the configuration options please see the README.


perl(1), UMLS::Interface

perl(1), UMLS::Similarity(3)


  If you have any trouble installing and using UMLS-Similarity, 
  please contact us via the users mailing list :


  You can join this group by going to:


  You may also contact us directly if you prefer :

      Bridget T. McInnes: bthomson at cs.umn.edu 

      Ted Pedersen : tpederse at d.umn.edu


  Bridget T McInnes <bthomson at cs.umn.edu>
  Siddharth Patwardhan <sidd at cs.utah.edu>
  Serguei Pakhomov <pakh0002 at umn.edu>
  Ted Pedersen <tpederse at d.umn.edu>


Copyright 2004-2011 by Bridget T McInnes, Siddharth Patwardhan, Serguei Pakhomov, Ying Liu and Ted Pedersen

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.