text: user4864: I'm trying to separate RNA from protein in a complex protein/RNA PDB file and I want all RNA info with the hetero atoms in between the bases BUT without H20 etc. In short I want RNA part of pdb file without discontinuous lines.
  I managed to separate RNA from protein with Bio PDB Select but it consider hetero atoms as amino acid when I use is_aa(residue). So hetero atoms wont appear in my "only RNA" file.
  from Bio.PDB import *
  from Bio.PDB import PDBParser, PDBIO, Select
  import os
  
  class ProtSelect(Select):
      def accept_residue(self, residue):
          return 1 if is_aa(residue) == True else 0
  
  class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if is_aa(residue) == False and residue.id[0] != "W" else 0
  
  pdb = PDBParser().get_structure("2bh2", "pdb2bh2.ent")
  io = PDBIO()
  io.set_structure(pdb)
  io.save("seqprotest.pdb", ProtSelect())
  io.save("seqRNAtest.pdb", RNASelect())
  
  EDIT: I managed to do it:
  class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if ((residue.id[0] != 'H_ MG') and ((residue.get_resname() == '  A' or residue.get_resname() == '  U' or   residue.get_resname() == '  G' or  residue.get_resname() == '  C' or residue.get_resname() == '  T') or  (residue.id[0][0:2] == 'H_' and (residue.get_resname()[2] == 'U'  or residue.get_resname()[2] == 'A' or residue.get_resname()[2] == 'C' or residue.get_resname()[2] == 'G' or residue.get_resname()[2] == 'T'))))  else 0
  
  It's not pretty but it do the job.
  The idea is to get everything that finish by a nucleotide. I figured out that hetatom's names of RNA chains always finish by a nucleotide letter so i just have to check everything that begins by 'H_' and ends by 'A,T,C,G,U'.
  Just remove 'H_ MG' and you're good.
  
  user4864: Solution I found: (c/p of body)
  class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if ((residue.id[0] != 'H_ MG') and ((residue.get_resname() == '  A' or residue.get_resname() == '  U' or   residue.get_resname() == '  G' or  residue.get_resname() == '  C' or residue.get_resname() == '  T') or  (residue.id[0][0:2] == 'H_' and (residue.get_resname()[2] == 'U'  or residue.get_resname()[2] == 'A' or residue.get_resname()[2] == 'C' or residue.get_resname()[2] == 'G' or residue.get_resname()[2] == 'T'))))  else 0
  
  It's not pretty but it do the job. The idea is to get everything that finish by a nucleotide. I figured out that hetatom's names of RNA chains always finish by a nucleotide letter so i just have to check everything that begins by 'H_' and ends by 'A,T,C,G,U'. Just remove 'H_ MG' and you're good.
  
original_text: 4864: <p>I'm trying to separate RNA from protein in a complex protein/RNA PDB file and I want all RNA info with the hetero atoms in between the bases BUT without H20 etc. In short I want RNA part of pdb file without discontinuous lines.</p>
  
  <p>I managed to separate RNA from protein with Bio PDB Select but it consider hetero atoms as amino acid when I use is_aa(residue). So hetero atoms wont appear in my "only RNA" file.</p>
  
  <pre><code>from Bio.PDB import *
  from Bio.PDB import PDBParser, PDBIO, Select
  import os
  
  class ProtSelect(Select):
      def accept_residue(self, residue):
          return 1 if is_aa(residue) == True else 0
  
  class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if is_aa(residue) == False and residue.id[0] != "W" else 0
  
  pdb = PDBParser().get_structure("2bh2", "pdb2bh2.ent")
  io = PDBIO()
  io.set_structure(pdb)
  io.save("seqprotest.pdb", ProtSelect())
  io.save("seqRNAtest.pdb", RNASelect())
  </code></pre>
  
  <p>EDIT: I managed to do it:</p>
  
  <pre><code>class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if ((residue.id[0] != 'H_ MG') and ((residue.get_resname() == '  A' or residue.get_resname() == '  U' or   residue.get_resname() == '  G' or  residue.get_resname() == '  C' or residue.get_resname() == '  T') or  (residue.id[0][0:2] == 'H_' and (residue.get_resname()[2] == 'U'  or residue.get_resname()[2] == 'A' or residue.get_resname()[2] == 'C' or residue.get_resname()[2] == 'G' or residue.get_resname()[2] == 'T'))))  else 0
  </code></pre>
  
  <p>It's not pretty but it do the job.
  The idea is to get everything that finish by a nucleotide. I figured out that hetatom's names of RNA chains always finish by a nucleotide letter so i just have to check everything that begins by 'H_' and ends by 'A,T,C,G,U'.
  Just remove 'H_ MG' and you're good.</p>
   4864: <p>Solution I found: (c/p of body)</p>
  
  <pre><code>class RNASelect(Select):
      def accept_residue(self, residue):
          return 1 if ((residue.id[0] != 'H_ MG') and ((residue.get_resname() == '  A' or residue.get_resname() == '  U' or   residue.get_resname() == '  G' or  residue.get_resname() == '  C' or residue.get_resname() == '  T') or  (residue.id[0][0:2] == 'H_' and (residue.get_resname()[2] == 'U'  or residue.get_resname()[2] == 'A' or residue.get_resname()[2] == 'C' or residue.get_resname()[2] == 'G' or residue.get_resname()[2] == 'T'))))  else 0
  </code></pre>
  
  <p>It's not pretty but it do the job. The idea is to get everything that finish by a nucleotide. I figured out that hetatom's names of RNA chains always finish by a nucleotide letter so i just have to check everything that begins by 'H_' and ends by 'A,T,C,G,U'. Just remove 'H_ MG' and you're good.</p>
  