oucgc1996 commited on
Commit
84cc8ee
·
verified ·
1 Parent(s): 43e7765

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -29
app.py CHANGED
@@ -51,7 +51,7 @@ class MyDataset(Dataset):
51
  def __init__(self,dict_data) -> None:
52
  super(MyDataset,self).__init__()
53
  self.data=dict_data
54
- self.structure=pdb_structure(dict_data['structure'])
55
  def __getitem__(self, index):
56
  return self.data['text'][index], self.structure[index]
57
  def __len__(self):
@@ -178,34 +178,29 @@ class MyModel(nn.Module):
178
  return torch.softmax(output_feature,dim=1)
179
 
180
 
181
- def pdb_structure(Structure_index):
182
- created_folders = []
183
- SurfacePoitCloud_all = []
184
- for index in Structure_index:
185
- # structure_folder = join(temp_path, str(index)+".pdb")
186
- # created_folders.append(structure_folder)
187
- # pdb_file = join(pdb_path, f"{index}.pdb")
188
- # if os.path.exists(pdb_file):
189
- # shutil.copy2(pdb_file, structure_folder)
190
- # else:
191
- # print(f"PDB file not found for structure {index}")
192
- print("=================================Structure prediction========================")
193
- for i in tqdm(range(0, len(test_sequences))):
194
- command = ["curl", "-X", "POST", "-k", "--data", f"{test_sequences[i]}", "https://api.esmatlas.com/foldSequence/v1/pdb/"]
195
- result = subprocess.run(command, capture_output=True, text=True)
196
- # with open(os.path.join(pdb_path, f'{test_Structure_index[i]}.pdb'), 'w') as file:
197
- # file.write(result.stdout)
198
- coords, atname, pdbname, pdb_num = utils.parsePDB(result.stdout)
199
- atoms_channel = utils.atomlistToChannels(atname)
200
- radius = utils.atomlistToRadius(atname)
201
- PointCloudSurfaceObject = VolumeMaker.PointCloudSurface(device=device)
202
- coords = coords.to(device)
203
- radius = radius.to(device)
204
- atoms_channel = atoms_channel.to(device)
205
- SurfacePoitCloud = PointCloudSurfaceObject(coords, radius)
206
- feature = SurfacePoitCloud.view(pdb_num,-1,3).cpu()
207
- SurfacePoitCloud_all.append(feature)
208
- SurfacePoitCloud_all_tensor = torch.squeeze(torch.stack(SurfacePoitCloud_all),dim=1)
209
  return SurfacePoitCloud_all_tensor
210
 
211
  def ACE(file):
 
51
  def __init__(self,dict_data) -> None:
52
  super(MyDataset,self).__init__()
53
  self.data=dict_data
54
+ self.structure=pdb_structure(dict_data['test_sequences'])
55
  def __getitem__(self, index):
56
  return self.data['text'][index], self.structure[index]
57
  def __len__(self):
 
178
  return torch.softmax(output_feature,dim=1)
179
 
180
 
181
+ def pdb_structure(test_sequences):
182
+ # structure_folder = join(temp_path, str(index)+".pdb")
183
+ # created_folders.append(structure_folder)
184
+ # pdb_file = join(pdb_path, f"{index}.pdb")
185
+ # if os.path.exists(pdb_file):
186
+ # shutil.copy2(pdb_file, structure_folder)
187
+ # else:
188
+ # print(f"PDB file not found for structure {index}")
189
+ print("=================================Structure prediction========================")
190
+ command = ["curl", "-X", "POST", "-k", "--data", f"{test_sequences}", "https://api.esmatlas.com/foldSequence/v1/pdb/"]
191
+ result = subprocess.run(command, capture_output=True, text=True)
192
+ # with open(os.path.join(pdb_path, f'{test_Structure_index[i]}.pdb'), 'w') as file:
193
+ # file.write(result.stdout)
194
+ coords, atname, pdbname, pdb_num = utils.parsePDB(result.stdout)
195
+ atoms_channel = utils.atomlistToChannels(atname)
196
+ radius = utils.atomlistToRadius(atname)
197
+ PointCloudSurfaceObject = VolumeMaker.PointCloudSurface(device=device)
198
+ coords = coords.to(device)
199
+ radius = radius.to(device)
200
+ atoms_channel = atoms_channel.to(device)
201
+ SurfacePoitCloud = PointCloudSurfaceObject(coords, radius)
202
+ feature = SurfacePoitCloud.view(pdb_num,-1,3).cpu()
203
+ SurfacePoitCloud_all_tensor = torch.squeeze(torch.stack(feature),dim=1)
 
 
 
 
 
204
  return SurfacePoitCloud_all_tensor
205
 
206
  def ACE(file):