|
17 | 17 | import warnings |
18 | 18 | warnings.filterwarnings('ignore', category=FutureWarning) |
19 | 19 | warnings.filterwarnings('ignore', category=DeprecationWarning) |
| 20 | +from rank_pep_plddt import rank_peptide_plddt |
20 | 21 | ### |
21 | 22 | import argparse |
| 23 | +from run_prediction_ig_patch import ( |
| 24 | + add_ig_pipeline_args, setup_ig_pipeline, process_target_with_ig_pipeline, |
| 25 | +) |
22 | 26 |
|
23 | 27 | parser = argparse.ArgumentParser( |
24 | 28 | description="Run simple template-based alphafold inference", |
|
71 | 75 | parser.add_argument('--no_initial_guess', action='store_true', default=False, help='When active, no intial guess is used to direct modeling and only template is used.') |
72 | 76 | parser.add_argument('--return_all_outputs', action='store_true', default=False, help='Save all alphafold outputs including evoformer output') |
73 | 77 | parser.add_argument('--use_msa', action='store_true', default=False, help='If Enabled, use MSA for prediction. If not, only template is used.') |
| 78 | +parser = add_ig_pipeline_args(parser) |
| 79 | +parser.add_argument('--pep_sampling', type=str, default=None, |
| 80 | + help='Peptide sampling scope: "all", "anchors", or comma-separated ' |
| 81 | + '1-indexed peptide positions e.g. "2,5,9"') |
74 | 82 | args = parser.parse_args() |
75 | 83 |
|
76 | 84 | import os |
|
108 | 116 | num_recycle = args.num_recycles[0], |
109 | 117 | args = args |
110 | 118 | ) |
111 | | - |
| 119 | +ig_config = setup_ig_pipeline(args) |
112 | 120 | final_dfl = [] |
113 | 121 | for counter, targetl in targets.iterrows(): |
114 | 122 | print('START:', counter, 'of', targets.shape[0]) |
|
191 | 199 | msa = [query_sequence] + msa |
192 | 200 |
|
193 | 201 |
|
194 | | - |
195 | | - |
196 | | - all_metrics = predict_utils.run_alphafold_prediction( |
197 | | - query_sequence=query_sequence, |
198 | | - msa=msa, |
199 | | - deletion_matrix=deletion_matrix, |
200 | | - chainbreak_sequence=query_chainseq, |
201 | | - template_features=all_template_features, |
202 | | - model_runners=model_runners, |
203 | | - out_prefix=outfile_prefix, |
204 | | - crop_size=crop_size, |
205 | | - dump_pdbs = not (args.no_pdbs or args.terse), |
206 | | - dump_metrics = not args.terse, |
207 | | - template_pdb_dict = template_pdb_dict, # added by Amir for getting pandora data |
208 | | - no_initial_guess=args.no_initial_guess, |
209 | | - return_all_outputs=args.return_all_outputs |
| 202 | + # ── Build peptide mask per-target if sampling requested ── |
| 203 | + all_metrics = process_target_with_ig_pipeline( |
| 204 | + args, ig_config, targetl, query_sequence, query_chainseq, |
| 205 | + all_template_features, model_runners, outfile_prefix, |
| 206 | + crop_size, msa, deletion_matrix, |
| 207 | + ) |
| 208 | + # -------- End of V2 after sampling mode -------------- # |
| 209 | + all_metrics = process_target_with_ig_pipeline( |
| 210 | + args, ig_config, targetl, query_sequence, query_chainseq, |
| 211 | + all_template_features, model_runners, outfile_prefix, |
| 212 | + crop_size, msa, deletion_matrix, |
210 | 213 | ) |
211 | 214 |
|
212 | | - |
| 215 | + # ── Rank sampled structures by peptide pLDDT ── |
| 216 | + if getattr(args, 'pep_sampling', None) is not None: |
| 217 | + for model_name in args.model_names: |
| 218 | + npz_path = f'{outfile_prefix}_{model_name}_sampling_results.npz' |
| 219 | + if os.path.exists(npz_path): |
| 220 | + rank_peptide_plddt(npz_path, query_chainseq) |
213 | 221 | outl = targetl.copy() |
214 | 222 | for model_name, metrics in all_metrics.items(): |
215 | 223 | plddts = metrics['plddt'] |
|
0 commit comments