#!/usr/bin/env python # coding: utf-8 # # Solution-1 # Visualize a PDB structure, set styles, and add labels. # In[1]: import py3Dmol # ### TODO-1 # Instantiate py3Dmol viewer with PDB structure 1NCA (Neuraminidase-FAB complex) # In[2]: viewer = py3Dmol.view(query='pdb:1NCA') viewer.show() # ### TODO-2 # Apply the following styles to this structure: # * chain N (Neuraminidase): orange cartoon # * chain H (Heavy chain): blue sphere # * chain L (Light chain): lightblue sphere # # In[3]: viewer.setStyle({'chain':'N'},{'cartoon': {'color': 'orange'}}) viewer.setStyle({'chain':'H'},{'sphere': {'color': 'blue'}}) viewer.setStyle({'chain':'L'},{'sphere': {'color': 'lightblue'}}) viewer.show() # ### TODO-3: Add text labels to the three chains # In[4]: viewer.addLabel('Neuraminidase', {'fontColor':'orange', 'backgroundColor':'lightgray'}, {'chain': 'N'}) viewer.addLabel('Heavy chain', {'fontColor':'blue', 'backgroundColor':'lightgray'}, {'chain': 'H'}) viewer.addLabel('Light chain', {'fontColor':'blue', 'backgroundColor':'lightgray'}, {'chain': 'L'}) viewer.show() # ### Bonus: Set the style for sugar residues MAN, BMA, and NAG to stick and color by a greenCarbon colorscheme. # In[5]: viewer.setStyle({'resn': ['MAN', 'BMA', 'NAG']}, {'stick':{'colorscheme': 'greenCarbon'}}) viewer.show()