OSError: The topology is loaded by filename extension, and the detected ".pd" format is not supported

Viewed 16

I'm writing a code to generate features of ligands. Code is:

def parsePDB(self):
    top = self.pdb.topology
    residues = [str(residue)[:3] for residue in top.residues]
    residues_cp = residues.copy()

    # number of all groups in the complex except the ligand
    LIG_number = residues.index('LIG')
    self.residues_indices = [i for i in range(top.n_residues) if i != LIG_number]

    # Get the types of atoms in the protein and ligand
    self.rec_indices = top.select('protein')
    self.lig_indices = top.select('resname LIG')
    table, bond = top.to_dataframe()
    self.all_ele = table['element']
    self.lig_ele = table['element'][self.lig_indices]
    
    H_num = []
    for num, i in enumerate(self.all_ele):
        if i == 'H':
            H_num.append(num)

    # Get the serial number of the atom in each residue or group
    removes = []
    for i in self.residues_indices:
        atoms = top.residue(i).atoms
        each_atoms = [j.index for j in atoms]
        heavy_atoms = [x for x in each_atoms if not x in H_num]
        
        if len(heavy_atoms) == 0:
            removes.append(i)
        else:
            self.atoms_indices.append(heavy_atoms)
    
    if len(removes) != 0:
        for i in removes:
            self.residues_indices.remove(i)
    self.residues = [residues_cp[x] for x in self.residues_indices]

    # Get the 3D coordinates for all atoms
    self.xyz = self.pdb.xyz[0]
    
    return self

I'm getting this error:

OSError: The topology is loaded by filename extension, and the detected ".pd" format is not supported. Supported topology formats include ".pdb", ".pdb.gz", ".h5", ".lh5", ".prmtop", ".parm7", ".prm7", ".psf", ".mol2", ".hoomdxml", ".gro", ".arc", ".hdf5" and ".gsd".

Can anyone please suggest me how to resolve this issue? Thanks

0 Answers
Related