In [1]:
%matplotlib inline

In [2]:
from hiveplot import HivePlot
import networkx as nx
import matplotlib.pyplot as plt

In [3]:
p = nx.read_gpickle('hiv1_homology_model.pkl')
p


/Users/ericmjl/anaconda/lib/python3.5/site-packages/sklearn/preprocessing/data.py:583: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
  warnings.warn(DEPRECATION_MSG_1D, DeprecationWarning)
/Users/ericmjl/anaconda/lib/python3.5/site-packages/sklearn/preprocessing/data.py:583: DeprecationWarning: Passing 1d arrays as data is deprecated in 0.17 and will raise ValueError in 0.19. Reshape your data either using X.reshape(-1, 1) if your data has a single feature or X.reshape(1, -1) if it contains a single sample.
  warnings.warn(DEPRECATION_MSG_1D, DeprecationWarning)
Out[3]:
<pin.pin.ProteinInteractionNetwork at 0x10b303a90>

In [4]:
p.nodes(data=True)[0]


Out[4]:
('B62ILE',
 {'chain_id': 'B',
  'features': array([[  0.        ,   0.        ,   0.        ,   0.        ,
            0.        ,   0.        ,   0.        ,   0.        ,
            0.        ,   0.        ,   0.        ,   1.        ,
            0.        ,   0.        ,   0.        ,   0.        ,
            0.        ,   0.        ,   0.        ,   0.        ,
            0.        ,   0.        ,   0.        ,  -0.13533789,
           -0.2123377 ,   6.        ,  36.98579247,   0.        ,
            0.        ,   1.        ,   0.        ,   0.        ,
            0.        ,   0.        ,   1.        ,   0.        ]]),
  'resi_name': 'ILE',
  'resi_num': 62,
  'x': 19.75,
  'y': 16.239999999999998,
  'z': 28.93})

In [5]:
nodes = dict()
nodes['chainA'] = [n for n, d in p.nodes(data=True) if d['chain_id'] == 'A']
nodes['chainB'] = [n for n, d in p.nodes(data=True) if d['chain_id'] == 'B']

edges = dict()
edges['all'] = [(u, v, d) for u, v, d in p.edges(data=True)]

nodes_cmap = dict()
nodes_cmap['chainA'] = 'red'
nodes_cmap['chainB'] = 'blue'

In [6]:
h = HivePlot(nodes, edges, nodes_cmap)
h.draw()
plt.savefig('protein_graph.pdf')



In [ ]: