Selecting part of an extracted ligand I have the PDB 6LU7.

I extracted the ligand using extract lig, org  and then the protein using extract prot, poly.  The ligand has three parts:  02J, PJE, and 010.

I want to select the 02J and 010 IN A SCRIPT and delete them.


I know how to do it by simply clicking, but want to incluse this in a script.
I know that structure way too well —SARS-COV-2 MPro.
In PyMOL command line
 remove resn 02J or 010

or
 cmd.remove('resn 02J or 010')

In python
 import pymol2
 with pymol2.PyMOL() as pymol:
      pymol.cmd.fetch('6LU7')
      pymol.cmd.remove('resn 02J or 010')
      pymol.cmd.save('6LU7.mod.pdb') 
      #or pdbblock = pymol.cmd.get_pdbstr()

From the sounds of it you'd like to make the peptidomimetic a peptide. If you wanted to do the horrid thing of making PJE, the capped side chain glutamine ketamide, into glutamine, the command to rename atoms is a multitude of cmd.alter('resn PJE and name &lt;atomname&gt;', 'name=&quot;&lt;newname&gt;&quot;) followed by a cmd.alter('resn PJE', 'resn=&quot;GLN&quot;') and lastly cmd.sort() to commit the changes. Not pretty, but is all in PyMOL.