diff --git a/app.py b/app.py index bbca4dc01b26593a7441f38f9fd7dbf7523f102f..0a67a46d72bed22e14a42d1ee40d67fc8ace0707 100644 --- a/app.py +++ b/app.py @@ -15,6 +15,10 @@ from rdkit import RDLogger from rdkit.Chem import MolFromSmiles, AddHs from torch_geometric.loader import DataLoader import yaml +import sys +import csv + +csv.field_size_limit(sys.maxsize) print(torch.__version__) os.makedirs("data/esm2_output", exist_ok=True) @@ -41,6 +45,8 @@ with open(f"workdir/paper_score_model/model_parameters.yml") as f: with open(f"workdir/paper_confidence_model/model_parameters.yml") as f: confidence_args = Namespace(**yaml.full_load(f)) +import shutil + t_to_sigma = partial(t_to_sigma_compl, args=score_model_args) model = get_model(score_model_args, device, t_to_sigma=t_to_sigma, no_parallel=True) @@ -66,30 +72,17 @@ state_dict = torch.load( confidence_model.load_state_dict(state_dict, strict=True) confidence_model = confidence_model.to(device) confidence_model.eval() -tr_schedule = get_t_schedule(inference_steps=10) -rot_schedule = tr_schedule -tor_schedule = tr_schedule -print("common t schedule", tr_schedule) -failures, skipped, confidences_list, names_list, run_times, min_self_distances_list = ( - 0, - 0, - [], - [], - [], - [], -) -N = 10 def get_pdb(pdb_code="", filepath=""): - if pdb_code is None or pdb_code == "": - try: - return filepath.name - except AttributeError as e: + try: + return filepath.name + except AttributeError as e: + if pdb_code is None or pdb_code == "": return None - else: - os.system(f"wget -qnc https://files.rcsb.org/view/{pdb_code}.pdb") - return f"{pdb_code}.pdb" + else: + os.system(f"wget -qnc https://files.rcsb.org/view/{pdb_code}.pdb") + return f"{pdb_code}.pdb" def get_ligand(smiles="", filepath=""): @@ -111,11 +104,23 @@ def read_mol(molpath): return mol -def molecule(input_pdb, ligand_pdb): +def molecule(input_pdb, ligand_pdb, original_ligand): structure = read_mol(input_pdb) mol = read_mol(ligand_pdb) + try: + ligand = read_mol(original_ligand.name) + _, ext = os.path.splitext(original_ligand.name) + lig_str_1 = """let original_ligand = `""" + ligand + """`""" + lig_str_2 = f""" + viewer.addModel( original_ligand, "{ext[1:]}" ); + viewer.getModel(2).setStyle({{stick:{{colorscheme:"greenCarbon"}}}});""" + except AttributeError as e: + ligand = None + lig_str_1 = "" + lig_str_2 = "" + x = ( """ @@ -134,11 +139,27 @@ def molecule(input_pdb, ligand_pdb): .mol-container select{ background-image:None; } + .green{ + width:20px; + height:20px; + background-color:#33ff45; + display:inline-block; + } + .magenta{ + width:20px; + height:20px; + background-color:magenta; + display:inline-block; + } - + +
+ Uploaded ligand position + Predicted ligand position +