Created
November 18, 2024 05:30
-
-
Save ljmartin/eaeeb435c8512cd37352abca339142b9 to your computer and use it in GitHub Desktop.
Boltz1 on Modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sequences: | |
- protein: | |
id: [A, B] | |
sequence: MVTPEGNVSLVDESLLVGVTDEDRAVRSAHQFYERLIGLWAPAVMEAAHELGVFAALAEAPADSGELARRLDCDARAMRVLLDALYAYDVIDRIHDTNGFRYLLSAEARECLLPGTLFSLVGKFMHDINVAWPAWRNLAEVVRHGARDTSGAESPNGIAQEDYESLVGGINFWAPPIVTTLSRKLRASGRSGDATASVLDVGCGTGLYSQLLLREFPRWTATGLDVERIATLANAQALRLGVEERFATRAGDFWRGGWGTGYDLVLFANIFHLQTPASAVRLMRHAAACLAPDGLVAVVDQIVDADREPKTPQDRFALLFAASMTNTGGGDAYTFQEYEEWFTAAGLQRIETLDTPMHRILLARRATEPSAVPEGQASENLYFQ | |
msa: ./seq1.a3m | |
- ligand: | |
id: [C, D] | |
ccd: SAH | |
- ligand: | |
id: [E, F] | |
smiles: N[C@@H](Cc1ccc(O)cc1)C(=O)O |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import modal | |
image = ( | |
modal.Image.debian_slim() | |
.pip_install("uv") | |
.run_commands("uv pip install --system --compile-bytecode boltz") | |
.apt_install("wget") | |
.run_commands('mkdir /root/.boltz/') | |
.run_commands('wget -O /root/.boltz/ccd.pkl "https://www.dropbox.com/scl/fi/h4mjhcbhzzkkj4piu1k6x/ccd.pkl?rlkey=p43trjrs9ots4qk84ygk24seu&st=bymcsoqe&dl=1"') | |
.run_commands('wget -O /root/.boltz/boltz1.ckpt "https://www.dropbox.com/scl/fi/8qo9aryyttzp97z74dchn/boltz1.ckpt?rlkey=jvxl2jsn0kajnyfmesbj4lb89&st=dipi1sbw&dl=1"') | |
) | |
app = modal.App(name="boltzrun", image=image) | |
@app.function( | |
timeout = 60*5, # 5 mins - increase obviously for bigger or multiple runs. | |
gpu="A100" # got OOMs with anything smaller than A100 on example yaml. | |
) | |
def boltzrun(msadata, ligandyaml): | |
# save MSA and input YAML into instance: | |
with open('./seq1.a3m', 'w') as f: | |
f.write(msadata) | |
with open('./ligand.yaml', 'w') as f: | |
f.write(ligandyaml) | |
import os | |
# run boltz: | |
os.system('boltz predict ligand.yaml') | |
# package outputs: | |
os.system("tar czvf temp.tar.gz boltz_results_ligand") | |
# load outputs as binary data and return it | |
output = open('./temp.tar.gz', 'rb').read() | |
return output | |
@app.local_entrypoint() | |
def main(): | |
msadata = open('../boltz/examples/msa/seq1.a3m').read() | |
ligandyaml = open('./ligand.yaml').read() | |
#receive binary data: | |
output = boltzrun.remote(msadata, ligandyaml) | |
#write | |
with open('./result.tar.gz', 'wb') as f: | |
f.write(output) | |
#now you unpack outside of the script with 'tar xzvf result.tar.gz' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment