Skip to content

Commit

Permalink
Merge pull request #1049 from griffithlab/iedb_api_no_data
Browse files Browse the repository at this point in the history
Retry when IEDB API returns no prediction data
  • Loading branch information
susannasiebert authored Jan 10, 2024
2 parents 2310013 + 5b405a1 commit 4ff2dc2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pvactools/lib/prediction_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from Bio import SeqIO
import random
import uuid
from datetime import datetime

class IEDB(metaclass=ABCMeta):
@classmethod
Expand Down Expand Up @@ -72,7 +73,11 @@ def predict(self, input_file, allele, epitope_length, iedb_executable_path, iedb

response = requests.post(self.url, data=data)
retries = 0
while (response.status_code == 500 or response.status_code == 403) and retries < iedb_retries:
while (response.status_code == 500 or response.status_code == 403 or response.text.count("\n") == 1) and retries < iedb_retries:
if response.text.count("\n") == 1:
print("No data returned. Retrying.")
print(datetime.now())
print(data)
random.seed(uuid.uuid4().int)
time.sleep(random.randint(30,90) * retries)
retries += 1
Expand Down

0 comments on commit 4ff2dc2

Please sign in to comment.