#!/usr/bin/perl # # parse the pubmed links to searchable format # use warnings; use strict; use File::Basename; sub parse_pub ($) { my $string = shift @_; local $_; if ($string =~ m/^.+?:.+?\. (.+)+$/) { $_ = $1; if (m/(.+?) (\d+): (\d+)-\d+, (\d+)./) { return "${1}[JO] AND ${4}[DP] AND ${2}[VI] AND ${3}[PG]"; } else { return undef; } } return; } my $omimf = shift @ARGV || "-"; open (INF,"$omimf") or die "Unable to open '$omimf': $!"; my $within = 0; # within field area my $key = ""; # current type my $i = 1; # line number my $space = 0; # was last line space my $extra = ""; # entries are in multiple lines while () { chomp; s/\r$//; !m/\*FIELD\* RF/ && !$within && next; if (m/\*FIELD\*/ && $within) { $within = 0; exit; } elsif (m/\*FIELD\* RF/) { $within = 1; } else { if (!$_) { $space = 1; } else { $space = 0; } if ($space) { chop ($extra); if ($extra =~ m/^.+?:.+?\. (.+)+$/) { $extra = $1; # print "$string,$1\n"; if ($extra =~ m/(.+?) (\d+): (\d+)-\d+, (\d+)./) { print "${1}[JO] AND ${4}[DP] AND ${2}[VI] AND ${3}[PG]\n"; } else { # return undef; } } # if ($key = parse_pub($extra)) { # # print "$key\n"; # } else { # print "$extra\n"; # } } else { $extra .= "$_ "; } } # main else } exit;