[Biopython-dev] [BioPython] PubMed find_related

Peter biopython at maubp.freeserve.co.uk
Fri Nov 28 07:37:04 EST 2008


On Tue, Nov 25, 2008 at 4:05 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>>>> from Bio import Entrez
>>>> handle = Entrez.elink(dbfrom='pubmed',id=12345)
>>>> record = Entrez.read(handle)
>
> Feel free to write a section about Entrez.elink for the Biopython documentation :-).
> Currently, this section is almost empty.

This does need a little love, doesn't it.  Here is a slightly longer
example which could form the basis of a tutorial entry:

    >>> from Bio import Entrez
    >>> Entrez.email = "A.N.Other at example.com"
    >>> pmid = "12230038"
    >>> handle = Entrez.elink(dbfrom='pubmed', id=pmid)
    >>> result = Entrez.read(handle)
    >>> for link in result[0]["LinkSetDb"][0]['Link'] :
    ...     print link

The deeply nested nature of the XML results do suggest that a helper
function in Bio.Entrez would be useful here.  Maybe something like:

def find_related(dbfrom, id) :
    #Returns a list of dictionaries containing Score and ID matched
    result = read(elink(dbfrom=dbfrom, id=id))
    return result[0]["LinkSetDb"][0]['Link']

It might make more sense to return just a list of ID strings, but the
score may be interesting.

Peter


More information about the Biopython-dev mailing list