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
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() click to toggle source

AB - Abstract

Abstract.
    # File lib/bio/db/medline.rb
145 def ab
146   @pubmed['AB'].gsub(/\s+/, ' ').strip
147 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
193 def ad
194   @pubmed['AD'].strip.split(/\n/)
195 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
152 def au
153   @pubmed['AU'].strip
154 end
authors() click to toggle source
    # File lib/bio/db/medline.rb
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() 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
201 def doi
202   @pubmed['AID'][/(\S+) \[doi\]/, 1]
203 end
dp() click to toggle source

DP - Publication Date

The date the article was published.
    # File lib/bio/db/medline.rb
127 def dp
128   @pubmed['DP'].strip
129 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
102 def ip
103   @pubmed['IP'].strip
104 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
185 def mh
186   @pubmed['MH'].strip.split(/\n/)
187 end
Also aliased as: mesh
pages() click to toggle source
    # File lib/bio/db/medline.rb
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() click to toggle source

PG - Page Number

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

PMID - PubMed Unique Identifier

Unique number assigned to each PubMed citation.
   # File lib/bio/db/medline.rb
74 def pmid
75   @pubmed['PMID'].strip
76 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
278 def pt
279   @pubmed['PT'].strip.split(/\n/)   
280 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
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() click to toggle source

SO - Source

Composite field containing bibliographic information.
    # File lib/bio/db/medline.rb
178 def so
179   @pubmed['SO'].strip
180 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
87 def ta
88   @pubmed['TA'].gsub(/\s+/, ' ').strip
89 end
Also aliased as: journal
ti() click to toggle source

TI - Title Words

The title of the article.
    # File lib/bio/db/medline.rb
138 def ti
139   @pubmed['TI'].gsub(/\s+/, ' ').strip
140 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
81 def ui
82   @pubmed['UI'].strip
83 end
vi() click to toggle source

VI - Volume

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