In [22]:
import numpy as np
import pandas as pd
from Bio.PDB.PDBParser import PDBParser
In [1]:
a = "/Users/weilu/Research/server/apr_2020/cornichon_cbd/chain_E/frags.mem"
with open(a) as f:
b = f.readlines()
pdb_list = [c.split()[0].split("/")[-1].split(".")[0] for c in b[4:]]
In [23]:
a = "/Users/weilu/Research/server/apr_2020/cornichon_cbd//chain_E/fraglib/1deka.gro"
In [24]:
parser = PDBParser()
# all_atom_pdb_file = "/Users/weilu/Research/server/feb_2020/compare_side_chain_with_and_without/side_chain_run1/256b/4_0/crystal_structure.pdb"
structure = parser.get_structure("x", a)
In [27]:
list(structure.get_residues())
Out[27]:
In [29]:
import sys
sys.path.insert(0, "/Users/weilu/openmmawsem/helperFunctions/")
from Pdb2GroLib import *
In [36]:
a = list(structure.get_residues())[0]
In [39]:
list(a.get_atoms())
Out[39]:
In [42]:
set()
Out[42]:
In [37]:
"CA" in a
Out[37]:
In [33]:
parser = PDBParser()
# all_atom_pdb_file = "/Users/weilu/Research/server/feb_2020/compare_side_chain_with_and_without/side_chain_run1/256b/4_0/crystal_structure.pdb"
structure = parser.get_structure("x", pdbFile)
In [35]:
list(structure.get_chains())
Out[35]:
In [32]:
pdbFile = "/Users/weilu/Research/server/apr_2020/cornichon_cbd/frag_in_cbd/pdbs/1AWC.pdb"
groFile = "/Users/weilu/Research/server/apr_2020/cornichon_cbd/frag_in_cbd/pdbs/1awcA.pdb"
chainID = "A"
Pdb2Gro(pdbFile, groFile, chainID.upper())
In [ ]:
def convert_all_atom_pdb_to_cbd_representation(all_atom_pdb_file, cbd_representation_file):
# from a all atom pdb.
# preserve N, CA, C, O, and place the CB at the center of mass of the side chain
parser = PDBParser()
# all_atom_pdb_file = "/Users/weilu/Research/server/feb_2020/compare_side_chain_with_and_without/side_chain_run1/256b/4_0/crystal_structure.pdb"
structure = parser.get_structure("x", all_atom_pdb_file)
x_com_dic = {}
for res in structure.get_residues():
chain = res.get_full_id()[2]
resID = res.get_full_id()[3][1]
x_com = get_side_chain_center_of_mass(res)
x_com_dic[f"{chain}{resID}"] = x_com
for res in structure.get_residues():
chain = res.get_full_id()[2]
resID = res.get_full_id()[3][1]
x_com = x_com_dic[f"{chain}{resID}"]
if res.resname == "GLY":
continue
res["CB"].set_coord(x_com)
io = PDBIO()
io.set_structure(structure)
class CBDRepresentationSelect(Select):
def accept_atom(self, atom):
if atom.id in ["N", "CA", "C", "O", "CB", "H"]:
return True
else:
return False
# cbd_representation_file = "/Users/weilu/Research/server/feb_2020/compare_side_chain_with_and_without/side_chain_run1/256b/4_0/cbd_representation.pdb"
io.save(cbd_representation_file, CBDRepresentationSelect())
return True