You can also save each chain and heteroatom in CHIMERA by doing “select:.a” -> GUI-> Save PDB and “select:.b”->GUI-> Save PDB
f = open('chainA.pdb','w')
f2= open('chainB.pdb','w')
pdb = open("1c1d.pdb","r")
for line in pdb:
if line[:4] == 'ATOM' and line[21:22] == "A":
f.write(line)
if line[:6] == 'HETATM' and line[21:22] == "A":
f.write(line)
if line[:4] =='ATOM' and line[21:22] =="B":
f2.write(line)
if line[:6] == 'HETATM' and line[21:22] == "B":
f2.write(line)