Class: Bio::MEDLINE
Overview
Instance Attribute Summary collapse
-
#pubmed ⇒ Object
readonly
Returns the value of attribute pubmed.
Instance Method Summary collapse
-
#ab ⇒ Object
(also: #abstract)
AB - Abstract Abstract.
-
#ad ⇒ Object
(also: #affiliations)
AD - Affiliation Institutional affiliation and address of the first author, and grant numbers.
-
#au ⇒ Object
AU - Author Name Authors’ names.
- #authors ⇒ Object
-
#doi ⇒ Object
AID - Article Identifier Article ID values may include the pii (controlled publisher identifier) or doi (Digital Object Identifier).
-
#dp ⇒ Object
(also: #date)
DP - Publication Date The date the article was published.
-
#initialize(entry) ⇒ MEDLINE
constructor
A new instance of MEDLINE.
-
#ip ⇒ Object
(also: #issue)
IP - Issue The number of the issue, part, or supplement of the journal in which the article was published.
-
#mh ⇒ Object
(also: #mesh)
MH - MeSH Terms NLM’s controlled vocabulary.
- #pages ⇒ Object
-
#pg ⇒ Object
PG - Page Number The full pagination of the article.
- #pii ⇒ Object
-
#pmid ⇒ Object
(also: #entry_id)
PMID - PubMed Unique Identifier Unique number assigned to each PubMed citation.
-
#pt ⇒ Object
(also: #publication_type)
PT - Publication Type The type of material the article represents.
-
#reference ⇒ Object
returns a Reference object.
-
#so ⇒ Object
(also: #source)
SO - Source Composite field containing bibliographic information.
-
#ta ⇒ Object
(also: #journal)
TA - Journal Title Abbreviation Standard journal title abbreviation.
-
#ti ⇒ Object
(also: #title)
TI - Title Words The title of the article.
-
#ui ⇒ Object
UI - MEDLINE Unique Identifier Unique number assigned to each MEDLINE citation.
-
#vi ⇒ Object
(also: #volume)
VI - Volume Journal volume.
- #year ⇒ Object
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 39 40 41 42 |
# 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 |
Instance Attribute Details
#pubmed ⇒ Object (readonly)
Returns the value of attribute pubmed.
43 44 45 |
# File 'lib/bio/db/medline.rb', line 43 def pubmed @pubmed end |
Instance Method Details
#ab ⇒ Object Also known as: abstract
AB - Abstract
Abstract.
145 146 147 |
# File 'lib/bio/db/medline.rb', line 145 def ab @pubmed['AB'].gsub(/\s+/, ' ').strip end |
#ad ⇒ Object Also known as: affiliations
AD - Affiliation
Institutional affiliation and address of the first author, and grant
numbers.
193 194 195 |
# File 'lib/bio/db/medline.rb', line 193 def ad @pubmed['AD'].strip.split(/\n/) end |
#au ⇒ Object
AU - Author Name
Authors' names.
152 153 154 |
# File 'lib/bio/db/medline.rb', line 152 def au @pubmed['AU'].strip end |
#authors ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/bio/db/medline.rb', line 156 def = [] au.split(/\n/).each do || if =~ / / name = .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('. ') = "#{name.join(' ')}, #{initial}." end if suffix << " " + suffix end .push() end return end |
#doi ⇒ Object
AID - Article Identifier
Article ID values may include the pii (controlled publisher identifier)
or doi (Digital Object Identifier).
201 202 203 |
# File 'lib/bio/db/medline.rb', line 201 def doi @pubmed['AID'][/(\S+) \[doi\]/, 1] end |
#dp ⇒ Object Also known as: date
DP - Publication Date
The date the article was published.
127 128 129 |
# File 'lib/bio/db/medline.rb', line 127 def dp @pubmed['DP'].strip end |
#ip ⇒ Object Also known as: issue
IP - Issue
The number of the issue, part, or supplement of the journal in which
the article was published.
102 103 104 |
# File 'lib/bio/db/medline.rb', line 102 def ip @pubmed['IP'].strip end |
#mh ⇒ Object Also known as: mesh
MH - MeSH Terms
NLM's controlled vocabulary.
185 186 187 |
# File 'lib/bio/db/medline.rb', line 185 def mh @pubmed['MH'].strip.split(/\n/) end |
#pages ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# 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 ⇒ Object
PG - Page Number
The full pagination of the article.
109 110 111 |
# File 'lib/bio/db/medline.rb', line 109 def pg @pubmed['PG'].strip end |
#pii ⇒ Object
205 206 207 |
# File 'lib/bio/db/medline.rb', line 205 def pii @pubmed['AID'][/(\S+) \[pii\]/, 1] end |
#pmid ⇒ Object Also known as: entry_id
PMID - PubMed Unique Identifier
Unique number assigned to each PubMed citation.
74 75 76 |
# File 'lib/bio/db/medline.rb', line 74 def pmid @pubmed['PMID'].strip end |
#pt ⇒ Object Also known as: publication_type
PT - Publication Type
The type of material the article represents.
278 279 280 |
# File 'lib/bio/db/medline.rb', line 278 def pt @pubmed['PT'].strip.split(/\n/) end |
#reference ⇒ Object
returns a Reference object.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bio/db/medline.rb', line 47 def reference hash = Hash.new hash['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 ⇒ Object Also known as: source
SO - Source
Composite field containing bibliographic information.
178 179 180 |
# File 'lib/bio/db/medline.rb', line 178 def so @pubmed['SO'].strip end |
#ta ⇒ Object Also known as: journal
TA - Journal Title Abbreviation
Standard journal title abbreviation.
87 88 89 |
# File 'lib/bio/db/medline.rb', line 87 def ta @pubmed['TA'].gsub(/\s+/, ' ').strip end |
#ti ⇒ Object Also known as: title
TI - Title Words
The title of the article.
138 139 140 |
# File 'lib/bio/db/medline.rb', line 138 def ti @pubmed['TI'].gsub(/\s+/, ' ').strip end |
#ui ⇒ Object
UI - MEDLINE Unique Identifier
Unique number assigned to each MEDLINE citation.
81 82 83 |
# File 'lib/bio/db/medline.rb', line 81 def ui @pubmed['UI'].strip end |
#vi ⇒ Object Also known as: volume
VI - Volume
Journal volume.
94 95 96 |
# File 'lib/bio/db/medline.rb', line 94 def vi @pubmed['VI'].strip end |
#year ⇒ Object
132 133 134 |
# File 'lib/bio/db/medline.rb', line 132 def year dp[0,4] end |