# center_protein.py¶

Moves a given protein structure so its geometric center is located at (0,0,0)
USAGE:
python center_protein.py [which_model]

## Categories:¶

• core/data/io/find_pdb

## Program source:¶

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 import sys sys.path.append('../../../../../bin/') from pybioshell.core.data.io import find_pdb if len(sys.argv) < 2 : print(""" Moves a given protein structure so its geometric center is located at (0,0,0) USAGE: python center_protein.py [which_model] CATEGORIES: core/data/io/find_pdb KEYWORDS: PDB input; center protein; coordinates """) sys.exit() which_model = 0 if len(sys.argv) == 2 else int(sys.argv[2]) pdb_reader = find_pdb(sys.argv[1], "./") structure = pdb_reader.create_structure(which_model) cx, cy, cz, n = 0, 0, 0, 0 for ic in range(structure.count_chains()) : chain = structure[ic] for ir in range(chain.count_residues()) : resid = chain[ir] for ai in range(resid.count_atoms()) : cx += resid[ai].x cy += resid[ai].y cz += resid[ai].z n+=1.0 cx /= n cy /= n cz /= n print("# Center was:",cx,cy,cz) for ic in range(structure.count_chains()) : chain = structure[ic] for ir in range(chain.count_residues()) : resid = chain[ir] for ai in range(resid.count_atoms()) : resid[ai].x -= cx resid[ai].y -= cy resid[ai].z -= cz print(resid[ai].to_pdb_line())