Download model/comp_surface/prepare_target/input_output/protonate.py from OneScience-Group/SurfDock: direct link, hf CLI and curl.
- Browser
- Download file 1.13 kB
-
https://huggingface.co/OneScience-Group/SurfDock/resolve/main/model/comp_surface/prepare_target/input_output/protonate.py
- Command line
-
hf download hf://OneScience-Group/SurfDock/model/comp_surface/prepare_target/input_output/protonate.py
-
curl -L -o protonate.py https://huggingface.co/OneScience-Group/SurfDock/resolve/main/model/comp_surface/prepare_target/input_output/protonate.py
1.13 kB
| """ | |
| protonate.py: Wrapper method for the reduce program: protonate (i.e., add hydrogens) a pdb using reduce | |
| and save to an output file. | |
| Pablo Gainza - LPDI STI EPFL 2019 | |
| Released under an Apache License 2.0 | |
| """ | |
| from subprocess import Popen, PIPE | |
| from IPython.core.debugger import set_trace | |
| import os | |
| def protonate(in_pdb_file, out_pdb_file): | |
| # protonate (i.e., add hydrogens) a pdb using reduce and save to an output file. | |
| # in_pdb_file: file to protonate. | |
| # out_pdb_file: output file where to save the protonated pdb file. | |
| # Remove protons first, in case the structure is already protonated | |
| args = ["reduce", "-Trim", in_pdb_file] | |
| p2 = Popen(args, stdout=PIPE, stderr=PIPE) | |
| stdout, stderr = p2.communicate() | |
| outfile = open(out_pdb_file, "w") | |
| outfile.write(stdout.decode('utf-8').rstrip()) | |
| outfile.close() | |
| # Now add them again. | |
| args = ["reduce", "-HIS", out_pdb_file] | |
| p2 = Popen(args, stdout=PIPE, stderr=PIPE) | |
| stdout, stderr = p2.communicate() | |
| outfile = open(out_pdb_file, "w") | |
| outfile.write(stdout.decode('utf-8')) | |
| outfile.close() | |