{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Download Mmtf Files Demo\n", "\n", "Example of downloading a list of PDB entries from [RCSB](\"http://mmtf.rcsb.org\")\n", "\n", "## Imports" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "from pyspark import SparkConf, SparkContext\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.structureViewer import view_structure" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Configure Spark" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "conf = SparkConf().setMaster(\"local[*]\") \\\n", " .setAppName(\"DownloadMMTFFiles\")\n", "sc = SparkContext(conf = conf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download a list of PDB entries using MMTF web services" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "pdbIds = ['1AQ1','1B38','1B39','1BUH']\n", "\n", "pdb = mmtfReader.download_mmtf_files(pdbIds, sc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Count the number of entires downloaded" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "number of entries downloaded : 4\n" ] } ], "source": [ "count = pdb.count()\n", "\n", "print(f'number of entries downloaded : {count}')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualize Structures" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "dec9087ed50a4342aa1737daca768f27", "version_major": 2, "version_minor": 0 }, "text/html": [ "
Failed to display Jupyter Widget of type interactive
.
\n", " If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean\n", " that the widgets JavaScript is still loading. If this message persists, it\n", " likely means that the widgets JavaScript library is either not installed or\n", " not enabled. See the Jupyter\n", " Widgets Documentation for setup instructions.\n", "
\n", "\n", " If you're reading this message in another frontend (for example, a static\n", " rendering on GitHub or NBViewer),\n", " it may mean that your frontend doesn't currently support widgets.\n", "
\n" ], "text/plain": [ "interactive(children=(IntSlider(value=0, description='i', max=3), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "