[Biopython] Fw: Entrez.efetch

Michiel de Hoon mjldehoon at yahoo.com
Mon Apr 19 03:08:04 EDT 2010


> I sent the mail to the biopython at biopython.org
> but it was not delivered.

It will be delivered if you subscribe to the mailing list.

--- On Mon, 4/19/10, olumide olufuwa <ludax5 at yahoo.com> wrote:

> From: olumide olufuwa <ludax5 at yahoo.com>
> Subject: Fw: [Biopython]Entrez.efetch
> To: biopython-owner at lists.open-bio.org
> Cc: "Biopython mailing list" <biopython at biopython.org>
> Date: Monday, April 19, 2010, 2:50 AM
> 
> 
> Hello Michel,
> I sent the mail to the biopython at biopython.org
> but it was not delivered. I have edited the message. 
> 
> 
> The code that 
> accepts UNIPROT ID, retrieves the record using
> Entrez.efetch and then it
>  parsed to obtain the Pubmed ID which i use to search
> Medline for the 
> Title, Abstract and other information about the entry. 
> The code:
> 
> query_id=str(raw_input("please
> 
> 
>  enter your UNIPROT_ID: ")) #Request UNIPROT ID from user
> Entrez.email="ludax5 at yahoo.com"
> prothandle=Entrez.efetch(db="protein",
> 
> 
>  id=query_id, rettype="gb" #queries Protein DB with the
> given ID
> #The
>  program returns an error here if a wrong ID is given.
> Details of the 
> error is given below
> seq_record=SeqIO.read(prothandle, "gb")
> for
> 
>  record in seq_record.annotations['references']: # To
> obtain Pubmed id 
> from the seqrecord
>    key_word=record.pubmed_id
>    if key_word:
>     
>  handle=Entrez.efetch(db="pubmed",
> 
>  id=key_word, rettype="medline")
>      
> medRecords=Medline.parse(handle)
>      for rec in medRecords: #prints 
> title and Abstract
>          if rec.has_key('AB') and 
> rec.has_key('TI'):
>            print "TITLE: ",rec['TI']
>           
>  print "ABSTRACT: ",rec['AB']
>            print ' '
> 
> 
> THE 
> PROBLEM: The program gives an error if a wrong ID is
> entered or an ID 
> other than UNIPROT ID e.g PDB ID, GSS ID etc. 
> 
> 
> 
> An Example Run:
> 
> 
> please enter your UNIPROT_ID:
>  1wio #A PDB ID is given instead
> 
> 
> Traceback (most recent call last):
>   File "file.py", line 11, in 
> <module>
>     seq_record=SeqIO.read(prothandle, "gb")
>   File 
> "/usr/lib/python2.5/site-packages/Bio/SeqIO/__init__.py",
> line 522, in 
> read
>     raise ValueError("No records found in handle")
> ValueError:
> 
>  No records found in handle
> 
> I want to avoid this error, thus i 
> want the program to print "INCORRECT ID GIVEN"  when a
> wrong or an 
> incorrect ID is given.
> 
> 
> Thanks a lot.
> lummy
> 
> 
> 
> 


      



More information about the Biopython mailing list