{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Solution-1\n", "Apply your skills to filter structures and visualize the hits.\n", "\n", "For details see [filters](https://github.com/sbl-sdsc/mmtf-pyspark/tree/master/mmtfPyspark/filters) and [demos](https://github.com/sbl-sdsc/mmtf-pyspark/tree/master/demos/filters)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Import pyspark and mmtfPyspark" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from pyspark.sql import SparkSession\n", "from mmtfPyspark.io import mmtfReader\n", "from mmtfPyspark.filters import ContainsDnaChain, ContainsLProteinChain, ContainsSequenceRegex, RFree\n", "from mmtfPyspark.structureViewer import view_structure, view_group_interaction" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Configure Spark" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "spark = SparkSession.builder.appName(\"Solution-1\").getOrCreate()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Read PDB structures" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "path = \"../resources/mmtf_reduced_sample/\"\n", "pdb = mmtfReader.read_sequence_file(path).cache()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-1: Filter structures by R-free in the range [0, 0.2]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [], "source": [ "pdb = pdb.filter(RFree(0, 0.2))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-2: Find the protein-DNA complexes in this dataset" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "pdb = pdb.filter(ContainsLProteinChain()).filter(ContainsDnaChain())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-3: Create a of list the PDB IDs of the protein-DNA complexes" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "complexes = pdb.keys().collect()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Visualize the protein-DNA complexes" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "6d49f36a76fb49fd8062c591e180025a", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(IntSlider(value=0, continuous_update=False, description='Structure', max=27), Output()),…" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "view_structure(complexes);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### TODO-4: Find complexes with a Zinc finger motif\n", "Zinc finger have the following sequence motif (regular expression): \"C.{2,4}C.{12}H.{3,5}H\"." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [], "source": [ "pdb = pdb.filter(ContainsSequenceRegex(\"C.{2,4}C.{12}H.{3,5}H\"))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "652b13469a604badba47a5b622e14524", "version_major": 2, "version_minor": 0 }, "text/plain": [ "interactive(children=(IntSlider(value=0, continuous_update=False, description='Structure', max=1), Output()), …" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "view_group_interaction(pdb.keys().collect(),\"ZN\");" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "spark.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.13" } }, "nbformat": 4, "nbformat_minor": 4 }