<jupyter_start><jupyter_text>Create Mutant Given [1] a directory of pdb files and [2] residue mutations:- Mutate the residues- Minimize the structure- Save the pdbs to a new "output" directory<jupyter_code>import os
import subprocess<jupyter_output><empty_output><jupyter_text>Set directory and residue numbers<jupyter_code># DIRECTORY = '/Users/alexandertaguchi/Desktop/slink_no_helix/'
DIRECTORY = '/Users/alexandertaguchi/Desktop/slink_helix/'
# NAME = '36-38_53-55'
NAME = '41-45_139-145'
# RESIDUES = {18:'THR', 16:'SER', 4:'SER'}
RESIDUES = {4:'LEU', 6:'VAL', 8:'THR', 14:'THR', 16:'ARG', 18:'GLU'}<jupyter_output><empty_output><jupyter_text>Generate chimera script<jupyter_code># Paths to pdbs and output directory
pdbs = [x for x in os.listdir(DIRECTORY) if x[-4:] == '.pdb']
if not os.path.isdir(DIRECTORY + 'output'):
    os.mkdir(DIRECTORY + 'output')

# Write command script to file
with open(DIRECTORY + 'mutate.cmd', 'w') as file:
    file.write('#\n# Chimera command script to mutate peptide\n#\n')
    
    # Mutate residues
    mutate = ''.join([f'swapaa {value} #0:{key};\n' for key, value in RESIDUES.items()])
    
    # Loop over pdbs
    for pdb in pdbs:
        file.write(f'open {DIRECTORY + pdb};\n')
        file.write(mutate)
        file.write(f'minimize spec #0 nogui true\n'
                   f'write #0 {DIRECTORY}output/{pdb[:-4]}_{NAME}.pdb\n'
                   f'close #0\n')<jupyter_output><empty_output><jupyter_text>Run Chimera<jupyter_code>subprocess.call(['chimera', '--nogui', DIRECTORY + 'mutate.cmd'])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1568253968253968, 'fraction_numerical': 0.025396825396825397, 'mean_word_length': 4.415807560137457, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '447621', 'license': 'MIT', 'n_tokens_mistral': 629, 'n_tokens_neox': 585, 'n_words': 130, 'path': 'mutate.ipynb', 'repo_name': 'AlexTaguchi/chimera-scripts', 'size': '1575'}