Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# af2_min.py
import os
import sys
import subprocess
from paths import PDB_FILES
from os.path import exists
def activate_conda_env(env_name):
conda_init = "source /home/tiburon/anaconda3/etc/profile.d/conda.sh"
activate_command = f"conda activate {env_name} && python -c \"print('Environment activated')\""
full_command = f"{conda_init} && {activate_command}"
try:
result = subprocess.run(full_command, shell=True, check=True, executable="/bin/bash" if sys.platform != "win32" else None)
print(f"Conda environment '{env_name}' activated successfully.")
except subprocess.CalledProcessError as e:
print(f"Failed to activate conda environment '{env_name}': {e}")
def deactivate_conda_env():
conda_init = "source /home/tiburon/anaconda3/etc/profile.d/conda.sh"
deactivate_command = "conda deactivate && python -c \"print('Environment deactivated')\""
full_command = f"{conda_init} && {deactivate_command}"
try:
result = subprocess.run(full_command, shell=True, check=True, executable="/bin/bash" if sys.platform != "win32" else None)
print("Conda environment deactivated successfully.")
except subprocess.CalledProcessError as e:
print(f"Failed to deactivate conda environment: {e}")
# This is the first step in post-processing.
if len(sys.argv) < 2:
print("Usage: af2_min.py <pdb_id>")
raise
pdb = sys.argv[1].strip().lower()
if exists(f"{PDB_FILES}{pdb}"):
activate_conda_env('OpenMM')
af2_min_command = f'python3 OpenMM_mini.py -af2 -outD {PDB_FILES}{pdb}_af2_min {PDB_FILES}{pdb}/*.pdb'
try:
result = subprocess.run(af2_min_command, shell=True, check=True, executable="/bin/bash" if sys.platform != "win32" else None)
except subprocess.CalledProcessError as e:
print(f"Failed to run OpenMM_mini.py: {e}")
deactivate_conda_env()
else:
print(f"Need to download structures from source, put them in {PDB_FILES}{pdb}")