Class: Bio::MEDLINE

Inherits:
NCBIDB show all
Defined in:
lib/bio/db/medline.rb

Overview

Description

NCBI PubMed/MEDLINE database class.

Examples

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DB

#exists?, #fetch, #get, open, #tags

Constructor Details

#initialize(entry) ⇒ MEDLINE

Returns a new instance of MEDLINE.



28
29
30
31
32
33
34
35
36
37
38
# 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
    end
    @pubmed[tag] += line[6..-1] if line.length > 6
  end
end

Instance Attribute Details

#pubmedObject (readonly)

Returns the value of attribute pubmed.



39
40
41
# File 'lib/bio/db/medline.rb', line 39

def pubmed
  @pubmed
end

Instance Method Details

#abObject Also known as: abstract

AB - Abstract

Abstract.


140
141
142
# File 'lib/bio/db/medline.rb', line 140

def ab
  @pubmed['AB'].gsub(/\s+/, ' ').strip
end

#adObject Also known as: affiliations

AD - Affiliation

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


188
189
190
# File 'lib/bio/db/medline.rb', line 188

def ad
  @pubmed['AD'].strip.split(/\n/)
end

#auObject

AU - Author Name

Authors' names.


147
148
149
# File 'lib/bio/db/medline.rb', line 147

def au
  @pubmed['AU'].strip
end

#authorsObject



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/bio/db/medline.rb', line 151

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

#doiObject

AID - Article Identifier

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


196
197
198
# File 'lib/bio/db/medline.rb', line 196

def doi
  @pubmed['AID'][/(\S+) \[doi\]/, 1]
end

#dpObject Also known as: date

DP - Publication Date

The date the article was published.


122
123
124
# File 'lib/bio/db/medline.rb', line 122

def dp
  @pubmed['DP'].strip
end

#ipObject Also known as: issue

IP - Issue

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


97
98
99
# File 'lib/bio/db/medline.rb', line 97

def ip
  @pubmed['IP'].strip
end

#mhObject Also known as: mesh

MH - MeSH Terms

NLM's controlled vocabulary.


180
181
182
# File 'lib/bio/db/medline.rb', line 180

def mh
  @pubmed['MH'].strip.split(/\n/)
end

#pagesObject



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/bio/db/medline.rb', line 108

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

#pgObject

PG - Page Number

The full pagination of the article.


104
105
106
# File 'lib/bio/db/medline.rb', line 104

def pg
  @pubmed['PG'].strip
end

#piiObject



200
201
202
# File 'lib/bio/db/medline.rb', line 200

def pii
  @pubmed['AID'][/(\S+) \[pii\]/, 1]
end

#pmidObject Also known as: entry_id

PMID - PubMed Unique Identifier

Unique number assigned to each PubMed citation.


69
70
71
# File 'lib/bio/db/medline.rb', line 69

def pmid
  @pubmed['PMID'].strip
end

#ptObject Also known as: publication_type

PT - Publication Type

The type of material the article represents.


273
274
275
# File 'lib/bio/db/medline.rb', line 273

def pt
  @pubmed['PT'].strip.split(/\n/)   
end

#referenceObject

returns a Reference object.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/bio/db/medline.rb', line 43

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['affiliations'] = affiliations

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

  return Reference.new(hash)
end

#soObject Also known as: source

SO - Source

Composite field containing bibliographic information.


173
174
175
# File 'lib/bio/db/medline.rb', line 173

def so
  @pubmed['SO'].strip
end

#taObject Also known as: journal

TA - Journal Title Abbreviation

Standard journal title abbreviation.


82
83
84
# File 'lib/bio/db/medline.rb', line 82

def ta
  @pubmed['TA'].gsub(/\s+/, ' ').strip
end

#tiObject Also known as: title

TI - Title Words

The title of the article.


133
134
135
# File 'lib/bio/db/medline.rb', line 133

def ti
  @pubmed['TI'].gsub(/\s+/, ' ').strip
end

#uiObject

UI - MEDLINE Unique Identifier

Unique number assigned to each MEDLINE citation.


76
77
78
# File 'lib/bio/db/medline.rb', line 76

def ui
  @pubmed['UI'].strip
end

#viObject Also known as: volume

VI - Volume

Journal volume.


89
90
91
# File 'lib/bio/db/medline.rb', line 89

def vi
  @pubmed['VI'].strip
end

#yearObject



127
128
129
# File 'lib/bio/db/medline.rb', line 127

def year
  dp[0,4]
end