Spaces:
Sleeping
Sleeping
fix inference_app.py
Browse files- inference_app.py +5 -5
inference_app.py
CHANGED
|
@@ -287,7 +287,7 @@ class PairedPDB(HeteroData): # type: ignore
|
|
| 287 |
return graph
|
| 288 |
|
| 289 |
#create_graph takes inputs apo_ligand, apo_residue and paired holo as pdb3(ground truth).
|
| 290 |
-
def create_graph(pdb1, pdb2,
|
| 291 |
r"""
|
| 292 |
Create a heterogeneous graph from two PDB files, with the ligand and receptor
|
| 293 |
as separate nodes, and their respective features and edges.
|
|
@@ -304,19 +304,19 @@ def create_graph(pdb1, pdb2, pdb3='/home/sukanya/iitm_bisect_pinder_submission/t
|
|
| 304 |
# Extract coordinates from PDB files
|
| 305 |
coords1 = torch.tensor(extract_coordinates_from_pdb(pdb1),dtype=torch.float)
|
| 306 |
coords2 = torch.tensor(extract_coordinates_from_pdb(pdb2),dtype=torch.float)
|
| 307 |
-
coords3 = torch.tensor(extract_coordinates_from_pdb(pdb3),dtype=torch.float)
|
| 308 |
# Create the HeteroData object
|
| 309 |
data = HeteroData()
|
| 310 |
|
| 311 |
# Define ligand node features
|
| 312 |
data["ligand"].x = torch.tensor(coords1, dtype=torch.float)
|
| 313 |
data["ligand"].pos = coords1
|
| 314 |
-
data["ligand"].y = torch.tensor(coords3[:len(coords1)], dtype=torch.float)
|
| 315 |
|
| 316 |
# Define receptor node features
|
| 317 |
data["receptor"].x = torch.tensor(coords2, dtype=torch.float)
|
| 318 |
data["receptor"].pos = coords2
|
| 319 |
-
data["receptor"].y = torch.tensor(coords3[len(coords1):], dtype=torch.float)
|
| 320 |
|
| 321 |
# Construct k-NN graph for ligand
|
| 322 |
ligand_edge_index = knn_graph(data["ligand"].pos, k=k)
|
|
@@ -890,7 +890,7 @@ model.eval()
|
|
| 890 |
def predict (input_seq_1, input_msa_1, input_protein_1, input_seq_2,input_msa_2, input_protein_2):
|
| 891 |
start_time = time.time()
|
| 892 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 893 |
-
data = create_graph(input_protein_1, input_protein_2,
|
| 894 |
|
| 895 |
with torch.no_grad():
|
| 896 |
mat, vect = model(data)
|
|
|
|
| 287 |
return graph
|
| 288 |
|
| 289 |
#create_graph takes inputs apo_ligand, apo_residue and paired holo as pdb3(ground truth).
|
| 290 |
+
def create_graph(pdb1, pdb2, k=5):
|
| 291 |
r"""
|
| 292 |
Create a heterogeneous graph from two PDB files, with the ligand and receptor
|
| 293 |
as separate nodes, and their respective features and edges.
|
|
|
|
| 304 |
# Extract coordinates from PDB files
|
| 305 |
coords1 = torch.tensor(extract_coordinates_from_pdb(pdb1),dtype=torch.float)
|
| 306 |
coords2 = torch.tensor(extract_coordinates_from_pdb(pdb2),dtype=torch.float)
|
| 307 |
+
# coords3 = torch.tensor(extract_coordinates_from_pdb(pdb3),dtype=torch.float)
|
| 308 |
# Create the HeteroData object
|
| 309 |
data = HeteroData()
|
| 310 |
|
| 311 |
# Define ligand node features
|
| 312 |
data["ligand"].x = torch.tensor(coords1, dtype=torch.float)
|
| 313 |
data["ligand"].pos = coords1
|
| 314 |
+
# data["ligand"].y = torch.tensor(coords3[:len(coords1)], dtype=torch.float)
|
| 315 |
|
| 316 |
# Define receptor node features
|
| 317 |
data["receptor"].x = torch.tensor(coords2, dtype=torch.float)
|
| 318 |
data["receptor"].pos = coords2
|
| 319 |
+
# data["receptor"].y = torch.tensor(coords3[len(coords1):], dtype=torch.float)
|
| 320 |
|
| 321 |
# Construct k-NN graph for ligand
|
| 322 |
ligand_edge_index = knn_graph(data["ligand"].pos, k=k)
|
|
|
|
| 890 |
def predict (input_seq_1, input_msa_1, input_protein_1, input_seq_2,input_msa_2, input_protein_2):
|
| 891 |
start_time = time.time()
|
| 892 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 893 |
+
data = create_graph(input_protein_1, input_protein_2, k=10)
|
| 894 |
|
| 895 |
with torch.no_grad():
|
| 896 |
mat, vect = model(data)
|