(pdb)
| 24 | # protein gym datasets |
| 25 | |
| 26 | def bio_load_pdb(pdb): |
| 27 | # Load raw pdb file with biopython |
| 28 | parser = PDBParser(QUIET=True) |
| 29 | protein = parser.get_structure(0, pdb) |
| 30 | residues = [residue for residue in protein.get_residues()] |
| 31 | residue_type = [data.Protein.residue2id.get(residue.get_resname(), 0) for residue in residues] |
| 32 | residue_number = [residue.full_id[3][1] for residue in residues] |
| 33 | id2residue = {residue.full_id: i for i, residue in enumerate(residues)} |
| 34 | residue_feature = functional.one_hot(torch.as_tensor(residue_type), len(data.Protein.residue2id)+1) |
| 35 | |
| 36 | atoms = [atom for atom in protein.get_atoms()] |
| 37 | atoms = [atom for atom in atoms if atom.get_name() in data.Protein.atom_name2id] |
| 38 | occupancy = [atom.get_occupancy() for atom in atoms] |
| 39 | b_factor = [atom.get_bfactor() for atom in atoms] |
| 40 | atom_type = [data.feature.atom_vocab.get(atom.get_name()[0], 0) for atom in atoms] |
| 41 | atom_name = [data.Protein.atom_name2id.get(atom.get_name(), 37) for atom in atoms] |
| 42 | node_position = np.stack([atom.get_coord() for atom in atoms], axis=0) |
| 43 | node_position = torch.as_tensor(node_position) |
| 44 | atom2residue = [id2residue[atom.get_parent().full_id] for atom in atoms] |
| 45 | |
| 46 | edge_list = [[0, 0, 0]] |
| 47 | bond_type = [0] |
| 48 | |
| 49 | return data.Protein(edge_list, atom_type=atom_type, bond_type=bond_type, residue_type=residue_type, |
| 50 | num_node=len(atoms), num_residue=len(residues), atom_name=atom_name, |
| 51 | atom2residue=atom2residue, occupancy=occupancy, b_factor=b_factor, |
| 52 | residue_number=residue_number, node_position=node_position, residue_feature=residue_feature |
| 53 | ), "".join([data.Protein.id2residue_symbol[res] for res in residue_type]) |
| 54 | |
| 55 | |
| 56 | @R.register("datasets.ProteinGym") |
nothing calls this directly
no outgoing calls
no test coverage detected