In [1]:
import os
import sys
import random
import time
from random import seed, randint
import argparse
import platform
from datetime import datetime
import imp
import numpy as np
import fileinput
from itertools import product
import pandas as pd
from scipy.interpolate import griddata
from scipy.interpolate import interp2d
import seaborn as sns
from os import listdir

import matplotlib.pyplot as plt
import seaborn as sns
from scipy.interpolate import griddata
import matplotlib as mpl
# sys.path.insert(0,'..')
# from notebookFunctions import *
# from .. import notebookFunctions
from Bio.PDB.Polypeptide import one_to_three
from Bio.PDB.Polypeptide import three_to_one
from Bio.PDB.PDBParser import PDBParser
from pyCodeLib import *
from small_script.myFunctions import *
sys.path.insert(0, "/Users/weilu/openmmawsem")
from helperFunctions.myFunctions import *
from collections import defaultdict
%matplotlib inline
# plt.rcParams['figure.figsize'] = (10,6.180)    #golden ratio
# %matplotlib notebook
%load_ext autoreload
%autoreload 2

In [2]:
frag_name = "/Users/weilu/Research/server/mar_2020/mass_iterative_run/setups/1a1x/1a1x.gro"
frag = pd.read_csv(frag_name, skiprows=2, sep="\s+", header=None, names=["Res_id", "Res", "Type", "i", "x", "y", "z"])

In [ ]:
def get_side_chain_center_of_mass(atoms):
    # ensure complete first
    total = np.array([0., 0., 0.])
    total_mass = 0
    for atom in atoms:
        if atom.get_name() in ["N", "CA", "C", "O", "OXT"]:
            continue
        if atom.element == "H":
            continue
        total += atom.mass * atom.get_coord()
        total_mass += atom.mass
        # print(atom.get_name(), atom.get_coord())
    x_com = total / total_mass
    return x_com

In [3]:
frag


Out[3]:
Res_id Res Type i x y z
0 1 ALA N 1 0.943 2.721 3.690
1 1 ALA H 2 1.019 2.802 3.646
2 1 ALA H2 3 0.840 2.775 3.664
3 1 ALA H3 4 0.971 2.717 3.806
4 1 ALA CA 5 0.956 2.591 3.617
5 1 ALA HA 6 0.924 2.604 3.503
6 1 ALA C 7 0.877 2.485 3.693
7 1 ALA O 8 0.927 2.426 3.789
8 1 ALA CB 9 1.104 2.550 3.606
9 1 ALA HB1 10 1.163 2.608 3.519
10 1 ALA HB2 11 1.114 2.435 3.571
11 1 ALA HB3 12 1.176 2.558 3.701
12 2 GLY N 13 0.754 2.461 3.649
13 2 GLY H 14 0.730 2.460 3.532
14 2 GLY CA 15 0.668 2.365 3.715
15 2 GLY HA2 16 0.587 2.314 3.644
16 2 GLY HA3 17 0.723 2.271 3.764
17 2 GLY C 18 0.585 2.439 3.818
18 2 GLY O 19 0.518 2.376 3.899
19 3 GLU N 20 0.591 2.572 3.814
20 3 GLU H 21 0.592 2.617 3.704
21 3 GLU CA 22 0.518 2.659 3.906
22 3 GLU HA 23 0.461 2.587 3.982
23 3 GLU C 24 0.409 2.738 3.835
24 3 GLU O 25 0.407 2.748 3.712
25 3 GLU CB 26 0.612 2.762 3.970
26 3 GLU HB2 27 0.664 2.822 3.881
27 3 GLU HB3 28 0.549 2.834 4.041
28 3 GLU CG 29 0.714 2.708 4.069
29 3 GLU HG2 30 0.809 2.781 4.060
... ... ... ... ... ... ... ...
1705 104 PRO HG2 1706 3.084 3.651 3.611
1706 104 PRO HG3 1707 3.165 3.543 3.735
1707 104 PRO CD 1708 2.974 3.632 3.814
1708 104 PRO HD2 1709 3.000 3.576 3.916
1709 104 PRO HD3 1710 2.918 3.547 3.751
1710 105 ASP N 1711 3.094 4.076 3.730
1711 105 ASP H 1712 3.179 4.100 3.810
1712 105 ASP CA 1713 3.074 4.175 3.624
1713 105 ASP HA 1714 2.956 4.187 3.617
1714 105 ASP C 1715 3.147 4.134 3.497
1715 105 ASP O 1716 3.265 4.102 3.501
1716 105 ASP CB 1717 3.120 4.314 3.667
1717 105 ASP HB2 1718 3.082 4.354 3.773
1718 105 ASP HB3 1719 3.238 4.329 3.675
1719 105 ASP CG 1720 3.082 4.422 3.565
1720 105 ASP OD1 1721 3.152 4.435 3.462
1721 105 ASP OD2 1722 2.982 4.493 3.589
1722 106 ASP N 1723 3.075 4.133 3.385
1723 106 ASP H 1724 2.964 4.171 3.369
1724 106 ASP CA 1725 3.135 4.096 3.258
1725 106 ASP HA 1726 3.253 4.078 3.263
1726 106 ASP C 1727 3.128 4.214 3.161
1727 106 ASP O 1728 3.187 4.318 3.196
1728 106 ASP CB 1729 3.066 3.973 3.198
1729 106 ASP HB2 1730 2.954 3.989 3.159
1730 106 ASP HB3 1731 3.070 3.878 3.270
1731 106 ASP CG 1732 3.140 3.917 3.076
1732 106 ASP OD1 1733 3.255 3.960 3.048
1733 106 ASP OD2 1734 3.084 3.827 3.009
1734 106 ASP OXT 1735 3.086 4.199 3.047

1735 rows × 7 columns


In [ ]: