-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBioinformatics_Tasks_Entrez.py.py
86 lines (65 loc) · 2.26 KB
/
Bioinformatics_Tasks_Entrez.py.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from Bio import Entrez
# 1st
Entrez.email = '[email protected]'
handle = Entrez.einfo()
result = handle.read()
handle.close()
print(result)
#2nd
Entrez.email = '[email protected]'
handle = Entrez.einfo()
record = Entrez.read(handle)
handle.close()
print(record.keys())
print(record['DbList'])
print(record.values())
print(record['DbList'])
# 3rd
Entrez.email = '[email protected]'
handle = Entrez.einfo(db='protein')
record = Entrez.read(handle)
handle.close()
print('Description: ',record['DbInfo']['Description'])
print('Count: ',record['DbInfo']['Count'])
print('LastUpdate: ',record['DbInfo']['LastUpdate'])
# 4th
Entrez.email = '[email protected]'
handle = Entrez.esummary(db='nlmcatalog',
id = '101660833')#id should be exist in db this is id of pubmed database
record = Entrez.read(handle)
handle.close()
info = record[0]['TitleMainList'][0]
print('Journal info\nid: {} \nTitle: {}'.format(record[0]['Id'],info['Title']))
# 5th
Entrez.email = '[email protected]'
handle = Entrez.esearch(db='pubmed',
term = 'biopython')
result = Entrez.read(handle)
handle.close()
print('Description: ',result['DbInfo']['Description'])
print('Count: ',(result['DbInfo']['Count']))
print('LastUpdate: ',(result['DbInfo']['LastUpdate']))
# 6th
'''
EFetch is what you use when you want to retrieve a full record from Entrez. This covers several possible databases '''
Entrez.email = '[email protected]'
handle = Entrez.efetch(db='nucleotide',
id = 'EU490707', rettype='gb',
retmode = 'text')
print(handle.read())
handle.close()
# 7th
# EGQuery provide counts for a search term in each of entre database(i.e a global query).
Entrez.email = '[email protected]'
handle = Entrez.egquery(term='biopython') #here can be any database name like pubmed or any other
recode = Entrez.read(handle)
handle.close()
for row in recode['eGQueryResult']:
print(row['DbName'],row['Count'])
# 8th
Entrez.email = '[email protected]'
handle = Entrez.espell(term='biopythooon') #here can be any database name like pubmed or any other
recode = Entrez.read(handle)
recode['Query']
'biopythooon'
print(recode['CorrectedQuery'])