File size: 887 Bytes
fdaed96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import requests #type: ignore


def fold_protein_sequence(sequence):
    """
    Folds a protein sequence using the ESM Atlas API.
    - URL: https://api.esmatlas.com/foldSequence/v1/pdb/
    - Method: POST
    - Body: Raw sequence string (NOT JSON)
    - No API Token required.
    """
    api_url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
    
    print(f"Folding sequence ({len(sequence)} residues)...")

    try:
        # Note: 'data' argument sends raw body. Do not use 'json='.
        response = requests.post(api_url, data=sequence, verify=True)
        
        if response.status_code == 200:
            return response.text  # Returns PDB content directly
        else:
            print(f"API Error {response.status_code}: {response.text}")
            return None
            
    except Exception as e:
        print(f"Connection Failed: {e}")
        return None