Created
June 16, 2017 20:09
-
-
Save leelasd/20ba02595f0e2557812a215d5c626495 to your computer and use it in GitHub Desktop.
Delete Clashes between water and protein
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Using BioPython Doing All the Manipulations | |
## | |
import numpy as np | |
from Bio.PDB import * | |
from Bio.KDTree import KDTree | |
parser_p = PDBParser() | |
parser_m = PDBParser() | |
#3eiy_stripped.pdb LSD_POPE.pdb | |
prot = parser_p.get_structure('CXCR4-A','./3eiy_stripped.pdb') | |
memb = parser_p.get_structure('POPE-M' ,'./onlyWater.pdb') | |
prot_atoms = [at for at in prot.get_atoms() ] | |
memb_atoms = [at for at in memb.get_atoms()] | |
prot_coos = np.array([at.coord for at in prot_atoms],np.float) | |
memb_coos = np.array([at.coord for at in memb_atoms],np.float) | |
clashes = [] | |
atom_kdtree = KDTree(3) | |
atom_kdtree.set_coords(memb_coos) | |
for p in range(len(prot_coos)): | |
atom_kdtree.search(prot_coos[p], 1.500) | |
res = list(atom_kdtree.get_indices()) | |
clashes = clashes + res | |
del_res = [memb_atoms[c].get_parent().get_id()[1] for c in clashes] | |
del_res = list(set(del_res)) | |
for chain in memb[0]: [chain.detach_child((' ', ids, ' ')) for ids in del_res] | |
io = PDBIO() | |
io.set_structure(memb) | |
#io.save('Cropped_MembranePOPE_wProtein.pdb') | |
io.save('watercropped.pdb') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment