Skip to content

Commit 289e7e3

Browse files
authored
update file_exsits function to check file url in igvf portal (#53)
1 parent 2e19173 commit 289e7e3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

seqspec/utils.py

+10
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ def region_ids_in_spec(seqspec, modality, region_ids):
119119

120120
def file_exists(uri):
121121
try:
122+
if uri.startswith("https://api.data.igvf.org"):
123+
auth = get_remote_auth_token()
124+
if auth is None:
125+
print("Warning: IGVF_API_KEY and IGVF_SECRET_KEY not set")
126+
r = requests.head(uri, auth=auth)
127+
if r.status_code == 307:
128+
# igvf download link will redirect to a presigned amazon s3 url, HEAD request will not work.
129+
r = requests.get(r.headers["Location"], headers={"Range": "bytes=0-0"})
130+
return r.status_code == 206
131+
return r.status_code == 200
122132
r = requests.head(uri)
123133
if r.status_code == 302:
124134
return file_exists(r.headers["Location"])

0 commit comments

Comments
 (0)