Skip to content

Commit

Permalink
Fix ESMFold API requests - disable SSL to avoid certificate errors (#81)
Browse files Browse the repository at this point in the history
* Disable SSL in for ESMFold API

* Disable SSL in `esmfold_apiquery.py`

* Formatting fix for linting

* Only suppress SSL warnings

* Fix linting
  • Loading branch information
naailkhan28 authored Jan 24, 2024
1 parent 9afd286 commit 859b9a6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ProteinCartography/esmfold_apiquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import argparse
import os
import sys
import warnings

# depends on api_utils.py
from api_utils import session_with_retry
from Bio import SeqIO
from requests.packages.urllib3.exceptions import InsecureRequestWarning

### NOTES
# ESMFold API example from website:
Expand Down Expand Up @@ -51,9 +53,11 @@ def post_esmfold_apiquery(fasta: str):
Args:
fasta (str): string of valid amino acids for query.
"""
# Here we're making the request with verify=False to disable SSL
# This may be a security concern, but is (hopefully)
# temporary until the ESM Atlas SSL certificates are fixed
result = session_with_retry().post(
"https://api.esmatlas.com/foldSequence/v1/pdb/",
data=fasta,
"https://api.esmatlas.com/foldSequence/v1/pdb/", data=fasta, verify=False
)
if result.status_code == 200:
return result.text
Expand Down Expand Up @@ -123,7 +127,12 @@ def main():

input_file = args.input
output_file = args.output
esmfold_apiquery(input_file, output_file)

# Ignore warnings when we make the ESMFold API request
# We're disabling SSL which `requests` will otherwise warn us about
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=InsecureRequestWarning)
esmfold_apiquery(input_file, output_file)


# check if called from interpreter
Expand Down

0 comments on commit 859b9a6

Please sign in to comment.