Class Bio::MEDLINE
In: lib/bio/db/medline.rb  (CVS)
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

[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
      end
      @pubmed[tag] += line[6..-1] if line.length > 6
    end
  end

Public Instance methods

AB - Abstract

  Abstract.

[Source]

# File lib/bio/db/medline.rb, line 140
  def ab
    @pubmed['AB'].gsub(/\s+/, ' ').strip
  end
abstract()

Alias for ab

AD - Affiliation

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

[Source]

# File lib/bio/db/medline.rb, line 185
  def ad
    @pubmed['AD'].strip.split(/\n/)
  end
affiliations()

Alias for ad

AU - Author Name

  Authors' names.

[Source]

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

[Source]

# File lib/bio/db/medline.rb, line 151
  def authors
    authors = []
    au.split(/\n/).each do |author|
      if author =~ / /
        name = author.split(/\s+/)
        suffix = name[-2] =~ /^[A-Z]+$/ ? name.pop : nil        # Jr etc.
        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

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 193
  def doi
    @pubmed['AID'][/(\S+) \[doi\]/, 1]
  end

DP - Publication Date

  The date the article was published.

[Source]

# File lib/bio/db/medline.rb, line 122
  def dp
    @pubmed['DP'].strip
  end
entry_id()

Alias for pmid

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 97
  def ip
    @pubmed['IP'].strip
  end
issue()

Alias for ip

journal()

Alias for ta

mesh()

Alias for mh

MH - MeSH Terms

  NLM's controlled vocabulary.

[Source]

# File lib/bio/db/medline.rb, line 177
  def mh
    @pubmed['MH'].strip.split(/\n/)
  end

[Source]

# 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

PG - Page Number

  The full pagination of the article.

[Source]

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

[Source]

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

PMID - PubMed Unique Identifier

  Unique number assigned to each PubMed citation.

[Source]

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

PT - Publication Type

  The type of material the article represents.

[Source]

# File lib/bio/db/medline.rb, line 270
  def pt
    @pubmed['PT'].strip.split(/\n/)   
  end
publication_type()

Alias for pt

returns a Reference object.

[Source]

# 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

SO - Source

  Composite field containing bibliographic information.

[Source]

# File lib/bio/db/medline.rb, line 170
  def so
    @pubmed['SO'].strip
  end
source()

Alias for so

TA - Journal Title Abbreviation

  Standard journal title abbreviation.

[Source]

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

TI - Title Words

  The title of the article.

[Source]

# File lib/bio/db/medline.rb, line 133
  def ti
    @pubmed['TI'].gsub(/\s+/, ' ').strip
  end
title()

Alias for ti

UI - MEDLINE Unique Identifier

  Unique number assigned to each MEDLINE citation.

[Source]

# File lib/bio/db/medline.rb, line 76
  def ui
    @pubmed['UI'].strip
  end

VI - Volume

  Journal volume.

[Source]

# File lib/bio/db/medline.rb, line 89
  def vi
    @pubmed['VI'].strip
  end
volume()

Alias for vi

[Source]

# File lib/bio/db/medline.rb, line 127
  def year
    dp[0,4]
  end

[Validate]