def search(self):

        if self.database == 'PubMed':
            from Bio import PubMed
            from Bio import GenBank

        searchIds = PubMed.search_for(self.searchTerm, max_ids=self.maxResults)

        GBrecParser = GenBank.FeatureParser()
        ncbiDict = GenBank.NCBIDictionary(self.type,
                                          'genbank',
                                          parser=GBrecParser)

        from Bio import Medline

        MLrecParser = Medline.RecordParser()
        medlineDict = PubMed.Dictionary(delay=1.0, parser=MLrecParser)
        for id in searchIds:
            MLrecord = medlineDict[id]
            GBrecord = ncbiDict[id]
            newDBItem = DBItem(self.project,
                               seq=GBrecord.seq,
                               descript=GBrecord.description,
                               id=id,
                               record=MLrecord)
            self.items[id] = newDBItem
Exemple #2
0
"""Example script showing how to interact with PubMed."""
# standard library
import string

# biopython
from Bio import PubMed
from Bio import Medline

# do the search and get the ids
search_term = 'orchid'
orchid_ids = PubMed.search_for(search_term)

print orchid_ids

# access Medline through a dictionary interface that returns PubMed Records
rec_parser = Medline.RecordParser()
medline_dict = PubMed.Dictionary(parser=rec_parser)

for id in orchid_ids[0:5]:
    cur_record = medline_dict[id]
    print 'title:', string.rstrip(cur_record.title)
    print 'authors:', cur_record.authors
    print 'source:', string.strip(cur_record.source)
    print
Exemple #3
0
        elif opt == '-c':
            count_only = 1
        elif opt == '-d':
            try:
                delay = float(arg)
            except ValueError:
                print "Delay must be a floating point value"
                sys.exit(0)
            if delay < 0:
                print "Delay cannot be negative"
                sys.exit(0)
    if help:
        print_usage()
        sys.exit(0)

    print "Doing a PubMed search for %s..." % repr(query)

    ids = PubMed.search_for(query)
    print "Found %d citations" % len(ids)

    if count_only:
        sys.exit(0)

    pm = PubMed.Dictionary(delay=delay)
    for id in ids:
        try:
            print pm[id]
        except KeyError, x:
            print "Couldn't download %s, %s" % (id, x)
        sys.stdout.flush()