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]:
plt.rcParams['figure.figsize'] = np.array([16.18033, 10])    #golden ratio
plt.rcParams['figure.facecolor'] = 'w'
plt.rcParams['figure.dpi'] = 100
plt.rcParams.update({'font.size': 22})

In [4]:
def do(cmd, get=False, show=True):
    if get:
        out = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True).communicate()[0].decode()
        if show:
            print(out, end="")
        return out
    else:
        return subprocess.Popen(cmd, shell=True).wait()

In [26]:
pre = "/Users/weilu/Research/server/mar_2020/3DROBOT_DATA/3DRobot_set/3VZ9B/"
nativePdb = f"{pre}/native.pdb"
decoy_list = glob.glob(f"{pre}/decoy*.pdb")
info_ = []
p = PDBParser(QUIET=True)

for decoyPdb in decoy_list[:3]:
    decoyName = decoyPdb.split("/")[-1].split(".")[0]
    # decoyPdb = decoy_list[0]
    s = p.get_structure("decoy", decoyPdb)
    decoy_s = s[0]
    q = float(do(f"python ~/opt/small_script/CalcQValueFromTwoPdb_2.py {nativePdb} {decoyPdb}", get=True))
    info_.append([decoyName, q, decoy_s])
data = pd.DataFrame(info_, columns=["Protein", "Qw", "structure"]).sort_values("Qw").reset_index(drop=True)


0.358 0.311 0.287 

In [27]:


In [28]:
data


Out[28]:
Protein Qw structure
0 decoy12_3 0.287 (((<Atom H>, <Atom N>, <Atom CA>, <Atom C>, <A...
1 decoy28_37 0.311 (((<Atom H>, <Atom N>, <Atom CA>, <Atom C>, <A...
2 decoy29_130 0.358 (((<Atom H>, <Atom N>, <Atom CA>, <Atom C>, <A...

In [23]:
a = pd.read_pickle("/Users/weilu/Research/server/mar_2020/mass_iterative_optimization/optimization_native/decoys/openMM/1osa_iteration_start_native.pkl")

In [24]:
a


Out[24]:
Steps Qw Rg Backbone Rama Contact Fragment Exclude_Side SideChain Exclude Beta Pap Helical Total Run Protein Folder structure
0 202 0.46 19.97 210.54 -967.83 -269.01 -603.63 18.53 48.78 21.30 -46.46 -0.00 0.0 -1587.78 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
1 203 0.48 20.01 201.62 -981.04 -274.77 -612.63 26.64 48.26 23.99 -49.15 -0.00 0.0 -1617.08 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
2 204 0.51 20.38 202.44 -980.54 -283.50 -622.67 20.83 51.62 19.52 -48.10 -0.00 0.0 -1640.40 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
3 205 0.48 20.62 236.61 -970.28 -286.89 -610.83 21.13 62.85 21.41 -45.77 -0.00 0.0 -1571.78 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
4 206 0.47 20.15 218.81 -980.37 -284.72 -603.91 22.06 64.38 21.69 -50.29 -0.00 0.0 -1592.36 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
5 207 0.43 20.00 190.40 -978.31 -291.78 -597.74 20.73 47.98 20.20 -45.37 -0.00 0.0 -1633.88 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
6 208 0.50 20.34 227.69 -989.31 -278.55 -619.28 20.06 46.63 22.36 -48.09 -0.00 0.0 -1618.50 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
7 209 0.44 19.67 213.91 -971.53 -287.35 -609.09 28.55 58.41 19.92 -47.73 -0.00 0.0 -1594.90 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
8 210 0.47 19.77 199.47 -979.35 -286.19 -618.39 25.39 61.41 15.91 -46.64 -0.00 0.0 -1628.39 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
9 211 0.51 20.47 214.76 -985.16 -281.28 -609.80 25.73 58.11 14.24 -49.30 -0.00 0.0 -1612.72 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
10 212 0.56 20.46 212.73 -986.03 -268.52 -616.09 17.32 36.42 19.75 -45.84 -0.00 0.0 -1630.25 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
11 213 0.55 20.56 214.93 -977.90 -272.91 -622.88 25.00 43.14 18.16 -50.49 -0.00 0.0 -1622.94 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
12 214 0.48 20.26 216.44 -984.32 -289.41 -613.00 22.63 46.87 18.94 -45.86 -0.00 0.0 -1627.71 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
13 215 0.49 20.03 229.72 -975.15 -278.48 -610.07 25.08 56.40 26.47 -44.71 -0.00 0.0 -1570.73 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
14 216 0.53 20.76 235.50 -976.08 -287.14 -615.56 23.18 60.37 19.62 -47.55 -0.00 0.0 -1587.65 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
15 217 0.52 20.23 193.83 -986.48 -280.45 -610.45 23.77 62.97 23.40 -44.79 -0.00 0.0 -1618.20 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
16 218 0.52 20.16 226.47 -990.54 -294.93 -613.49 25.28 44.92 18.56 -46.44 -0.00 0.0 -1630.17 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
17 219 0.50 20.43 215.03 -977.20 -280.75 -607.28 22.13 53.58 16.17 -45.75 -0.00 0.0 -1604.06 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
18 220 0.48 20.71 213.41 -984.52 -282.33 -602.35 21.62 65.61 27.53 -47.79 -0.00 0.0 -1588.82 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
19 221 0.48 20.40 208.82 -972.74 -297.07 -613.78 27.97 50.25 17.90 -46.19 -0.00 0.0 -1624.83 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
20 222 0.47 20.14 214.29 -979.21 -284.57 -603.23 22.02 54.05 19.97 -49.51 -0.00 0.0 -1606.18 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
21 223 0.46 19.73 197.67 -973.75 -281.30 -608.59 22.36 61.20 24.96 -48.37 -0.00 0.0 -1605.82 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
22 224 0.44 19.83 196.87 -987.19 -289.91 -606.12 24.15 58.13 17.66 -48.96 -0.00 0.0 -1635.37 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
23 225 0.49 20.38 219.14 -974.89 -287.14 -615.29 21.70 53.87 16.82 -47.12 -0.00 0.0 -1612.91 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
24 226 0.46 20.02 227.01 -973.91 -278.30 -608.43 18.01 58.66 19.11 -46.57 -0.07 0.0 -1584.49 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
25 227 0.47 20.31 234.54 -976.36 -276.22 -603.99 15.26 42.17 19.52 -46.23 -0.00 0.0 -1591.31 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
26 228 0.50 20.93 228.57 -975.09 -276.83 -633.77 22.61 48.51 17.77 -49.89 -0.00 0.0 -1618.13 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
27 229 0.48 20.46 220.63 -975.12 -279.01 -620.62 23.54 45.83 21.93 -47.05 -0.00 0.0 -1609.88 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
28 230 0.46 20.50 224.01 -972.77 -291.46 -612.90 31.98 54.11 25.59 -44.04 -0.01 0.0 -1585.49 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
29 231 0.46 20.82 194.23 -981.29 -264.47 -606.20 20.79 55.40 20.76 -47.44 -0.00 0.0 -1608.22 0 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
70 222 0.50 20.06 216.58 -978.09 -277.40 -619.48 23.21 54.17 23.77 -49.01 -0.00 0.0 -1606.24 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
71 223 0.45 19.38 202.89 -975.78 -277.33 -595.01 19.97 50.83 22.51 -48.79 -0.20 0.0 -1600.91 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
72 224 0.43 19.10 224.62 -985.35 -282.83 -606.53 21.28 57.47 21.14 -51.03 -0.00 0.0 -1601.23 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
73 225 0.46 19.59 215.20 -990.77 -286.46 -602.03 22.86 54.89 19.30 -50.74 -0.00 0.0 -1617.75 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
74 226 0.43 19.39 221.62 -986.72 -279.99 -612.42 21.64 59.46 21.71 -47.68 -0.00 0.0 -1602.38 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
75 227 0.46 19.91 196.29 -980.23 -285.16 -604.00 17.76 58.84 17.94 -52.99 -0.00 0.0 -1631.55 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
76 228 0.48 20.09 213.08 -960.06 -278.93 -605.74 21.64 58.59 30.30 -50.02 -0.00 0.0 -1571.16 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
77 229 0.45 19.47 215.89 -985.92 -286.40 -600.37 21.72 48.60 15.32 -47.98 -0.00 0.0 -1619.14 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
78 230 0.48 19.90 207.76 -971.91 -289.60 -604.72 24.46 63.64 19.17 -48.87 -0.00 0.0 -1600.08 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
79 231 0.52 19.99 199.39 -967.21 -262.11 -616.13 20.58 61.77 17.99 -46.86 -0.00 0.0 -1592.58 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
80 232 0.48 19.99 220.46 -969.73 -269.78 -621.63 21.96 51.46 19.80 -51.33 -0.00 0.0 -1598.79 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
81 233 0.50 20.59 197.58 -976.50 -271.66 -606.19 19.48 65.93 21.90 -45.90 -0.00 0.0 -1595.36 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
82 234 0.48 20.70 211.45 -977.65 -287.62 -612.02 23.13 58.22 15.15 -46.78 -0.00 0.0 -1616.12 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
83 235 0.47 20.04 214.22 -982.21 -285.47 -612.25 20.99 46.75 13.90 -47.05 -0.00 0.0 -1631.14 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
84 236 0.48 20.01 238.68 -975.98 -283.45 -620.03 22.88 56.31 19.39 -52.35 -0.00 0.0 -1594.55 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
85 237 0.52 20.30 197.98 -979.17 -277.16 -616.20 24.71 69.74 20.67 -50.91 -0.00 0.0 -1610.35 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
86 238 0.46 19.93 205.17 -983.02 -282.23 -608.05 16.35 54.72 18.51 -46.04 -0.00 0.0 -1624.58 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
87 239 0.47 20.00 196.07 -961.97 -280.05 -615.01 18.75 46.56 16.39 -46.89 -0.00 0.0 -1626.14 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
88 240 0.46 19.90 233.23 -982.21 -273.94 -607.79 20.47 41.81 20.80 -46.57 -0.00 0.0 -1594.20 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
89 241 0.45 20.03 203.99 -982.96 -273.38 -601.32 19.05 52.85 18.42 -47.20 -0.00 0.0 -1610.56 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
90 242 0.45 19.98 216.58 -981.34 -276.36 -609.83 25.49 52.55 17.11 -47.14 -0.00 0.0 -1602.94 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
91 243 0.47 20.25 221.34 -976.02 -280.30 -616.73 21.08 55.57 21.56 -48.21 -0.00 0.0 -1601.72 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
92 244 0.50 20.40 222.34 -980.62 -287.17 -607.50 21.23 44.64 18.16 -49.47 -0.00 0.0 -1618.39 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
93 245 0.46 19.75 211.07 -972.25 -276.62 -606.40 20.60 42.57 19.36 -47.38 -0.00 0.0 -1609.06 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
94 246 0.54 20.65 218.71 -978.24 -259.21 -625.94 14.51 66.91 20.05 -48.88 -0.00 0.0 -1592.08 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
95 247 0.55 21.04 209.29 -975.08 -278.28 -618.65 22.20 53.79 17.13 -45.89 -0.00 0.0 -1615.50 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
96 248 0.47 20.26 227.06 -980.66 -279.75 -607.96 22.92 48.94 17.83 -49.13 -0.00 0.0 -1600.75 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
97 249 0.51 20.42 223.94 -974.39 -285.72 -616.94 21.67 62.90 13.96 -49.45 -0.00 0.0 -1604.04 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
98 250 0.52 20.49 222.61 -975.35 -272.64 -615.92 19.40 52.86 17.51 -49.17 -0.00 0.0 -1600.70 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...
99 251 0.49 20.16 220.14 -977.32 -269.28 -602.38 24.47 60.55 18.08 -47.73 -0.00 0.0 -1573.47 1 1osa iteration_start_native (((<Atom CA>, <Atom C>, <Atom O>, <Atom CB>), ...

100 rows × 18 columns


In [ ]: