I have a PDB file (2i0q.pdb), and I must extract the A chain from the PDB file to another file called "A.pdb" which I have already done successfully. Next, I have to take A.pdb and extract each alpha carbon ("CA") into another file. I have tried to write the function that does this, but my output file "CA.txt" appears to be blank. Can someone see what I have done wrong?
from Bio.PDB import *
parser=PDBParser()
structure=parser.get_structure('X', '2i0q.pdb')
#This extracts each chain in the PDB file into its own separate file
for chain in structure.get_chains():
io.set_structure(chain)
io.save(chain.get_id() + ".pdb")
structure_2 = parser.get_structure('Y', 'A.pdb')
def CA(structure):
f = open('CA.txt', 'w')
for atom in structure:
if atom =='CA':
f.write(atom)
CA(structure_2)
This works. Thank you very much!