forked from buithuytien/GeneCloudOmics
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgetFASTA.py
30 lines (24 loc) · 814 Bytes
/
getFASTA.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
import requests
import os, sys
count = 0
size = len(Protein_id)
print(size)
for id in Protein_id:
url = "https://www.uniprot.org/uniprot/" + id + ".fasta"
try:
r = requests.get(url,timeout=10)
r.raise_for_status()
except requests.exceptions.HTTPError as errh:
print ("Http Error:",errh)
except requests.exceptions.ConnectionError as errc:
print ("Error Connecting:",errc)
except requests.exceptions.Timeout as errt:
print ("Timeout Error:",errt)
except requests.exceptions.RequestException as err:
print ("OOps: Something Else",err)
dir = os.getcwd() + "/donwload.fasta"
if r.status_code == 200:
count += 1
print(id + " downloaded Successfully")
with open(dir,'ab+') as f:
f.write(r.content)