42Cummer commited on
Commit
fdaed96
·
verified ·
1 Parent(s): 50f7884

Upload foldprotein.py

Browse files

protein folding using api

Files changed (1) hide show
  1. scripts/foldprotein.py +28 -0
scripts/foldprotein.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests #type: ignore
2
+
3
+
4
+ def fold_protein_sequence(sequence):
5
+ """
6
+ Folds a protein sequence using the ESM Atlas API.
7
+ - URL: https://api.esmatlas.com/foldSequence/v1/pdb/
8
+ - Method: POST
9
+ - Body: Raw sequence string (NOT JSON)
10
+ - No API Token required.
11
+ """
12
+ api_url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
13
+
14
+ print(f"Folding sequence ({len(sequence)} residues)...")
15
+
16
+ try:
17
+ # Note: 'data' argument sends raw body. Do not use 'json='.
18
+ response = requests.post(api_url, data=sequence, verify=True)
19
+
20
+ if response.status_code == 200:
21
+ return response.text # Returns PDB content directly
22
+ else:
23
+ print(f"API Error {response.status_code}: {response.text}")
24
+ return None
25
+
26
+ except Exception as e:
27
+ print(f"Connection Failed: {e}")
28
+ return None