-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_IDs.py
35 lines (26 loc) · 1.06 KB
/
Get_IDs.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
from Bio import Entrez
Entrez.email = "[email protected]"
Entrez.tool = "MyLocalScript"
def get_retMax(DataBase, TermQuery):
handle = Entrez.esearch(db=DataBase, term=TermQuery)
record = Entrez.read(handle)
handle.close()
return record["Count"]
def get_All_PMIDs(DataBase, TermQuery, retMaxNo):
handle = Entrez.esearch(db=DataBase, term=TermQuery, retMax=retMaxNo)
record = Entrez.read(handle)
handle.close()
print("-------------> ", record)
return record["IdList"]
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
db = "pubmed"
term = "mir145"
retMax = get_retMax(db, term)
print("retMax :: ", retMax)
pubmed_id_list = get_All_PMIDs(db, term, int(retMax))
print("Number of PubMed database titles = ", get_retMax(db, term))
if(int(retMax) != 0):
print("PubMed Database = ", pubmed_id_list)
else:
print("No documents match your search terms.")