File: pmid2MIAME.R

package info (click to toggle)
r-bioc-annotate 1.84.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,624 kB
  • sloc: makefile: 2
file content (28 lines) | stat: -rw-r--r-- 935 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
pmid2MIAME = function (pmid) 
{
#
# we find that some abstracts are text values of <Abstract>
# and some of <Abstract><AbstractText> ...
#
# need to think about validity checking here .. DTD?
#
    x = pubmed(pmid)
    rr = xmlRoot(x)
    top = xmlChildren(rr)
    pmart = top[["PubmedArticle"]]
    cit = xmlChildren(pmart)[["MedlineCitation"]]
    art = cit[["Article"]]
    cart = xmlChildren(art)
    title = xmlValue(cart[["ArticleTitle"]])
    abst = xmlValue(cart[["Abstract"]])
    if (is.null(abst)) {
	caa = xmlChildren(cart[["Abstract"]])
        abst = xmlValue(caa[["AbstractText"]])
    }
    if (is.null(abst)) abst = ""
    aff = xmlValue(cart[["Affiliation"]])
    an = cart[["AuthorList"]]
    last = xmlValue(xmlChildren(an[[1]])[["LastName"]])
    ini = xmlValue(xmlChildren(an[[1]])[["Initials"]])
    new("MIAME", name=paste(last,ini,collapse=", "), lab = aff, title = title, abstract = abst, pubMedIds = pmid)
}