{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Filter Protein Dna Complexes Demo\n", "\n", "This example shows how to filter PDB by protein DNA complexes\n", "\n", "![](./figures/ProteinDnaComplex.png)\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 ContainsDnaChain, ContainsLProteinChain\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(\"FilterProteinDnaComplexDate\")\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 proteins that cotinas Dna chain and L protein chain\n", "\n", "1) Retain pdb entires that exclusively contain L-peptide chains\n", "2) Retain pdb entries that exclusively contain L-Dna" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "structures = pdb.filter(ContainsLProteinChain()) \\\n", " .filter(ContainsDnaChain())" ] }, { "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 entires that contain L-protein and L-DNA: 124\n" ] } ], "source": [ "count = structures.count()\n", "\n", "print(f\"Number of entires that contain L-protein and L-DNA: {count}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualize Structures" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "d1fefe5f913a4a9285879bf1d175400d", "version_major": 2, "version_minor": 0 }, "text/html": [ "

Failed to display Jupyter Widget of type interactive.

\n", "

\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=123), Output()), _dom_classes=('widget-interact',))" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ ".view3d>" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "structure_names = structures.keys().collect()\n", "view_structure(structure_names)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Terminate Spark " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "sc.stop()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.0" } }, "nbformat": 4, "nbformat_minor": 2 }