The x, y, and z coordinates of atoms are provided in the PDB file. One way to extract them is by using the Biopython package . In this article, we will extract coordinates of C-alpha atoms for each residue from the PDB file using Biopython.
Let’s say we have a PDB file named ‘input.pdb‘.
#!/usr/bin/env python3 from Bio.PDB import * import numpy as np p=PDBParser() structure=p.get_structure('input', "input.pdb") for model in structure: for chain in model: CA_coord =  for residue in chain: CA_coord.append((residue['CA'].get_vector())) print(CA_coord)
Save this file as Python script, for example, as ‘ca_coord.py‘, keep your input file in the same directory or provide the full path in the script, and run it as: