#!/usr/bin/perl -w use strict; use CGI qw(:standard); use NGD; ###################################################################### ###################################################################### # # This program displays a HTML form, allowing a user to enter the # terms for calculation of the NGD in a variety of ways and with # additional options, such as synonym search. # # NGD.pm is used as a utility module to provide an interface to # connect to the Google API and calc the NGD(s). # # The results are then displayed in a HTML table. # ##################################################################### ##################################################################### ############################## #Change Log ############################## # 20 May 2006 - Lucy # Removed synonym search ###################################################################### # # Nicely displays the distance matrix in a HTML table, when multiple # search terms are used. # ##################################################################### sub _displayTable($$$) { my ($firstTerms, $secondTerms, $results) = @_; print ""; foreach (@$secondTerms) { print ""; } print ""; for (my $i = 0; $i < @$firstTerms; $i++) { print ""; for (my $j = 0; $j < @$secondTerms; $j++) { if ( defined( $$results{$$firstTerms[$i].'-'.$$secondTerms[$j]}->{QueryString}) ) { print ""; } else { print ""; } } print ""; } print "
 $_
".$$firstTerms[$i]."{QueryString}."'>". $$results{$$firstTerms[$i].'-'.$$secondTerms[$j]}->{Distance}, " --
"; print p, "About these results", br; } ###################################################################### # # Parses the form input and then choses what behaviour of NGD.pm to # use (currently just calcs distance between 1 or 2 terms). # ##################################################################### sub _parseform($$) { my ($term1, $term2) = @_; my $string; my $ngd = NGD->new(); if (defined($term1) && defined($term2)) { $string = "Calculating NGD ...\n"; my $distance = $ngd->singleDistance($term1, $term2); $string .= "

The distance for $term1 and $term2 is : $distance

"; $string .= "About these results
"; $string .= "

Top Google Hits:

"; $string .= $ngd->getLastResult()."
"; } } #end parseform() ###################################################################### ## ## Print the HTML ## ###################################################################### # my $help = "help.cgi"; #name and location of the associated help file. print header(); my $term1 = param('term1'); my $term2 = param('term2'); my $results = _parseform($term1, $term2); print start_html(-title => 'Normalised Google Distances', -style => { -type => 'text/css', -src => '../haushinka.css'}, -head=>[ Link({ -rel => 'Shortcut Icon', -type => 'image/x-icon', -href => '../images/favicon.ico'})], ); print < HEADER print <

Normalised Google Distances

This is a simplified version of a program I developed to measure the relationship between different terms using the Google search engine.

It will calculate the strength of a relationship based on the number of results returned by a Google search, feel free to experiment by entering some queries below (for example, try entering the terms 'horse' and 'rider' to discover their relationship). It uses the normlised google distance equation featured in this paper and was developed as part of a project during my bioinformatics masters course. Originally, it concentrated on mapping likely phenotypes to genes and was able to query a database of gene names to incorporate the synonyms of a gene name in the distance result, however it can also be applied more generally.

For more information about this software and the theory behind it, see here. If you experience any problems please read this.


Compare

Against



$results

HTML