Spaces:
Runtime error
Runtime error
Simon Duerr
commited on
Commit
•
fe26361
1
Parent(s):
0a6b286
change bfactor
Browse files
app.py
CHANGED
@@ -196,6 +196,21 @@ def prepare_input(input, jobname, baseconfig, hard_case):
|
|
196 |
|
197 |
return yaml.dump(yaml_dict).replace("'", "\""),os.path.join("/tmp/", f"{jobname}.zip")
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
def run_rf2aa(jobname, zip_archive):
|
200 |
current_dir = os.getcwd()
|
201 |
try:
|
@@ -203,20 +218,11 @@ def run_rf2aa(jobname, zip_archive):
|
|
203 |
zip_ref.extractall(os.path.join(current_dir))
|
204 |
os.system(f"python -m rf2aa.run_inference --config-name {jobname}.yaml --config-path {current_dir}/{jobname}")
|
205 |
# scale pLDDT to 0-100 range in pdb output file
|
206 |
-
|
207 |
-
structure = parser.get_structure(jobname, f"{current_dir}/{jobname}/{jobname}.pdb")
|
208 |
-
for model in structure:
|
209 |
-
for chain in model:
|
210 |
-
for residue in chain:
|
211 |
-
for atom in residue:
|
212 |
-
atom.bfactor = atom.bfactor * 100
|
213 |
-
io = PDBIO()
|
214 |
-
io.set_structure(structure)
|
215 |
-
io.save(f"{current_dir}/{jobname}/{jobname}.pdb")
|
216 |
|
217 |
except Exception as e:
|
218 |
raise gr.Error(f"Error running RFAA: {e}")
|
219 |
-
return f"{current_dir}/{jobname}/{jobname}.pdb"
|
220 |
|
221 |
|
222 |
|
@@ -287,7 +293,7 @@ with gr.Blocks() as demo:
|
|
287 |
runfiles = gr.File(label="files to run RFAA", visible=False)
|
288 |
instructions = gr.Markdown(visible=False)
|
289 |
|
290 |
-
|
291 |
|
292 |
btn.click(predict, inputs=[inp, jobname, dry_run, base_config, hard_case], outputs=[config_file, runfiles, instructions, out])
|
293 |
|
|
|
196 |
|
197 |
return yaml.dump(yaml_dict).replace("'", "\""),os.path.join("/tmp/", f"{jobname}.zip")
|
198 |
|
199 |
+
|
200 |
+
def convert_bfactors(pdb_path):
|
201 |
+
with open(pdb_path, 'r') as f:
|
202 |
+
lines = f.readlines()
|
203 |
+
for i,line in enumerate(lines):
|
204 |
+
# multiple each bfactor by 100
|
205 |
+
if line[0:6] == 'ATOM ' or line[0:6] == 'HETATM':
|
206 |
+
bfactor = float(line[60:66])
|
207 |
+
bfactor *= 100
|
208 |
+
line = line[:60] + f'{bfactor:6.2f}' + line[66:]
|
209 |
+
lines[i] = line
|
210 |
+
with open(pdb_path.replace(".pdb", "_processed.pdb"), 'w') as f:
|
211 |
+
f.write(''.join(lines))
|
212 |
+
|
213 |
+
|
214 |
def run_rf2aa(jobname, zip_archive):
|
215 |
current_dir = os.getcwd()
|
216 |
try:
|
|
|
218 |
zip_ref.extractall(os.path.join(current_dir))
|
219 |
os.system(f"python -m rf2aa.run_inference --config-name {jobname}.yaml --config-path {current_dir}/{jobname}")
|
220 |
# scale pLDDT to 0-100 range in pdb output file
|
221 |
+
convert_bfactors(f"{current_dir}/{jobname}/{jobname}.pdb")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
except Exception as e:
|
224 |
raise gr.Error(f"Error running RFAA: {e}")
|
225 |
+
return f"{current_dir}/{jobname}/{jobname}_processed.pdb"
|
226 |
|
227 |
|
228 |
|
|
|
293 |
runfiles = gr.File(label="files to run RFAA", visible=False)
|
294 |
instructions = gr.Markdown(visible=False)
|
295 |
|
296 |
+
out = Molecule3D(visible=False)
|
297 |
|
298 |
btn.click(predict, inputs=[inp, jobname, dry_run, base_config, hard_case], outputs=[config_file, runfiles, instructions, out])
|
299 |
|