hi everybody

Beema shafreen beema.shafreen at gmail.com
Tue Aug 21 00:59:39 EDT 2007


hi everybody, i have  written to fetch the url, and accesstje nm and np
entries
my code:
import re
import urllib2
import time
Gene_id=raw_input("Please enter the gene_id:")
fh = urllib2.urlopen('
http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=search&term='+Gene_id)
for line in fh.readlines():
        pattern = re.compile('(NM_\d+.\d{0,5})</a>.*(NP_\d+.\d{0,5})</a>')
        m = pattern.search(line)
        if m:
                nm_entry = m.group(1)
                np_entry =  m.group(2)
                length = len(np_entry)
                #data = raw_input("There are %s entry, They are:" %(length))
                fh1 = urllib2.urlopen('
http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val='+nm_entry)
                for line1 in fh1.readlines():
                        p1 = re.compile('source\s*(\d{1}.*\d+)')
                        m1 = p1.search(line1)
                        if m1:
                                seq = m1.group(1)
                                seq_len = seq.split('..')
                                print nm_entry, 'Length of NM_seq:',
seq_len[1],np_entry


                fh1.close()
fh.close()
time.sleep(2)

in my result :
Please enter the gene_id:
(after this i want to get the text and data) eg., there are 11 entries  and
the nm and np entry the final print statement. i have include the
highlighted text in code where it is repeaded since inside the looping
please check about the following code and post your comments and where is
include the text to get the result properly
#data = raw_input("There are %s entry, They are:" %(length))



regards
shafreen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20070821/c0a961a8/attachment.html>


More information about the Python-list mailing list