!pip install nglview --user
Requirement already satisfied: nglview in c:\users\vital\appdata\roaming\python\python39\site-packages (3.0.3) Requirement already satisfied: numpy in c:\anaconda3\lib\site-packages (from nglview) (1.21.5) Requirement already satisfied: jupyterlab-widgets in c:\anaconda3\lib\site-packages (from nglview) (1.0.0) Requirement already satisfied: ipywidgets>=7 in c:\anaconda3\lib\site-packages (from nglview) (7.6.5) Requirement already satisfied: nbformat>=4.2.0 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (5.5.0) Requirement already satisfied: widgetsnbextension~=3.5.0 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (3.5.2) Requirement already satisfied: ipython-genutils~=0.2.0 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (0.2.0) Requirement already satisfied: ipython>=4.0.0 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (7.31.1) Requirement already satisfied: ipykernel>=4.5.1 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (6.15.2) Requirement already satisfied: traitlets>=4.3.1 in c:\anaconda3\lib\site-packages (from ipywidgets>=7->nglview) (5.1.1) Requirement already satisfied: nest-asyncio in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (1.5.5) Requirement already satisfied: tornado>=6.1 in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (6.1) Requirement already satisfied: pyzmq>=17 in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (23.2.0) Requirement already satisfied: matplotlib-inline>=0.1 in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (0.1.6) Requirement already satisfied: debugpy>=1.0 in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (1.5.1) Requirement already satisfied: psutil in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (5.9.0) Requirement already satisfied: packaging in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (21.3) Requirement already satisfied: jupyter-client>=6.1.12 in c:\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets>=7->nglview) (7.3.4) Requirement already satisfied: jedi>=0.16 in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (0.18.1) Requirement already satisfied: backcall in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (0.2.0) Requirement already satisfied: colorama in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (0.4.5) Requirement already satisfied: setuptools>=18.5 in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (63.4.1) Requirement already satisfied: pygments in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (2.11.2) Requirement already satisfied: pickleshare in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (0.7.5) Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (3.0.20) Requirement already satisfied: decorator in c:\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets>=7->nglview) (5.1.1) Requirement already satisfied: jupyter_core in c:\anaconda3\lib\site-packages (from nbformat>=4.2.0->ipywidgets>=7->nglview) (4.11.1) Requirement already satisfied: jsonschema>=2.6 in c:\anaconda3\lib\site-packages (from nbformat>=4.2.0->ipywidgets>=7->nglview) (4.16.0) Requirement already satisfied: fastjsonschema in c:\anaconda3\lib\site-packages (from nbformat>=4.2.0->ipywidgets>=7->nglview) (2.16.2) Requirement already satisfied: notebook>=4.4.1 in c:\anaconda3\lib\site-packages (from widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (6.4.12) Requirement already satisfied: parso<0.9.0,>=0.8.0 in c:\anaconda3\lib\site-packages (from jedi>=0.16->ipython>=4.0.0->ipywidgets>=7->nglview) (0.8.3) Requirement already satisfied: pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in c:\anaconda3\lib\site-packages (from jsonschema>=2.6->nbformat>=4.2.0->ipywidgets>=7->nglview) (0.18.0) Requirement already satisfied: attrs>=17.4.0 in c:\anaconda3\lib\site-packages (from jsonschema>=2.6->nbformat>=4.2.0->ipywidgets>=7->nglview) (21.4.0) Requirement already satisfied: python-dateutil>=2.8.2 in c:\anaconda3\lib\site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets>=7->nglview) (2.8.2) Requirement already satisfied: entrypoints in c:\anaconda3\lib\site-packages (from jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets>=7->nglview) (0.4) Requirement already satisfied: pywin32>=1.0 in c:\anaconda3\lib\site-packages (from jupyter_core->nbformat>=4.2.0->ipywidgets>=7->nglview) (302) Requirement already satisfied: nbconvert>=5 in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (6.4.4) Requirement already satisfied: Send2Trash>=1.8.0 in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (1.8.0) Requirement already satisfied: terminado>=0.8.3 in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.13.1) Requirement already satisfied: argon2-cffi in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (21.3.0) Requirement already satisfied: jinja2 in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (2.11.3) Requirement already satisfied: prometheus-client in c:\anaconda3\lib\site-packages (from notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.14.1) Requirement already satisfied: wcwidth in c:\anaconda3\lib\site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=4.0.0->ipywidgets>=7->nglview) (0.2.5) Requirement already satisfied: pyparsing!=3.0.5,>=2.0.2 in c:\anaconda3\lib\site-packages (from packaging->ipykernel>=4.5.1->ipywidgets>=7->nglview) (3.0.9) Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.5.13) Requirement already satisfied: pandocfilters>=1.4.1 in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (1.5.0) Requirement already satisfied: testpath in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.6.0) Requirement already satisfied: jupyterlab-pygments in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.1.2) Requirement already satisfied: beautifulsoup4 in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (4.11.1) Requirement already satisfied: defusedxml in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.7.1) Requirement already satisfied: mistune<2,>=0.8.1 in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.8.4) Requirement already satisfied: bleach in c:\anaconda3\lib\site-packages (from nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (4.1.0) Requirement already satisfied: MarkupSafe>=0.23 in c:\anaconda3\lib\site-packages (from jinja2->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (2.0.1) Requirement already satisfied: six>=1.5 in c:\anaconda3\lib\site-packages (from python-dateutil>=2.8.2->jupyter-client>=6.1.12->ipykernel>=4.5.1->ipywidgets>=7->nglview) (1.16.0) Requirement already satisfied: pywinpty>=1.1.0 in c:\anaconda3\lib\site-packages (from terminado>=0.8.3->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (2.0.2) Requirement already satisfied: argon2-cffi-bindings in c:\anaconda3\lib\site-packages (from argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (21.2.0) Requirement already satisfied: cffi>=1.0.1 in c:\anaconda3\lib\site-packages (from argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (1.15.1) Requirement already satisfied: soupsieve>1.2 in c:\anaconda3\lib\site-packages (from beautifulsoup4->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (2.3.1) Requirement already satisfied: webencodings in c:\anaconda3\lib\site-packages (from bleach->nbconvert>=5->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (0.5.1) Requirement already satisfied: pycparser in c:\anaconda3\lib\site-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->notebook>=4.4.1->widgetsnbextension~=3.5.0->ipywidgets>=7->nglview) (2.21)
import nglview as nv
import requests # Этот стандартный модуль позволяет посылать запросы к веб-ресурсам
import json # Этот стандартный модуль позволяет легко работать с текстовым форматом json
my_query = {
"query": {
"type": "group",
"logical_operator": "and",
"nodes": []
},
"return_type": "entry"
}
keyword_clause = {
"type": "terminal",
"service": "full_text", # искать во всех текстовых полях
"parameters": {
"value": "androgen receptor with testosterone" # ключевые слова
}
}
my_query["query"]["nodes"].append(keyword_clause)
resolution_clause = {
"type": "terminal",
"service": "text",
"parameters": {
"value": 2.5, # Какое разрешение: не хуже 2.5 ангстрем
"attribute": "rcsb_entry_info.resolution_combined",
"operator": "less_or_equal"
}
}
my_query["query"]["nodes"].append(resolution_clause)
# Сколько лигандов должно быть в записи: не меньше 1 (то есть больше 0)
has_ligand_clause = {
"type": "terminal",
"service": "text",
"parameters": {
"attribute": "rcsb_entry_info.nonpolymer_entity_count",
"value": 0,
"operator": "greater"
}
}
my_query["query"]["nodes"].append(has_ligand_clause)
# Дата публикации записи: с января 2005 по январь 2010 года
date_range_clause = {
"type": "terminal",
"service": "text",
"parameters": {
"attribute": "rcsb_accession_info.initial_release_date",
"value": {
"from": "2005-01-01", # год-месяц-день
"to": "2010-01-01",
},
"operator": "range"
}
}
my_query["query"]["nodes"].append(date_range_clause)
rcsb = 'https://search.rcsb.org/rcsbsearch/v2/query'
json_query = json.dumps(my_query)
search = requests.post(f'{rcsb}', data=json_query) # Отсылаем запрос
search # проверка (200 - значит хорошо)
<Response [200]>
search_result = search.json() # Распаковываем ответ сервера в словарь
search_result # Берём лучшую находку
{'query_id': '717eccea-4aa6-438d-a4da-5051de3df35b', 'result_type': 'entry', 'total_count': 16514, 'result_set': [{'identifier': '2AM9', 'score': 0.9867492062372719}, {'identifier': '2Q7I', 'score': 0.9857518477206042}, {'identifier': '2Q7K', 'score': 0.985729945544985}, {'identifier': '2Q7L', 'score': 0.982568026943184}, {'identifier': '2Q7J', 'score': 0.9817502033034597}, {'identifier': '2AMA', 'score': 0.9784848902422165}, {'identifier': '2IHQ', 'score': 0.9603377009659534}, {'identifier': '2PNU', 'score': 0.9572375761820181}, {'identifier': '2AMB', 'score': 0.9553533144737761}, {'identifier': '1Z95', 'score': 0.9530152684698528}]}
best_hit = search_result["result_set"][0] # Лучшая находка
best_hit
{'identifier': '2AM9', 'score': 0.9867492062372719}
ЗАДАНИЕ 2: Таким образом, я далее буду работать с PDB ID 2AM9. На сайте RCSB PDBпод этим идентификатором была найдена "Кристаллическая структура лигандсвязывающего домена рецептора андрогена человека в комплексе с тестостероном(ключевые слова из запроса в заголовке)"(рецептор из организма человека; экспресирован Escherichia coli).Андрогены оказывают свое действие путем связывания с высокоспецифичным рецептором андрогена (AR). В дополнение к природным мощным андрогенам, AR связывает множество синтетических молекул-агонистов или антагонистов с различным сродством. Сама структура лиганда (размер, наличие и положение ненасыщенных связей, которые влияют на геометрию стероидного ядра или электронные свойства соседних атомов и т.д.) определяет количество взаимодействий, которые он может осуществлять с hARLBD( лигандсвязывающего домена рецептора андрогена человека ).
from ipywidgets import interact, fixed
my_examples = {
'Вариант 1': {
'description': '''
Поверхность белка покрашена в белый, с непрозрачностью 0.1
Белок в виде rope красного цвета
Боковые радикалы в стержневой модели, покрашенные согласно элементу
Лиганды в виде Ван-дер-Ваальсовых сфер, покрашены по элементам
''',
'representations': [
{
'type': 'surface',
'params': {
'sele': 'protein',
'color': 'white',
'opacity': 0.1
}
},
{
'type': 'rope',
'params': {
'sele': 'protein',
'color': 'red'
}
},
{
'type': 'licorice',
'params': {
'sele': 'sidechainAttached',
'color': 'element'
}
},
{
'type': 'spacefill',
'params': {
'sele': 'ligand',
'color': 'element'
}
},
],
},
'Вариант 5': {
'description': '''
Белок в виде tube, покраска по типу вторичной структуры
Боковые радикалы в стержневой модели, покрашены по гидрофобности
Лиганды показаны линиями, покрашены по элементам
Вода и ионы показаны в виде Ван-дер-Ваальсовых сфер
''',
'representations': [
{
'type': 'tube',
'params': {
'sele': 'protein',
'color': 'sstruc'
}
},
{
'type': 'line',
'params': {
'sele': 'ligand',
'color': 'element'
}
},
{
'type': 'licorice',
'params': {
'sele': 'sidechainAttached',
'color': 'hydrophobicity'
}
},
{
'type':'spacefill',
'params': {
'sele':'water or ion'
}
},
],
},
'Вариант 10': {
'description': '''
Белок в виде cartoon белого цвета
Cartoon для остатков с 20-го по 55-й покрашен в зеленый
Для остатков с 20-го по 55-й показаны боковые радикалы в модели hyperball, покраска по элементам
Лиганды показаны в шаростержневой модели, покраска по элементам
''',
'representations': [
{
'type': 'cartoon',
'params': {
'sele': 'protein',
'color': 'white'
}
},
{
'type': 'cartoon',
'params': {
'sele': 'protein and 20-55',
'color': 'green'
}
},
{
'type': 'hyperball',
'params': {
'sele': 'sidechainAttached and 20-55',
'color': 'element'
}
},
{
'type': 'ball+stick',
'params': {
'sele': 'ligand',
'color': 'element'
}
},
],
},
}
def show_examples(view, example_name):
view.clear()
example = my_examples[example_name]
print(example['description'])
view.set_representations(example['representations'])
view.center()
view = nv.show_pdbid("2am9", default_representation=False)
interact(show_examples, view=fixed(view), example_name=list(my_examples.keys()))
view