Class | Bio::MEDLINE
In: | lib/bio/db/medline.rb
Parent: | NCBIDB

## Description

NCBI PubMed/MEDLINE database class.

## Examples

      medline = Bio::MEDLINE.new(txt)
      medline.reference
      medline.pmid == medline.entry_id
      medilne.mesh

### Methods

ab abstract ad affiliations au authors date doi dp entry_id ip issue journal mesh mh new pages pg pii pmid pt publication_type reference so source ta ti title ui vi volume year

### Attributes

pubmed | [R] |

### Public Class methods

new(entry)

[Source]

        # File lib/bio/db/medline.rb, line 28
    28:   def initialize(entry)
    29:     @pubmed = Hash.new('')
    30:
    31:     tag = ''
    32:     entry.each_line do |line|
    33:       if line =~ /^\w/
    34:         tag = line[0,4].strip
    35:       else
    36:         # continuation from previous lines
    37:         @pubmed[tag] = @pubmed[tag].sub(/(?:\r|\r\n|\n)\z/, ' ')
    38:       end
    39:       value = line[6..-1]
    40:       @pubmed[tag] += value if value
    41:     end
    42:   end

### Public Instance methods

ab()

AB - Abstract

      Abstract.

[Source]

         # File lib/bio/db/medline.rb, line 145
    145:   def ab
    146:     @pubmed['AB'].gsub(/\s+/, ' ').strip
    147:   end

abstract()

Alias for ab

ad()

AD - Affiliation

      Institutional affiliation and address of the first author, and grant
      numbers.

[Source]

         # File lib/bio/db/medline.rb, line 193
    193:   def ad
    194:     @pubmed['AD'].strip.split(/\n/)
    195:   end

affiliations()

Alias for ad

au()

AU - Author Name

      Authors' names.

[Source]

         # File lib/bio/db/medline.rb, line 152
    152:   def au
    153:     @pubmed['AU'].strip
    154:   end

authors()

[Source]

         # File lib/bio/db/medline.rb, line 156
    156:   def authors
    157:     authors = []
    158:     au.split(/\n/).each do |author|
    159:       if author =~ / /
    160:         name = author.split(/\s+/)
    161:         suffix = nil
    162:         if name.length > 2 && name[-2] =~ /^[A-Z]+$/ # second to last are the initials
    163:           suffix = name.pop
    164:         end
    165:         initial = name.pop.split(//).join('. ')
    166:         author = "#{name.join(' ')}, #{initial}."
    167:       end
    168:       if suffix
    169:         author << " " + suffix
    170:       end
    171:       authors.push(author)
    172:     end
    173:     return authors
    174:   end

date()

Alias for dp

doi()

AID - Article Identifier

      Article ID values may include the pii (controlled publisher identifier)
      or doi (Digital Object Identifier).

[Source]

         # File lib/bio/db/medline.rb, line 201
    201:   def doi
    202:     @pubmed['AID'][/(\S+) \[doi\]/, 1]
    203:   end

dp()

DP - Publication Date

      The date the article was published.

[Source]

         # File lib/bio/db/medline.rb, line 127
    127:   def dp
    128:     @pubmed['DP'].strip
    129:   end

entry_id()

Alias for pmid

ip()

IP - Issue

      The number of the issue, part, or supplement of the journal in which
      the article was published.

[Source]

         # File lib/bio/db/medline.rb, line 102
    102:   def ip
    103:     @pubmed['IP'].strip
    104:   end

issue()

Alias for ip

journal()

Alias for ta

mesh()

Alias for mh

mh()

MH - MeSH Terms

      NLM's controlled vocabulary.

[Source]

         # File lib/bio/db/medline.rb, line 185
    185:   def mh
    186:     @pubmed['MH'].strip.split(/\n/)
    187:   end

pages()

[Source]

         # File lib/bio/db/medline.rb, line 113
    113:   def pages
    114:     pages = pg
    115:     if pages =~ /-/
    116:       from, to = pages.split('-')
    117:       if (len = from.length - to.length) > 0
    118:         to = from[0,len] + to
    119:       end
    120:       pages = "#{from}-#{to}"
    121:     end
    122:     return pages
    123:   end

pg()

PG - Page Number

      The full pagination of the article.

[Source]

         # File lib/bio/db/medline.rb, line 109
    109:   def pg
    110:     @pubmed['PG'].strip
    111:   end

pii()

[Source]

         # File lib/bio/db/medline.rb, line 205
    205:   def pii
    206:     @pubmed['AID'][/(\S+) \[pii\]/, 1]
    207:   end

pmid()

PMID - PubMed Unique Identifier

      Unique number assigned to each PubMed citation.

[Source]

        # File lib/bio/db/medline.rb, line 74
    74:   def pmid
    75:     @pubmed['PMID'].strip
    76:   end

pt()

PT - Publication Type

      The type of material the article represents.

[Source]

         # File lib/bio/db/medline.rb, line 278
    278:   def pt
    279:     @pubmed['PT'].strip.split(/\n/)
    280:   end

publication_type()

Alias for pt

reference()

returns a Reference object.

[Source]

        # File lib/bio/db/medline.rb, line 47
    47:   def reference
    48:     hash = Hash.new
    49:
    50:     hash['authors']     = authors
    51:     hash['title']       = title
    52:     hash['journal']     = journal
    53:     hash['volume']      = volume
    54:     hash['issue']       = issue
    55:     hash['pages']       = pages
    56:     hash['year']        = year
    57:     hash['pubmed']      = pmid
    58:     hash['medline']     = ui
    59:     hash['abstract']    = abstract
    60:     hash['mesh']        = mesh
    61:     hash['doi'] = doi
    62:     hash['affiliations'] = affiliations
    63:
    64:     hash.delete_if { |k, v| v.nil? or v.empty? }
    65:
    66:     return Reference.new(hash)
    67:   end

so()

SO - Source

      Composite field containing bibliographic information.

[Source]

         # File lib/bio/db/medline.rb, line 178
    178:   def so
    179:     @pubmed['SO'].strip
    180:   end

source()

Alias for so

ta()

TA - Journal Title Abbreviation

      Standard journal title abbreviation.

[Source]

        # File lib/bio/db/medline.rb, line 87
    87:   def ta
    88:     @pubmed['TA'].gsub(/\s+/, ' ').strip
    89:   end

ti()

TI - Title Words

      The title of the article.

[Source]

         # File lib/bio/db/medline.rb, line 138
    138:   def ti
    139:     @pubmed['TI'].gsub(/\s+/, ' ').strip
    140:   end

title()

Alias for ti

ui()

UI - MEDLINE Unique Identifier

      Unique number assigned to each MEDLINE citation.

[Source]

        # File lib/bio/db/medline.rb, line 81
    81:   def ui
    82:     @pubmed['UI'].strip
    83:   end

vi()

VI - Volume

      Journal volume.

[Source]

        # File lib/bio/db/medline.rb, line 94
    94:   def vi
    95:     @pubmed['VI'].strip
    96:   end

volume()

Alias for vi

year()

[Source]

         # File lib/bio/db/medline.rb, line 132
    132:   def year
    133:     dp[0,4]
    134:   end

[Validate]