{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Filter By Deposition Date Demo\n", "\n", "## Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pyspark import SparkConf, SparkContext\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.filters import DepositionDate\n", "from mmtfPyspark.structureViewer import view_structure" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Configure Spark" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "conf = SparkConf().setMaster(\"local[*]\") \\\n", " .setAppName(\"FilterByDepositionDate\")\n", "sc = SparkContext(conf = conf)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read in MMTF Files" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "path = \"../../resources/mmtf_reduced_sample/\"\n", "\n", "pdb = mmtfReader.read_sequence_file(path, sc)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Filter by deposition date" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "pdb = pdb.filter(DepositionDate('1999-02-26','1999-02-28'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Count number of entires" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of structure desposited between 1999-02-26 and 1999-02-28 is : 5\n" ] } ], "source": [ "count = pdb.count()\n", "\n", "print(f\"Number of structure desposited between 1999-02-26 and 1999-02-28 is : {count}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## View 3D structures" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b7be91a2b5014fe0ab9e5f0d2be89670", "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=4), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "