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 144
    144:   def ab
    145:     @pubmed['AB'].gsub(/\s+/, ' ').strip
    146:   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 192
    192:   def ad
    193:     @pubmed['AD'].strip.split(/\n/)
    194:   end

affiliations()

Alias for ad

au()

AU - Author Name

      Authors' names.

[Source]

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

authors()

[Source]

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

dp()

DP - Publication Date

      The date the article was published.

[Source]

         # File lib/bio/db/medline.rb, line 126
    126:   def dp
    127:     @pubmed['DP'].strip
    128:   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 101
    101:   def ip
    102:     @pubmed['IP'].strip
    103:   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 184
    184:   def mh
    185:     @pubmed['MH'].strip.split(/\n/)
    186:   end

pages()

[Source]

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

pg()

PG - Page Number

      The full pagination of the article.

[Source]

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

pii()

[Source]

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

pmid()

PMID - PubMed Unique Identifier

      Unique number assigned to each PubMed citation.

[Source]

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

pt()

PT - Publication Type

      The type of material the article represents.

[Source]

         # File lib/bio/db/medline.rb, line 277
    277:   def pt
    278:     @pubmed['PT'].strip.split(/\n/)
    279:   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['affiliations'] = affiliations
    62:
    63:     hash.delete_if { |k, v| v.nil? or v.empty? }
    64:
    65:     return Reference.new(hash)
    66:   end

so()

SO - Source

      Composite field containing bibliographic information.

[Source]

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

source()

Alias for so

ta()

TA - Journal Title Abbreviation

      Standard journal title abbreviation.

[Source]

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

ti()

TI - Title Words

      The title of the article.

[Source]

         # File lib/bio/db/medline.rb, line 137
    137:   def ti
    138:     @pubmed['TI'].gsub(/\s+/, ' ').strip
    139:   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 80
    80:   def ui
    81:     @pubmed['UI'].strip
    82:   end

vi()

VI - Volume

      Journal volume.

[Source]

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

volume()

Alias for vi

year()

[Source]

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

[Validate]