|
13 | 13 |
|
14 | 14 | class InteractionAnalyzer: |
15 | 15 | def __init__( |
16 | | - self, pdb_md, dataframe, num_processes, lig_name, special_ligand, peptide |
| 16 | + self, pdb_md, dataframe, num_processes, lig_name, special_ligand, peptide, md_len |
17 | 17 | ): |
18 | 18 | self.pdb_md = pdb_md |
19 | 19 | self.dataframe = dataframe |
20 | 20 | self.num_processes = num_processes |
21 | 21 | self.lig_name = lig_name |
22 | 22 | self.special = special_ligand |
23 | 23 | self.peptide = peptide |
| 24 | + self.md_len = md_len |
24 | 25 | self.ineraction_list = self.process_trajectory() |
25 | 26 |
|
26 | 27 | def characterize_complex( |
@@ -386,15 +387,14 @@ def fill_missing_frames(self, df): |
386 | 387 | pandas dataframe: DataFrame with placeholder values in the frames with no interactions. |
387 | 388 | """ |
388 | 389 |
|
389 | | - md_len = len(self.pdb_md.trajectory) - 1 |
390 | 390 | # Create a set containing all unique values in the 'FRAME' column |
391 | 391 | existing_frames = set(df["FRAME"]) |
392 | 392 |
|
393 | 393 | # Create a list to store new rows for missing numbers |
394 | 394 | missing_rows = [] |
395 | 395 |
|
396 | 396 | # Iterate through numbers from 0 to md_len |
397 | | - for frame_number in range(1, md_len): |
| 397 | + for frame_number in range(1, self.md_len): |
398 | 398 | if frame_number not in existing_frames: |
399 | 399 | # Create a new row with 'FRAME' set to the missing number and other columns set to "skip" |
400 | 400 | missing_row = {"FRAME": frame_number} |
@@ -428,17 +428,16 @@ def process_trajectory(self): |
428 | 428 | if self.dataframe is None: |
429 | 429 | print("\033[1mProcessing protein-ligand trajectory\033[0m") |
430 | 430 | print(f"\033[1mUsing {self.num_processes} CPUs\033[0m") |
431 | | - total_frames = len(self.pdb_md.trajectory) - 1 |
432 | 431 |
|
433 | 432 | with Pool(processes=self.num_processes) as pool: |
434 | 433 | frame_args = [ |
435 | 434 | (i, self.pdb_md, self.lig_name, self.special, self.peptide) |
436 | | - for i in range(1, total_frames + 1) |
| 435 | + for i in range(1, self.md_len) |
437 | 436 | ] |
438 | 437 |
|
439 | 438 | # Initialize the progress bar with the total number of frames |
440 | 439 | pbar = tqdm( |
441 | | - total=total_frames, |
| 440 | + total=self.md_len - 1, |
442 | 441 | ascii=True, |
443 | 442 | desc="\033[1mAnalyzing frames\033[0m", |
444 | 443 | ) |
|
0 commit comments