#!/usr/local/bin/perl -w # ################## MEDLINE FIELD EXTRACTION AND TABLE SUMMARY ############# # # # ALL FIELDS # # # # # # This uses a standard Medline output -via STDIN pipe or text file # # (preferably after fileds-to-single-line processing) # # and summarizes according to field selected # # # # By Mike Galsworthy # # # ############################################################################### use Getopt::Long; my ($field, $showtop); GetOptions ("field:s" => \$field, "showtop=i" => \$showtop); #if (!($field)) { # $field = 'AU'; # } if (!($showtop)) { $showtop = 10; #arbitrary default value } my $term = '(term not found)'; #defaults in case of failure: my $Count = '(count not found)'; #as these terms are written my $keep = '(keep not found)'; #by the program Medline_call.pl my $AU = '(nothing)'; my $MEDLINEcount = 0; my $Male = 0; my $Female = 0; my $Animals = 0; my $Humans = 0; my $InfantP = 0; my $InfantN = 0; my $Infant = 0; my $ChildP = 0; my $Child = 0; my $Adolescent = 0; my $Adult = 0; my $MiddleAged = 0; my $Aged = 0; my $Aged80over = 0; my $failure = 0; while (<>) { chomp; if (/norecordsxxx/) { $failure = 1; } if (/^QRY /) { $term = substr($_,6); } if (/^CNT /) { $Count = substr($_,6); } if (/^KP /) { $keep = substr($_,6); } if (/^MH /) { $MH = substr($_,6); if ($MH =~ /\*/) { # Starred terms $MHstarred = $MH; $tableMHstarred{$MHstarred}++; } if ($MH =~ /^\*/) { #to take the "*" off $MH = substr($MH,1); #Major MeSH Headings } my $slash = index($MH, '/'); if ($slash > 0) { # if slash $MH = substr($MH,0,$slash) # then remove } if ($MH eq "Male") { $Male++; $MH = "removed"; } if ($MH eq "Female") { $Female++; $MH = "removed"; } if ($MH eq "Animals") { $Animals++; $MH = "removed"; } if ($MH eq "Humans") { $Humans++; $MH = "removed"; } if ($MH eq "Infant, Premature") { $InfantP++; $MH = "removed"; } if ($MH eq "Infant, Newborn") { $InfantN++; $MH = "removed"; } if ($MH eq "Infant") { $Infant++; $MH = "removed"; } if ($MH eq "Child, Preschool") { $ChildP++; $MH = "removed"; } if ($MH eq "Child") { $Child++; $MH = "removed"; } if ($MH eq "Adolescent") { $Adolescent++; $MH = "removed"; } if ($MH eq "Adult") { $Adult++; $MH = "removed"; } if ($MH eq "Middle Aged") { $MiddleAged++; $MH = "removed"; } if ($MH eq "Aged") { $Aged++; $MH = "removed"; } if ($MH eq "Aged, 80 and over") { $Aged80over++; $MH = "removed"; } $tableMH{$MH}++; } } if ($failure==1) { print ' Sorry! This query is associated with 0 records... Try the Quick Call button to see if anything went wrong.
'; } else { print " Total PubMed records with MeSH entries : $Count"; print "
MEDSUM MeSH It processed the most recent : $keep"; if ($Count > $keep) { $Count = $keep; } print "

Here are the top $showtop Major MeSH Headings:

"; delete $tableMH{"removed"}; $countMH = $showtop; my $percent = 0; foreach $MH (sort{$tableMH{$b} <=> $tableMH{$a}} keys %tableMH) { if ($countMH > 0) { $percent = ($tableMH{$MH}/$Count)*100; print ''; $countMH--; } } print "
'; print $tableMH{$MH}; print ''; printf "%.2f \%", $percent; print ''; print $MH; print '
"; }