text: user12433: I have a PDB file which contain two molecules (receptor and ligand).
  Each molecule will have its own header. All in ONE PDB file.
  ‌The header of receptor section looks like this (line 1-6 of the PDB file):
  HEADER rec.pdb
  REMARK original generated coordinate pdb file
  ATOM      1  N   GLY A   1     -51.221 -13.970  37.091  1.00  0.00      RA0  N
  ATOM      2  H   GLY A   1     -50.383 -13.584  37.482  1.00  0.00      RA0  H
  ATOM      3  CA  GLY A   1     -50.902 -15.071  36.197  1.00  0.00      RA0  C
  ATOM      4  C   GLY A   1     -49.525 -15.659  36.443  1.00  0.00      RA0  C
  
  and this ligand section (line   11435 to 11440) of the PDB file
  HEADER lig.000.00.pdb
  ATOM      1  N   MET A   1      27.318 -26.957  12.663  1.00  0.00      LA0  N
  ATOM      2  H   MET A   1      27.313 -27.570  11.870  1.00  0.00      LA0  H
  ATOM      3  CA  MET A   1      28.374 -27.102  13.668  1.00  0.00      LA0  C
  ATOM      4  CB  MET A   1      28.531 -28.564  14.090  1.00  0.00      LA0  C
  ATOM      5  CG  MET A   1      27.224 -29.154  14.628  1.00  0.00      LA0  C
  
  Note that the receptor and ligand section also contain the string RA0 and LA0
  at the 11th column of PDB file.
  What I want to do is to rename the chain of receptor as chain A and ligand as chain B.
  In order to do that I intended to extract both part into two different objects first,
  then rename the chain and finally put them together again.
  I tried this code with Bio3D.
  But doesn't work:
  library(bio3d)
  pdb_infile <- "myfile.pdb"
  
  pdb <- read.pdb(pdb_infile)
  receptor_segment.sele <- atom.select(pdb, segid = "RA0",  verbose = TRUE)
  receptor_pdb <- trim.pdb(pdb, receptor_segment.sele)
  ligand_segment.sele <- atom.select(pdb, segid = "LA0",  verbose = TRUE)
  ligand_pdb <- trim.pdb(pdb, ligand_segment.sele) # showed no entry
  
  What's the way to do it?
  I'm open to solution with R or Python.
  
  user266: Since this is not a correct PDB file, it can be interpreted differently by different PDB reading libraries. The most reliable way to change it would be to read it as plain text and change the chain ID to B in the lines that have segment ID LA0.
  Note: Strings RA0 and LA0 start at column 73. Columns in the PDB format correspond to characters. This is not a whitespace-delimited file.
  Chain ID is in column 22.
  Segment ID is in columns 73-76.
  As a side note, segment ID was only briefly part of the official PDB spec (around 1996), nevertheless it's supported by many programs.
  Of course, if you have only one file that you want to modify, the fastest way is to do it manually in a text editor.
  
original_text: 12433: <p>I have a PDB file which contain two molecules (receptor and ligand).
  Each molecule will have its own header. All in <strong>ONE</strong> PDB file.</p>
  <p>‌The header of receptor section looks like this (line 1-6 of the PDB file):</p>
  <pre><code>HEADER rec.pdb
  REMARK original generated coordinate pdb file
  ATOM      1  N   GLY A   1     -51.221 -13.970  37.091  1.00  0.00      RA0  N
  ATOM      2  H   GLY A   1     -50.383 -13.584  37.482  1.00  0.00      RA0  H
  ATOM      3  CA  GLY A   1     -50.902 -15.071  36.197  1.00  0.00      RA0  C
  ATOM      4  C   GLY A   1     -49.525 -15.659  36.443  1.00  0.00      RA0  C
  </code></pre>
  <p>and this ligand section (line   11435 to 11440) of the PDB file</p>
  <pre><code>HEADER lig.000.00.pdb
  ATOM      1  N   MET A   1      27.318 -26.957  12.663  1.00  0.00      LA0  N
  ATOM      2  H   MET A   1      27.313 -27.570  11.870  1.00  0.00      LA0  H
  ATOM      3  CA  MET A   1      28.374 -27.102  13.668  1.00  0.00      LA0  C
  ATOM      4  CB  MET A   1      28.531 -28.564  14.090  1.00  0.00      LA0  C
  ATOM      5  CG  MET A   1      27.224 -29.154  14.628  1.00  0.00      LA0  C
  </code></pre>
  <p>Note that the receptor and ligand section also contain the string <code>RA0</code> and <code>LA0</code>
  at the 11th column of PDB file.</p>
  <p>What I want to do is to rename the chain of receptor as chain A and ligand as chain B.
  In order to do that I intended to extract both part into two different objects first,
  then rename the chain and finally put them together again.</p>
  <p>I tried this code with <a href="http://thegrantlab.org/bio3d/" rel="nofollow noreferrer">Bio3D</a>.
  But doesn't work:</p>
  <pre><code>library(bio3d)
  pdb_infile &lt;- &quot;myfile.pdb&quot;
  
  pdb &lt;- read.pdb(pdb_infile)
  receptor_segment.sele &lt;- atom.select(pdb, segid = &quot;RA0&quot;,  verbose = TRUE)
  receptor_pdb &lt;- trim.pdb(pdb, receptor_segment.sele)
  ligand_segment.sele &lt;- atom.select(pdb, segid = &quot;LA0&quot;,  verbose = TRUE)
  ligand_pdb &lt;- trim.pdb(pdb, ligand_segment.sele) # showed no entry
  </code></pre>
  <p>What's the way to do it?
  I'm open to solution with R or Python.</p>
   266: <p>Since this is not a correct PDB file, it can be interpreted differently by different PDB reading libraries. The most reliable way to change it would be to read it as plain text and change the chain ID to <code>B</code> in the lines that have segment ID <code>LA0</code>.</p>
  <p>Note: Strings RA0 and LA0 start at column 73. Columns in the PDB format correspond to characters. This is not a whitespace-delimited file.</p>
  <p>Chain ID is in column 22.<br />
  Segment ID is in columns 73-76.</p>
  <p>As a side note, segment ID was only briefly part of the official PDB spec (around 1996), nevertheless it's supported by many programs.</p>
  <p>Of course, if you have only one file that you want to modify, the fastest way is to do it manually in a text editor.</p>
  