class Bio::MEDLINE

Description

NCBI PubMed/MEDLINE database class.

Examples

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

Attributes

pubmed[R]

Public Class Methods

new(entry) click to toggle source
# File lib/bio/db/medline.rb, line 28
def initialize(entry)
  @pubmed = Hash.new('')

  tag = ''
  entry.each_line do |line|
    if line =~ /^\w/
      tag = line[0,4].strip
    else
      # continuation from previous lines
      @pubmed[tag] = @pubmed[tag].sub(/(?:\r|\r\n|\n)\z/, ' ')
    end
    value = line[6..-1]
    @pubmed[tag] += value if value
  end
end

Public Instance Methods

ab() click to toggle source

AB - Abstract

Abstract.
# File lib/bio/db/medline.rb, line 145
def ab
  @pubmed['AB'].gsub(/\s+/, ' ').strip
end
Also aliased as: abstract
abstract()
Alias for: ab
ad() click to toggle source

AD - Affiliation

Institutional affiliation and address of the first author, and grant
numbers.
# File lib/bio/db/medline.rb, line 193
def ad
  @pubmed['AD'].strip.split(/\n/)
end
Also aliased as: affiliations
affiliations()
Alias for: ad
au() click to toggle source

AU - Author Name

Authors' names.
# File lib/bio/db/medline.rb, line 152
def au
  @pubmed['AU'].strip
end
authors() click to toggle source
# File lib/bio/db/medline.rb, line 156
def authors
  authors = []
  au.split(/\n/).each do |author|
    if author =~ / /
      name = author.split(/\s+/)
      suffix = nil
      if name.length > 2 && name[-2] =~ /^[A-Z]+$/ # second to last are the initials
        suffix = name.pop
      end
      initial = name.pop.split(//).join('. ')
      author = "#{name.join(' ')}, #{initial}."
    end
    if suffix
      author << " " + suffix
    end
    authors.push(author)
  end
  return authors
end
date()
Alias for: dp
doi() click to toggle source

AID - Article Identifier

Article ID values may include the pii (controlled publisher identifier)
or doi (Digital Object Identifier).
# File lib/bio/db/medline.rb, line 201
def doi
  @pubmed['AID'][/(\S+) \[doi\]/, 1]
end
dp() click to toggle source

DP - Publication Date

The date the article was published.
# File lib/bio/db/medline.rb, line 127
def dp
  @pubmed['DP'].strip
end
Also aliased as: date
entry_id()
Alias for: pmid
ip() click to toggle source

IP - Issue

The number of the issue, part, or supplement of the journal in which
the article was published.
# File lib/bio/db/medline.rb, line 102
def ip
  @pubmed['IP'].strip
end
Also aliased as: issue
issue()
Alias for: ip
journal()
Alias for: ta
mesh()
Alias for: mh
mh() click to toggle source

MH - MeSH Terms

NLM's controlled vocabulary.
# File lib/bio/db/medline.rb, line 185
def mh
  @pubmed['MH'].strip.split(/\n/)
end
Also aliased as: mesh
pages() click to toggle source
# File lib/bio/db/medline.rb, line 113
def pages
  pages = pg
  if pages =~ /-/
    from, to = pages.split('-')
    if (len = from.length - to.length) > 0
      to = from[0,len] + to
    end
    pages = "#{from}-#{to}"
  end
  return pages
end
pg() click to toggle source

PG - Page Number

The full pagination of the article.
# File lib/bio/db/medline.rb, line 109
def pg
  @pubmed['PG'].strip
end
pii() click to toggle source
# File lib/bio/db/medline.rb, line 205
def pii
  @pubmed['AID'][/(\S+) \[pii\]/, 1]
end
pmid() click to toggle source

PMID - PubMed Unique Identifier

Unique number assigned to each PubMed citation.
# File lib/bio/db/medline.rb, line 74
def pmid
  @pubmed['PMID'].strip
end
Also aliased as: entry_id
pt() click to toggle source

PT - Publication Type

The type of material the article represents.
# File lib/bio/db/medline.rb, line 278
def pt
  @pubmed['PT'].strip.split(/\n/)   
end
Also aliased as: publication_type
publication_type()
Alias for: pt
reference() click to toggle source

returns a Reference object.

# File lib/bio/db/medline.rb, line 47
def reference
  hash = Hash.new

  hash['authors']     = authors
  hash['title']       = title
  hash['journal']     = journal
  hash['volume']      = volume
  hash['issue']       = issue
  hash['pages']       = pages
  hash['year']        = year
  hash['pubmed']      = pmid
  hash['medline']     = ui
  hash['abstract']    = abstract
  hash['mesh']        = mesh
  hash['doi'] = doi
  hash['affiliations'] = affiliations

  hash.delete_if { |k, v| v.nil? or v.empty? }

  return Reference.new(hash)
end
so() click to toggle source

SO - Source

Composite field containing bibliographic information.
# File lib/bio/db/medline.rb, line 178
def so
  @pubmed['SO'].strip
end
Also aliased as: source
source()
Alias for: so
ta() click to toggle source

TA - Journal Title Abbreviation

Standard journal title abbreviation.
# File lib/bio/db/medline.rb, line 87
def ta
  @pubmed['TA'].gsub(/\s+/, ' ').strip
end
Also aliased as: journal
ti() click to toggle source

TI - Title Words

The title of the article.
# File lib/bio/db/medline.rb, line 138
def ti
  @pubmed['TI'].gsub(/\s+/, ' ').strip
end
Also aliased as: title
title()
Alias for: ti
ui() click to toggle source

UI - MEDLINE Unique Identifier

Unique number assigned to each MEDLINE citation.
# File lib/bio/db/medline.rb, line 81
def ui
  @pubmed['UI'].strip
end
vi() click to toggle source

VI - Volume

Journal volume.
# File lib/bio/db/medline.rb, line 94
def vi
  @pubmed['VI'].strip
end
Also aliased as: volume
volume()
Alias for: vi
year() click to toggle source
# File lib/bio/db/medline.rb, line 132
def year
  dp[0,4]
end