Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Slice Syntax for tied_list for make_tied_positions_dict.py #27

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions examples/submit_example_5_new_protocol.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#SBATCH -p gpu
#SBATCH --mem=32g
#SBATCH --gres=gpu:rtx2080:1
#SBATCH -c 3
#SBATCH --output=example_5.out

source activate mlfold

folder_with_pdbs="../inputs/PDB_test_enzymes/8E0X/"

output_dir="../outputs/example_5_new_protocol_outputs"
if [ ! -d $output_dir ]
then
mkdir -p $output_dir
fi


path_for_parsed_chains=$output_dir"/parsed_pdbs.jsonl"
path_for_assigned_chains=$output_dir"/assigned_pdbs.jsonl"
path_for_fixed_positions=$output_dir"/fixed_pdbs.jsonl"
path_for_tied_positions=$output_dir"/tied_pdbs.jsonl"
chains_to_design="A B C D"
tied_positions="5:310 315:347, 2:307 312:344, 2:307 312:344, 1:306 311:343" #two list must match in length; residue 1 in chain A and C will be sampled togther;

python ../helper_scripts/parse_multiple_chains.py --input_path=$folder_with_pdbs --output_path=$path_for_parsed_chains

python ../helper_scripts/assign_fixed_chains.py --input_path=$path_for_parsed_chains --output_path=$path_for_assigned_chains --chain_list "$chains_to_design"

python ../helper_scripts/make_tied_positions_dict.py --input_path=$path_for_parsed_chains --output_path=$path_for_tied_positions --chain_list "$chains_to_design" --position_list "$tied_positions"

python ../protein_mpnn_run.py \
--jsonl_path $path_for_parsed_chains \
--chain_id_jsonl $path_for_assigned_chains \
--fixed_positions_jsonl $path_for_fixed_positions \
--tied_positions_jsonl $path_for_tied_positions \
--out_folder $output_dir \
--num_seq_per_target 2 \
--sampling_temp "0.1" \
--seed 37 \
--batch_size 1
18 changes: 16 additions & 2 deletions helper_scripts/make_tied_positions_dict.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import argparse

def parse_tied_str(tied_position_str):
tied_list = []
for one in tied_position_str.split(","):
one_list = []
for item in one.split():
if len(item.split(":")) == 1:
one_list.append(int(item.split(":")))
elif len(item.split(":")) == 2:
one_list.extend(list(range(int(item.split(":")[0]), int(item.split(":")[1]))))
else:
raise RuntimeError("Now we only support slice syntax(1:10, 2:11) and ordinary syntax(1 2, 2 3)")
tied_list.append(one_list)
return tied_list

def main(args):

import glob
Expand All @@ -14,7 +28,7 @@ def main(args):
homooligomeric_state = args.homooligomer

if homooligomeric_state == 0:
tied_list = [[int(item) for item in one.split()] for one in args.position_list.split(",")]
tied_list = parse_tied_str(args.position_list)
global_designed_chain_list = [str(item) for item in args.chain_list.split()]
my_dict = {}
for json_str in json_list:
Expand Down Expand Up @@ -49,7 +63,7 @@ def main(args):
argparser.add_argument("--input_path", type=str, help="Path to the parsed PDBs")
argparser.add_argument("--output_path", type=str, help="Path to the output dictionary")
argparser.add_argument("--chain_list", type=str, default='', help="List of the chains that need to be fixed")
argparser.add_argument("--position_list", type=str, default='', help="Position lists, e.g. 11 12 14 18, 1 2 3 4 for first chain and the second chain")
argparser.add_argument("--position_list", type=str, default='', help="Position lists, e.g. 11 12 14 18, 1 2 3 4 for first chain and the second chain. Slice is now supported.")
argparser.add_argument("--homooligomer", type=int, default=0, help="If 0 do not use, if 1 then design homooligomer")

args = argparser.parse_args()
Expand Down
Loading