-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (28 loc) · 1.07 KB
/
test.py
File metadata and controls
32 lines (28 loc) · 1.07 KB
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
import requests
# Define the URL for the UCSC Table Browser
url = "https://genome.ucsc.edu/cgi-bin/hgTables"
# Set up the POST data parameters
data = {
"clade": "vertebrate",
"org": "Zebrafish",
"db": "danRer11",
"hgta_group": "genes",
"hgta_track": "refSeqComposite",
"hgta_table": "ncbiRefSeq",
"hgta_regionType": "genome",
"position": "",
"hgta_outputType": "primaryTable",
"hgta_outFileName": "", # Leave empty to get the output inline
"boolshad.doNotRedirect": "1", # Prevent redirection
"hgta_doTopSubmit": "get output" # Trigger the data retrieval
}
# Make the POST request
response = requests.post(url, data=data)
# Check if the response is successful
if response.status_code == 200 and b'HGERROR-START' not in response.content:
# Save the content to a file
with open("ucsc_refseq.tsv", "wb") as f:
f.write(response.content)
print("✅ Data downloaded successfully as ucsc_refseq.tsv")
else:
print("❌ Failed to retrieve data. Please check the parameters and try again.")