(self, index)
| 97 | self.sequences.append(protein.to_sequence() if protein else None) |
| 98 | |
| 99 | def get_item(self, index): |
| 100 | if getattr(self, "lazy", False): |
| 101 | protein = data.Protein.from_pdb(self.pdb_files[index], **self.kwargs) |
| 102 | else: |
| 103 | protein = self.data[index].clone() |
| 104 | protein = protein.subgraph(protein.atom_name < 37) |
| 105 | |
| 106 | with protein.atom(): |
| 107 | # Init atom14 index map |
| 108 | protein.atom14index = rotamer.restype_atom14_index_map[ |
| 109 | protein.residue_type[protein.atom2residue], protein.atom_name |
| 110 | ] # [num_atom, 14] |
| 111 | |
| 112 | with protein.residue(): |
| 113 | # Init residue features |
| 114 | protein.residue_feature = functional.one_hot(protein.residue_type, 21) # [num_residue, 21] |
| 115 | |
| 116 | # Init residue masks |
| 117 | chi_mask = get_chi_mask(protein) |
| 118 | chi_1pi_periodic_mask = torch.tensor(rotamer.chi_pi_periodic)[protein.residue_type] |
| 119 | chi_2pi_periodic_mask = ~chi_1pi_periodic_mask |
| 120 | protein.chi_mask = chi_mask |
| 121 | protein.chi_1pi_periodic_mask = torch.logical_and(chi_mask, chi_1pi_periodic_mask) # [num_residue, 4] |
| 122 | protein.chi_2pi_periodic_mask = torch.logical_and(chi_mask, chi_2pi_periodic_mask) # [num_residue, 4] |
| 123 | |
| 124 | # Init atom37 features |
| 125 | protein.atom37_mask = torch.zeros(protein.num_residue, len(atom_name_vocab), device=protein.device, |
| 126 | dtype=torch.bool) # [num_residue, 37] |
| 127 | protein.atom37_mask[protein.atom2residue, protein.atom_name] = True |
| 128 | protein.sidechain37_mask = protein.atom37_mask.clone() # [num_residue, 37] |
| 129 | protein.sidechain37_mask[:, bb_atom_name] = False |
| 130 | item = {"graph": protein} |
| 131 | |
| 132 | if self.transform: |
| 133 | item = self.transform(item) |
| 134 | return item |
| 135 | |
| 136 | @staticmethod |
| 137 | def from_pdb_files(pdb_files, verbose=1, **kwargs): |
nothing calls this directly
no test coverage detected