Sukanyaaa commited on
Commit
196c9bb
·
1 Parent(s): 4a3e49d

fix infewrence_app.py

Browse files
Files changed (1) hide show
  1. inference_app.py +30 -3
inference_app.py CHANGED
@@ -108,6 +108,33 @@ from pinder.core.structure.atoms import atom_array_from_pdb_file
108
  from pathlib import Path
109
  from pinder.eval.dockq.biotite_dockq import BiotiteDockQ
110
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
  log = setup_logger(__name__)
113
 
@@ -285,8 +312,8 @@ def create_graph(pdb1, pdb2, k=5):
285
  HeteroData: A PyG HeteroData object containing ligand and receptor data.
286
  """
287
  # Extract coordinates from PDB files
288
- coords1 = torch.tensor(atom_array_from_pdb_file(pdb1),dtype=torch.float)
289
- coords2 = torch.tensor(atom_array_from_pdb_file(pdb2),dtype=torch.float)
290
  # coords3 = torch.tensor(extract_coordinates_from_pdb(pdb3),dtype=torch.float)
291
  # Create the HeteroData object
292
  data = HeteroData()
@@ -881,7 +908,7 @@ def predict (input_seq_1, input_msa_1, input_protein_1, input_seq_2,input_msa_2,
881
  mat, vect = model(data)
882
  mat = mat.to(device)
883
  vect = vect.to(device)
884
- ligand1 = torch.tensor(atom_array_from_pdb_file(input_protein_1),dtype=torch.float).to(device)
885
  # receptor1 = torch.tensor(extract_coordinates_from_pdb(input_protein_2),dtype=torch.float).to(device)
886
  transformed_ligand = torch.matmul(ligand1, mat) + vect
887
  # transformed_receptor = torch.matmul(receptor1, mat) + vect
 
108
  from pathlib import Path
109
  from pinder.eval.dockq.biotite_dockq import BiotiteDockQ
110
 
111
+ def extract_coordinates_from_pdb(filename, atom_name="CA"):
112
+ """
113
+ Extracts coordinates for specific atoms from a PDB file and returns them as a list of tuples.
114
+ Each tuple contains (x, y, z) coordinates of the specified atom type.
115
+
116
+ Parameters:
117
+ filename (str): Path to the PDB file.
118
+ atom_name (str): The name of the atom to filter by (e.g., "CA" for alpha carbon).
119
+
120
+ Returns:
121
+ list of tuple: List of coordinates as (x, y, z) tuples for the specified atom.
122
+ """
123
+ parser = PDB.PDBParser(QUIET=True)
124
+ structure = parser.get_structure("structure", filename)
125
+
126
+ coordinates = []
127
+
128
+ # Loop through each model, chain, residue, and atom to collect coordinates of specified atom
129
+ for model in structure:
130
+ for chain in model:
131
+ for residue in chain:
132
+ for atom in residue:
133
+ # Filter for specific atom name
134
+ xyz = atom.coord # Coordinates are in a numpy array
135
+ coordinates.append([xyz[0], xyz[1], xyz[2]])
136
+
137
+ return coordinates
138
 
139
  log = setup_logger(__name__)
140
 
 
312
  HeteroData: A PyG HeteroData object containing ligand and receptor data.
313
  """
314
  # Extract coordinates from PDB files
315
+ coords1 = torch.tensor(extract_coordinates_from_pdb(pdb1),dtype=torch.float)
316
+ coords2 = torch.tensor(extract_coordinates_from_pdb(pdb2),dtype=torch.float)
317
  # coords3 = torch.tensor(extract_coordinates_from_pdb(pdb3),dtype=torch.float)
318
  # Create the HeteroData object
319
  data = HeteroData()
 
908
  mat, vect = model(data)
909
  mat = mat.to(device)
910
  vect = vect.to(device)
911
+ ligand1 = torch.tensor(extract_coordinates_from_pdb(input_protein_1),dtype=torch.float).to(device)
912
  # receptor1 = torch.tensor(extract_coordinates_from_pdb(input_protein_2),dtype=torch.float).to(device)
913
  transformed_ligand = torch.matmul(ligand1, mat) + vect
914
  # transformed_receptor = torch.matmul(receptor1, mat) + vect